from openai import OpenAI
from memwire import MemWire, MemWireConfig
client = OpenAI()
config = MemWireConfig(qdrant_path="./memwire_data")
memory = MemWire(config=config)
USER_ID = "alice"
memory.add(user_id=USER_ID, messages=[
{"role": "user", "content": "I always write documentation before code."},
{"role": "user", "content": "I find long meetings unproductive."},
])
result = memory.recall("How do you approach software projects?", user_id=USER_ID)
messages = [{"role": "system", "content": "You are a helpful assistant."}]
if result.formatted:
messages.append({"role": "system", "content": f"Memory:\n{result.formatted}"})
messages.append({"role": "user", "content": "How do you approach software projects?"})
response = client.chat.completions.create(model="gpt-4o", messages=messages)
reply = response.choices[0].message.content
# Feed the response back — edges that contributed to this answer get stronger
stats = memory.feedback(response=reply, user_id=USER_ID)
print(stats) # {"strengthened": 4, "weakened": 1}