36 lines
1.1 KiB
Python
Executable File
36 lines
1.1 KiB
Python
Executable File
import requests
|
|
import json
|
|
import datetime
|
|
|
|
MEMORY_FILE = "/opt/wevads/data/ai_memory.json"
|
|
|
|
def summarize_and_learn():
|
|
with open(MEMORY_FILE, 'r') as f:
|
|
data = json.load(f)
|
|
|
|
# On analyse les 100 dernières interactions (Discussion + Logs)
|
|
context = " ".join([item['text'] for item in data[-100:]])
|
|
|
|
prompt = f"Analyse ces données d'Arsenal et génère 3 règles d'or pour optimiser les campagnes de demain : {context}"
|
|
|
|
r = requests.post('http://localhost:11434/api/generate',
|
|
json={"model": "llama3.2", "prompt": prompt, "stream": False})
|
|
|
|
insight = r.json().get('response', '')
|
|
|
|
# RÉ-INJECTION : On stocke l'insight comme une 'Règle d'Or'
|
|
new_entry = {
|
|
"timestamp": datetime.datetime.now().isoformat(),
|
|
"text": f"🧠 RÈGLE D'OR STRATÉGIQUE : {insight}",
|
|
"source": "self_synthesis"
|
|
}
|
|
|
|
data.append(new_entry)
|
|
with open(MEMORY_FILE, 'w') as f:
|
|
json.dump(data, f, indent=2)
|
|
|
|
print(f"📈 IA : Nouvelle règle d'or apprise : {insight[:100]}...")
|
|
|
|
if __name__ == "__main__":
|
|
summarize_and_learn()
|