Documentation Index
Fetch the complete documentation index at: https://docs-v1.agno.com/llms.txt
Use this file to discover all available pages before exploring further.
Code
cookbook/apps/discord/agent_with_user_memory.py
You are viewing v1 docs. For the latest documentation, visit docs.agno.com
Documentation Index
Fetch the complete documentation index at: https://docs-v1.agno.com/llms.txt
Use this file to discover all available pages before exploring further.
from textwrap import dedent
from agno.agent import Agent
from agno.app.discord import DiscordClient
from agno.memory.v2.db.sqlite import SqliteMemoryDb
from agno.memory.v2.manager import MemoryManager
from agno.memory.v2.memory import Memory
from agno.models.google import Gemini
from agno.storage.sqlite import SqliteStorage
from agno.tools.googlesearch import GoogleSearchTools
agent_storage = SqliteStorage(
table_name="agent_sessions", db_file="tmp/persistent_memory.db"
)
memory_db = SqliteMemoryDb(table_name="memory", db_file="tmp/memory.db")
memory = Memory(
db=memory_db,
memory_manager=MemoryManager(
memory_capture_instructions="""\
Collect User's name,
Collect Information about user's passion and hobbies,
Collect Information about the users likes and dislikes,
Collect information about what the user is doing with their life right now
""",
model=Gemini(id="gemini-2.0-flash"),
),
)
# Reset the memory for this example
memory.clear()
personal_agent = Agent(
name="Basic Agent",
model=Gemini(id="gemini-2.0-flash"),
tools=[GoogleSearchTools()],
add_history_to_messages=True,
num_history_responses=3,
add_datetime_to_instructions=True,
markdown=True,
memory=memory,
enable_agentic_memory=True,
instructions=dedent("""
You are a personal AI friend of the user, your purpose is to chat with the user about things and make them feel good.
First introduce yourself and ask for their name then, ask about themeselves, their hobbies, what they like to do and what they like to talk about.
Use Google Search tool to find latest infromation about things in the conversations
"""),
debug_mode=True,
)
discord_agent = DiscordClient(personal_agent)
if __name__ == "__main__":
discord_agent.serve()
Create a virtual environment
Terminal and create a python virtual environment.python3 -m venv .venv
source .venv/bin/activate
Was this page helpful?