-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description - Cache model clients --- ## Type of change Please check the options that are relevant: - [x] Model update (Addition or modification of models) --- ## Checklist - [x] Adherence to standards: Code complies with Agno’s style guidelines and best practices. - [x] Formatting and validation: You have run `./scripts/format.sh` and `./scripts/validate.sh` to ensure code is formatted and linted. - [x] Self-review completed: A thorough review has been performed by the contributor(s). - [x] Documentation: Docstrings and comments have been added or updated for any complex logic. - [x] Examples and guides: Relevant cookbook examples have been included or updated (if applicable). - [x] Tested in a clean environment: Changes have been tested in a clean environment to confirm expected behavior. - [x] Tests (optional): Tests have been added or updated to cover any new or changed functionality. --------- Co-authored-by: Dirk Brand <[email protected]>
- Loading branch information
1 parent
29885e1
commit 6653576
Showing
20 changed files
with
228 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
This recipe shows how to use personalized memories and summaries in an agent. | ||
Steps: | ||
1. Run: `./cookbook/scripts/run_pgvector.sh` to start a postgres container with pgvector | ||
2. Run: `pip install anthropic sqlalchemy 'psycopg[binary]' pgvector` to install the dependencies | ||
3. Run: `python cookbook/models/anthropic/memory.py` to run the agent | ||
""" | ||
|
||
from agno.agent import Agent, AgentMemory | ||
from agno.memory.db.postgres import PgMemoryDb | ||
from agno.models.anthropic import Claude | ||
from agno.storage.agent.postgres import PostgresAgentStorage | ||
from rich.pretty import pprint | ||
|
||
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai" | ||
agent = Agent( | ||
model=Claude(id="claude-3-5-sonnet-20241022"), | ||
# Store the memories and summary in a database | ||
memory=AgentMemory( | ||
db=PgMemoryDb(table_name="agent_memory", db_url=db_url), | ||
create_user_memories=True, | ||
create_session_summary=True, | ||
), | ||
# Store agent sessions in a database | ||
storage=PostgresAgentStorage( | ||
table_name="personalized_agent_sessions", db_url=db_url | ||
), | ||
# Show debug logs so, you can see the memory being created | ||
# debug_mode=True, | ||
) | ||
|
||
# -*- Share personal information | ||
agent.print_response("My name is john billings?", stream=True) | ||
|
||
# -*- Share personal information | ||
agent.print_response("I live in nyc?", stream=True) | ||
|
||
# -*- Share personal information | ||
agent.print_response("I'm going to a concert tomorrow?", stream=True) | ||
|
||
# Ask about the conversation | ||
agent.print_response( | ||
"What have we been talking about, do you know my name?", stream=True | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
This recipe shows how to use personalized memories and summaries in an agent. | ||
Steps: | ||
1. Run: `./cookbook/scripts/run_pgvector.sh` to start a postgres container with pgvector | ||
2. Run: `pip install cohere sqlalchemy 'psycopg[binary]' pgvector` to install the dependencies | ||
3. Run: `python cookbook/models/cohere/memory.py` to run the agent | ||
""" | ||
|
||
from agno.agent import Agent, AgentMemory | ||
from agno.memory.db.postgres import PgMemoryDb | ||
from agno.models.cohere import Cohere | ||
from agno.storage.agent.postgres import PostgresAgentStorage | ||
|
||
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai" | ||
agent = Agent( | ||
model=Cohere(id="command-r-08-2024"), | ||
# Store the memories and summary in a database | ||
memory=AgentMemory( | ||
db=PgMemoryDb(table_name="agent_memory", db_url=db_url), | ||
create_user_memories=True, | ||
create_session_summary=True, | ||
), | ||
# Store agent sessions in a database | ||
storage=PostgresAgentStorage( | ||
table_name="personalized_agent_sessions", db_url=db_url | ||
), | ||
# Show debug logs so, you can see the memory being created | ||
# debug_mode=True, | ||
) | ||
|
||
# -*- Share personal information | ||
agent.print_response("My name is john billings?", stream=True) | ||
|
||
# -*- Share personal information | ||
agent.print_response("I live in nyc?", stream=True) | ||
|
||
# -*- Share personal information | ||
agent.print_response("I'm going to a concert tomorrow?", stream=True) | ||
|
||
# Ask about the conversation | ||
agent.print_response( | ||
"What have we been talking about, do you know my name?", stream=True | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
This recipe shows how to use personalized memories and summaries in an agent. | ||
Steps: | ||
1. Run: `./cookbook/scripts/run_pgvector.sh` to start a postgres container with pgvector | ||
2. Run: `pip install mistralai sqlalchemy 'psycopg[binary]' pgvector` to install the dependencies | ||
3. Run: `python cookbook/models/mistral/memory.py` to run the agent | ||
""" | ||
|
||
from agno.agent import Agent, AgentMemory | ||
from agno.memory.db.postgres import PgMemoryDb | ||
from agno.models.mistral.mistral import MistralChat | ||
from agno.storage.agent.postgres import PostgresAgentStorage | ||
|
||
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai" | ||
agent = Agent( | ||
model=MistralChat(id="mistral-large-latest"), | ||
# Store the memories and summary in a database | ||
memory=AgentMemory( | ||
db=PgMemoryDb(table_name="agent_memory", db_url=db_url), | ||
create_user_memories=True, | ||
create_session_summary=True, | ||
), | ||
# Store agent sessions in a database | ||
storage=PostgresAgentStorage( | ||
table_name="personalized_agent_sessions", db_url=db_url | ||
), | ||
# Show debug logs so, you can see the memory being created | ||
# debug_mode=True, | ||
) | ||
|
||
# -*- Share personal information | ||
agent.print_response("My name is john billings?", stream=True) | ||
|
||
# -*- Share personal information | ||
agent.print_response("I live in nyc?", stream=True) | ||
|
||
# -*- Share personal information | ||
agent.print_response("I'm going to a concert tomorrow?", stream=True) | ||
|
||
# Ask about the conversation | ||
agent.print_response( | ||
"What have we been talking about, do you know my name?", stream=True | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
This recipe shows how to use personalized memories and summaries in an agent. | ||
Steps: | ||
1. Run: `./cookbook/scripts/run_pgvector.sh` to start a postgres container with pgvector | ||
2. Run: `pip install ollama sqlalchemy 'psycopg[binary]' pgvector` to install the dependencies | ||
3. Run: `python cookbook/models/ollama/memory.py` to run the agent | ||
""" | ||
|
||
from agno.agent import Agent, AgentMemory | ||
from agno.memory.db.postgres import PgMemoryDb | ||
from agno.models.ollama.chat import Ollama | ||
from agno.storage.agent.postgres import PostgresAgentStorage | ||
|
||
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai" | ||
agent = Agent( | ||
model=Ollama(id="qwen2.5:latest"), | ||
# Store the memories and summary in a database | ||
memory=AgentMemory( | ||
db=PgMemoryDb(table_name="agent_memory", db_url=db_url), | ||
create_user_memories=True, | ||
create_session_summary=True, | ||
), | ||
# Store agent sessions in a database | ||
storage=PostgresAgentStorage( | ||
table_name="personalized_agent_sessions", db_url=db_url | ||
), | ||
# Show debug logs so, you can see the memory being created | ||
# debug_mode=True, | ||
) | ||
|
||
# -*- Share personal information | ||
agent.print_response("My name is john billings?", stream=True) | ||
|
||
# -*- Share personal information | ||
agent.print_response("I live in nyc?", stream=True) | ||
|
||
# -*- Share personal information | ||
agent.print_response("I'm going to a concert tomorrow?", stream=True) | ||
|
||
# Ask about the conversation | ||
agent.print_response( | ||
"What have we been talking about, do you know my name?", stream=True | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters