Skip to content

Commit

Permalink
Merge branch 'main' into blog-to-podcast
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragts committed Feb 12, 2025
2 parents b939308 + 200b7e3 commit ffc0380
Show file tree
Hide file tree
Showing 184 changed files with 5,793 additions and 7,659 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# Machine specific
.idea
.vscode
*.code-workspace

# Ignore .env files
.env
Expand Down
15 changes: 0 additions & 15 deletions agno.code-workspace

This file was deleted.

2 changes: 1 addition & 1 deletion cookbook/agent_concepts/async/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
markdown=True,
)
# -*- Print a response to the cli
asyncio.run(agent.aprint_response("Share a breakfast recipe.", stream=True))
asyncio.run(agent.aprint_response("Share a breakfast recipe."))
13 changes: 13 additions & 0 deletions cookbook/agent_concepts/async/basic_stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import asyncio

from agno.agent import Agent
from agno.models.openai import OpenAIChat

agent = Agent(
model=OpenAIChat(id="gpt-4o"),
description="You help people with their health and fitness goals.",
instructions=["Recipes should be under 5 ingredients"],
markdown=True,
)
# -*- Print a response to the cli
asyncio.run(agent.aprint_response("Share a breakfast recipe.", stream=True))
4 changes: 1 addition & 3 deletions cookbook/agent_concepts/async/data_analyst.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@
- movies: contains information about movies from IMDB.
"""),
)
asyncio.run(
agent.aprint_response("What is the average rating of movies?", stream=False)
)
asyncio.run(agent.aprint_response("What is the average rating of movies?"))
3 changes: 3 additions & 0 deletions cookbook/agent_concepts/other/agent_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@
# Print the metrics
print("---" * 5, "Aggregated Metrics", "---" * 5)
pprint(agent.run_response.metrics)
# Print the session metrics
print("---" * 5, "Session Metrics", "---" * 5)
pprint(agent.session_metrics)
2 changes: 1 addition & 1 deletion cookbook/examples/apps/agentic_rag/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import streamlit as st
from agentic_rag import get_agentic_rag_agent
from agno.agent.agent import Agent
from agno.agent import Agent
from agno.utils.log import logger


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import asyncio

from agno.agent.agent import Agent
from agno.agent import Agent
from agno.models.anthropic import Claude

agent = Agent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import asyncio

from agno.agent.agent import Agent
from agno.agent import Agent
from agno.models.anthropic import Claude

agent = Agent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import asyncio

from agno.agent.agent import Agent
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.duckduckgo import DuckDuckGoTools

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/anthropic/tool_use.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("Whats happening in France?")
13 changes: 13 additions & 0 deletions cookbook/models/anthropic/tool_use_stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Run `pip install duckduckgo-search` to install dependencies."""

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
model=Claude(id="claude-3-5-sonnet-20240620"),
tools=[DuckDuckGoTools()],
show_tool_calls=True,
markdown=True,
)
agent.print_response("Whats happening in France?", stream=True)
6 changes: 6 additions & 0 deletions cookbook/models/aws/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.jpg
*.png
*.mp3
*.wav
*.mp4
*.mp3
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,51 @@ source ~/.venvs/aienv/bin/activate
```shell
export AWS_ACCESS_KEY_ID=***
export AWS_SECRET_ACCESS_KEY=***
export AWS_DEFAULT_REGION=***
export AWS_REGION=***
```

### 3. Install libraries

```shell
pip install -U boto3 duckduckgo-search duckdb yfinance agno
pip install -U boto3 duckduckgo-search agno
```

### 4. Run basic agent

- Streaming on

```shell
python cookbook/models/aws/bedrock_claude/basic_stream.py
python cookbook/models/aws/bedrock/basic_stream.py
```

- Streaming off

```shell
python cookbook/models/aws/bedrock_claude/basic.py
python cookbook/models/aws/bedrock/basic.py
```

### 5. Run Agent with Tools

- DuckDuckGo Search

```shell
python cookbook/models/aws/bedrock_claude/tool_use.py
python cookbook/models/aws/bedrock/tool_use.py
```

### 6. Run Agent that returns structured output

```shell
python cookbook/models/aws/bedrock_claude/structured_output.py
python cookbook/models/aws/bedrock/structured_output.py
```

### 7. Run Agent that uses storage

```shell
python cookbook/models/aws/bedrock_claude/storage.py
python cookbook/models/aws/bedrock/storage.py
```

### 8. Run Agent that uses knowledge

```shell
python cookbook/models/aws/bedrock_claude/knowledge.py
python cookbook/models/aws/bedrock/knowledge.py
```
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from agno.agent import Agent, RunResponse # noqa
from agno.models.google import GeminiOpenAI
from agno.models.aws import AwsBedrock

agent = Agent(model=GeminiOpenAI(id="gemini-2.0-flash-exp"), markdown=True)
agent = Agent(model=AwsBedrock(id="mistral.mistral-small-2402-v1:0"), markdown=True)

# Get the response in a variable
# run: RunResponse = agent.run("Share a 2 sentence horror story")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Iterator # noqa
from agno.agent import Agent, RunResponse # noqa
from agno.models.ollama import OllamaHermes
from agno.models.aws import AwsBedrock

agent = Agent(model=OllamaHermes(id="hermes3"), markdown=True)
agent = Agent(model=AwsBedrock(id="mistral.mistral-small-2402-v1:0"), markdown=True)

# Get the response in a variable
# run_response: Iterator[RunResponse] = agent.run("Share a 2 sentence horror story", stream=True)
Expand Down
25 changes: 25 additions & 0 deletions cookbook/models/aws/bedrock/image_agent_bytes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from pathlib import Path

from agno.agent import Agent
from agno.media import Image
from agno.models.aws import AwsBedrock
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
model=AwsBedrock(id="amazon.nova-pro-v1:0"),
tools=[DuckDuckGoTools()],
markdown=True,
)

image_path = Path(__file__).parent.joinpath("sample.jpg")

# Read the image file content as bytes
with open(image_path, "rb") as img_file:
image_bytes = img_file.read()

agent.print_response(
"Tell me about this image and give me the latest news about it.",
images=[
Image(content=image_bytes, format="jpeg"),
],
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List

from agno.agent import Agent, RunResponse # noqa
from agno.models.vertexai import Gemini
from agno.models.aws import AwsBedrock
from pydantic import BaseModel, Field
from rich.pretty import pprint # noqa

Expand All @@ -26,13 +26,13 @@ class MovieScript(BaseModel):


movie_agent = Agent(
model=Gemini(id="gemini-2.0-flash-exp"),
model=AwsBedrock(id="mistral.mistral-large-2402-v1:0"),
description="You help people write movie scripts.",
response_model=MovieScript,
)

# Get the response in a variable
# run: RunResponse = movie_agent.run("New York")
# pprint(run.content)
# movie_agent: RunResponse = movie_agent.run("New York")
# pprint(movie_agent.content)

movie_agent.print_response("New York")
14 changes: 14 additions & 0 deletions cookbook/models/aws/bedrock/tool_use.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Run `pip install duckduckgo-search` to install dependencies."""

from agno.agent import Agent
from agno.models.aws import AwsBedrock
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
model=AwsBedrock(id="mistral.mistral-large-2402-v1:0"),
tools=[DuckDuckGoTools()],
instructions="You are a helpful assistant that can use the following tools to answer questions.",
show_tool_calls=True,
markdown=True,
)
agent.print_response("Whats happening in France?")
14 changes: 14 additions & 0 deletions cookbook/models/aws/bedrock/tool_use_stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Run `pip install duckduckgo-search` to install dependencies."""

from agno.agent import Agent
from agno.models.aws import AwsBedrock
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
model=AwsBedrock(id="amazon.nova-lite-v1:0"),
tools=[DuckDuckGoTools()],
instructions="You are a helpful assistant that can use the following tools to answer questions.",
show_tool_calls=True,
markdown=True,
)
agent.print_response("Whats happening in France?", stream=True)
66 changes: 66 additions & 0 deletions cookbook/models/aws/claude/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# AWS Bedrock Anthropic Claude

[Models overview](https://docs.anthropic.com/claude/docs/models-overview)

> Note: Fork and clone this repository if needed
### 1. Create and activate a virtual environment

```shell
python3 -m venv ~/.venvs/aienv
source ~/.venvs/aienv/bin/activate
```

### 2. Export your AWS Credentials

```shell
export AWS_ACCESS_KEY_ID=***
export AWS_SECRET_ACCESS_KEY=***
export AWS_REGION=***
```

### 3. Install libraries

```shell
pip install -U boto3 duckduckgo-search agno
```

### 4. Run basic agent

- Streaming on

```shell
python cookbook/models/aws/claude/basic_stream.py
```

- Streaming off

```shell
python cookbook/models/aws/claude/basic.py
```

### 5. Run Agent with Tools

- DuckDuckGo Search

```shell
python cookbook/models/aws/claude/tool_use.py
```

### 6. Run Agent that returns structured output

```shell
python cookbook/models/aws/claude/structured_output.py
```

### 7. Run Agent that uses storage

```shell
python cookbook/models/aws/claude/storage.py
```

### 8. Run Agent that uses knowledge

```shell
python cookbook/models/aws/claude/knowledge.py
```
File renamed without changes.
15 changes: 15 additions & 0 deletions cookbook/models/aws/claude/async_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import asyncio

from agno.agent import Agent, RunResponse # noqa
from agno.models.aws import Claude

agent = Agent(
model=Claude(id="anthropic.claude-3-5-sonnet-20240620-v1:0"), markdown=True
)

# Get the response in a variable
# run: RunResponse = agent.run("Share a 2 sentence horror story")
# print(run.content)

# Print the response in the terminal
asyncio.run(agent.aprint_response("Share a 2 sentence horror story"))
17 changes: 17 additions & 0 deletions cookbook/models/aws/claude/async_basic_stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import asyncio
from typing import Iterator # noqa

from agno.agent import Agent, RunResponse # noqa
from agno.models.aws import Claude

agent = Agent(
model=Claude(id="anthropic.claude-3-5-sonnet-20240620-v1:0"), markdown=True
)

# Get the response in a variable
# run_response: Iterator[RunResponse] = agent.run("Share a 2 sentence horror story", stream=True)
# for chunk in run_response:
# print(chunk.content)

# Print the response in the terminal
asyncio.run(agent.aprint_response("Share a 2 sentence horror story", stream=True))
Loading

0 comments on commit ffc0380

Please sign in to comment.