@@ -38,26 +38,39 @@ from agno.models.openai import OpenAIChat
3838from agno.storage.sqlite import SqliteStorage
3939from rich.pretty import pprint
4040
41+ # UserId for the memories
4142user_id = " ava"
42- db_file = " tmp/memory.db"
43+ # Database file for memory and storage
44+ db_file = " tmp/agent.db"
45+
46+ # Initialize memory.v2
4347memory = Memory(
48+ # Use any model for creating memories
49+ model = OpenAIChat(id = " gpt-4.1" ),
4450 db = SqliteMemoryDb(table_name = " user_memories" , db_file = db_file),
45- delete_memories = True ,
46- clear_memories = True ,
4751)
48- memory.clear()
52+ # Initialize storage
4953storage = SqliteStorage(table_name = " agent_sessions" , db_file = db_file)
5054
55+ # Initialize Agent
5156memory_agent = Agent(
5257 model = OpenAIChat(id = " gpt-4.1" ),
58+ # Store memories in a database
5359 memory = memory,
60+ # Give the Agent the ability to update memories
5461 enable_agentic_memory = True ,
62+ # OR - Run the MemoryManager after each response
63+ enable_user_memories = True ,
64+ # Store the chat history in the database
5565 storage = storage,
66+ # Add the chat history to the messages
5667 add_history_to_messages = True ,
68+ # Number of history runs
5769 num_history_runs = 3 ,
58- read_chat_history = True ,
70+ markdown = True ,
5971)
6072
73+ memory.clear()
6174memory_agent.print_response(
6275 " My name is Ava and I like to ski." ,
6376 user_id = user_id,
@@ -68,7 +81,7 @@ print("Memories about Ava:")
6881pprint(memory.get_user_memories(user_id = user_id))
6982
7083memory_agent.print_response(
71- " I live in san francisco" ,
84+ " I live in san francisco, where should i move within a 4 hour drive? " ,
7285 user_id = user_id,
7386 stream = True ,
7487 stream_intermediate_steps = True ,
0 commit comments