forked from Arindam200/awesome-ai-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
75 lines (67 loc) · 2.02 KB
/
Copy pathmain.py
File metadata and controls
75 lines (67 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from agno.agent import Agent
from agno.memory.v2.db.sqlite import SqliteMemoryDb
from agno.memory.v2.memory import Memory
from agno.models.nebius import Nebius
from agno.storage.sqlite import SqliteStorage
from rich.pretty import pprint
import os
from dotenv import load_dotenv
load_dotenv()
# UserId for the memories
user_id = "arindam"
# Database file for memory and storage
db_file = "tmp/agent.db"
# Initialize memory.v2
memory = Memory(
# Use any model for creating memories
model=Nebius(
id="deepseek-ai/DeepSeek-V3-0324", api_key=os.getenv("NEBIUS_API_KEY")
),
db=SqliteMemoryDb(table_name="user_memories", db_file=db_file),
)
# Initialize storage
storage = SqliteStorage(table_name="agent_sessions", db_file=db_file)
# Initialize Agent
memory_agent = Agent(
model=Nebius(
id="deepseek-ai/DeepSeek-V3-0324", api_key=os.getenv("NEBIUS_API_KEY")
),
# Store memories in a database
memory=memory,
# Give the Agent the ability to update memories
enable_agentic_memory=True,
# OR - Run the MemoryManager after each response
enable_user_memories=True,
# Store the chat history in the database
storage=storage,
# Add the chat history to the messages
add_history_to_messages=True,
# Number of history runs
num_history_runs=3,
markdown=True,
)
memory.clear()
memory_agent.print_response(
"My name is Arindam and I support Mohun Bagan.",
user_id=user_id,
stream=True,
stream_intermediate_steps=True,
)
print("Memories about Arindam:")
pprint(memory.get_user_memories(user_id=user_id))
memory_agent.print_response(
"I live in Kolkata, where should i move within a 4 hour drive?",
user_id=user_id,
stream=True,
stream_intermediate_steps=True,
)
print("Memories about Arindam:")
pprint(memory.get_user_memories(user_id=user_id))
memory_agent.print_response(
"Tell me about Arindam",
user_id=user_id,
stream=True,
stream_intermediate_steps=True,
)
print("Memories about Arindam:")
pprint(memory.get_user_memories(user_id=user_id))