Skip to content

Commit

Permalink
Merge branch 'main' into update-exa-phi-2406
Browse files Browse the repository at this point in the history
  • Loading branch information
ysolanky authored Jan 31, 2025
2 parents 64494bb + aaf7be3 commit 3ef2f2e
Show file tree
Hide file tree
Showing 31 changed files with 343 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from agno.embedder.azure_openai import AzureOpenAIEmbedder
from agno.vectordb.pgvector import PgVector

embeddings = AzureOpenAIEmbedder().get_embedding(
embeddings = AzureOpenAIEmbedder(id="text-embedding-3-small").get_embedding(
"The quick brown fox jumps over the lazy dog."
)

Expand Down
1 change: 0 additions & 1 deletion cookbook/examples/agents/shopping_partner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.exa import ExaTools
from agno.tools.firecrawl import FirecrawlTools

agent = Agent(
name="shopping partner",
Expand Down
1 change: 1 addition & 0 deletions cookbook/examples/apps/agentic_rag/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
about_widget,
add_message,
display_tool_calls,

export_chat_history,
rename_session_widget,
session_selector_widget,
Expand Down
1 change: 0 additions & 1 deletion cookbook/examples/apps/agentic_rag/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def session_selector_widget(agent: Agent, model_id: str) -> None:
)
st.rerun()


def about_widget() -> None:
"""Display an about section in the sidebar"""
st.sidebar.markdown("---")
Expand Down
2 changes: 1 addition & 1 deletion cookbook/examples/apps/game_generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ source ~/.venvs/aienv/bin/activate
pip install -r cookbook/examples/apps/game_generator/requirements.txt
```

### 3. Export `OPENAI_API_KEY`
### 3. Export `OPENAI_API_KEY`

```shell
export OPENAI_API_KEY=sk-***
Expand Down
8 changes: 7 additions & 1 deletion cookbook/models/anthropic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ export OPENAI_API_KEY=***
python cookbook/models/anthropic/knowledge.py
```

### 9. Run Agent that analyzes an image
### 9. Run Agent that uses memory

```shell
python cookbook/models/anthropic/memory.py
```

### 10. Run Agent that analyzes an image

```shell
python cookbook/models/anthropic/image_agent.py
Expand Down
44 changes: 44 additions & 0 deletions cookbook/models/anthropic/memory.py
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
)
6 changes: 6 additions & 0 deletions cookbook/models/cohere/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ python cookbook/models/cohere/storage.py
```shell
python cookbook/models/cohere/knowledge.py
```

### 9. Run Agent that uses memory

```shell
python cookbook/models/cohere/memory.py
```
43 changes: 43 additions & 0 deletions cookbook/models/cohere/memory.py
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
)
6 changes: 6 additions & 0 deletions cookbook/models/mistral/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ python cookbook/models/mistral/tool_use.py
```shell
python cookbook/models/mistral/structured_output.py
```

### 7. Run Agent that uses memory

```shell
python cookbook/models/mistral/memory.py
```
8 changes: 1 addition & 7 deletions cookbook/models/mistral/basic.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import os

from agno.agent import Agent, RunResponse # noqa
from agno.models.mistral import MistralChat

mistral_api_key = os.getenv("MISTRAL_API_KEY")

agent = Agent(
model=MistralChat(
id="mistral-large-latest",
api_key=mistral_api_key,
),
model=MistralChat(id="mistral-large-latest"),
markdown=True,
)

Expand Down
43 changes: 43 additions & 0 deletions cookbook/models/mistral/memory.py
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
)
2 changes: 1 addition & 1 deletion cookbook/models/mistral/mistral_small.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
show_tool_calls=True,
markdown=True,
)
agent.print_response("Whats happening in France?", stream=True)
agent.print_response("Tell me about mistrall small, any news", stream=True)
13 changes: 9 additions & 4 deletions cookbook/models/ollama/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ python cookbook/models/ollama/storage.py
python cookbook/models/ollama/knowledge.py
```

### 9. Run Agent that interprets an image
### 9. Run Agent that uses memory

```shell
python cookbook/models/ollama/memory.py
```

### 10. Run Agent that interprets an image

Pull the llama3.2 vision model

Expand All @@ -75,14 +81,13 @@ ollama pull llama3.2-vision
python cookbook/models/ollama/image_agent.py
```

### 10. Run Agent that manually sets the Ollama client
### 11. Run Agent that manually sets the Ollama client

```shell
python cookbook/models/ollama/set_client.py
```


### 11. See demos of some well-known Ollama models
### 12. See demos of some well-known Ollama models

```shell
python cookbook/models/ollama/demo_deepseek_r1.py
Expand Down
43 changes: 43 additions & 0 deletions cookbook/models/ollama/memory.py
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
)
2 changes: 1 addition & 1 deletion cookbook/models/openai/memory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
This recipe shows how to use personalized memories and summaries in an agent.
Steps:
1. Run: `./cookbook/run_pgvector.sh` to start a postgres container with pgvector
1. Run: `./cookbook/scripts/run_pgvector.sh` to start a postgres container with pgvector
2. Run: `pip install openai sqlalchemy 'psycopg[binary]' pgvector` to install the dependencies
3. Run: `python cookbook/agents/personalized_memories_and_summaries.py` to run the agent
"""
Expand Down
46 changes: 0 additions & 46 deletions cookbook/tools/twitter_tools.py

This file was deleted.

Loading

0 comments on commit 3ef2f2e

Please sign in to comment.