An agent with SQLiteStore that remembers conversation history across turns. Demonstrates the simplest memory setup.
from definable.agent import Agentfrom definable.memory import Memory, SQLiteStorefrom definable.model import OpenAIChatmemory = Memory(store=SQLiteStore("./example_memory.db"))agent = Agent( model=OpenAIChat(id="gpt-4o-mini"), instructions="You are a helpful assistant with persistent memory.", memory=memory,)# Store informationoutput = agent.run( "My name is Alice and I'm a software engineer at Acme Corp.", user_id="alice",)print(output.content)# Recall informationoutput = agent.run("What do you know about me?", user_id="alice")print(output.content)
Exercises the MemoryStore protocol methods using InMemoryStore. Useful for understanding the data model without any external dependencies.
from definable.memory import InMemoryStorefrom definable.memory.types import MemoryEntrystore = InMemoryStore()await store.initialize()# Store a conversation entryentry = MemoryEntry( session_id="s1", user_id="alice", role="user", content="Hello, I'm Alice from San Francisco.",)await store.add(entry)# Query entriesentries = await store.get_entries("s1", user_id="alice")for e in entries: print(f"[{e.memory_id}] {e.role}: {e.content}")# Deleteawait store.delete(entry.memory_id)