Skip to content

Commit 3fa00ca

Browse files
Ayush0054dirkbrnd
andauthored
Enhance documentation for various agents in OpenAI and Gemini models (#197)
- Added new examples for image, audio, and PDF input agents in the Anthropic and Gemini sections. - Introduced structured output and tool usage examples for OpenAI responses. - Updated existing examples to reflect new functionalities and improved usage instructions. - Included detailed usage steps for running agents with various input types and tools. --------- Co-authored-by: Dirk Brand <[email protected]>
1 parent a2959cd commit 3fa00ca

36 files changed

+1415
-121
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Image Input Bytes Content
3+
---
4+
5+
## Code
6+
7+
```python cookbook/models/anthropic/image_input_bytes.py
8+
from pathlib import Path
9+
from agno.agent import Agent
10+
from agno.media import Image
11+
from agno.models.anthropic.claude import Claude
12+
from agno.tools.duckduckgo import DuckDuckGoTools
13+
from agno.utils.media import download_image
14+
15+
agent = Agent(
16+
model=Claude(id="claude-3-5-sonnet-20241022"),
17+
tools=[DuckDuckGoTools()],
18+
markdown=True,
19+
)
20+
21+
image_path = Path(__file__).parent.joinpath("sample.jpg")
22+
23+
download_image(
24+
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
25+
output_path=str(image_path),
26+
)
27+
28+
# Read the image file content as bytes
29+
image_bytes = image_path.read_bytes()
30+
31+
agent.print_response(
32+
"Tell me about this image and give me the latest news about it.",
33+
images=[
34+
Image(content=image_bytes),
35+
],
36+
stream=True,
37+
)
38+
```
39+
40+
## Usage
41+
42+
<Steps>
43+
<Snippet file="create-venv-step.mdx" />
44+
45+
<Step title="Set your API key">
46+
```bash
47+
export ANTHROPIC_API_KEY=xxx
48+
```
49+
</Step>
50+
51+
<Step title="Install libraries">
52+
```bash
53+
pip install -U anthropic agno duckduckgo-search
54+
```
55+
</Step>
56+
57+
<Step title="Run Agent">
58+
<CodeGroup>
59+
```bash Mac
60+
python cookbook/models/anthropic/image_input_bytes.py
61+
```
62+
63+
```bash Windows
64+
python cookbook/models/anthropic/image_input_bytes.py
65+
```
66+
</CodeGroup>
67+
</Step>
68+
</Steps>

examples/models/anthropic/image_agent.mdx renamed to examples/models/anthropic/image_input_url.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: Image Agent
2+
title: Image Input URL
33
---
44

55
## Code
66

7-
```python cookbook/models/anthropic/image_agent.py
7+
```python cookbook/models/anthropic/image_input_url.py
88
from agno.agent import Agent
99
from agno.media import Image
1010
from agno.models.anthropic import Claude
@@ -40,18 +40,18 @@ agent.print_response(
4040

4141
<Step title="Install libraries">
4242
```bash
43-
pip install -U anthropic duckduckgo-search agno
43+
pip install -U anthropic agno duckduckgo-search
4444
```
4545
</Step>
4646

4747
<Step title="Run Agent">
4848
<CodeGroup>
4949
```bash Mac
50-
python cookbook/models/anthropic/image_agent.py
50+
python cookbook/models/anthropic/image_input_url.py
5151
```
5252

5353
```bash Windows
54-
python cookbook/models/anthropic/image_agent.py
54+
python cookbook/models/anthropic/image_input_url.py
5555
```
5656
</CodeGroup>
5757
</Step>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: PDF Input Bytes Agent
3+
---
4+
5+
## Code
6+
7+
```python cookbook/models/anthropic/pdf_input_bytes.py
8+
from pathlib import Path
9+
from agno.agent import Agent
10+
from agno.media import File
11+
from agno.models.anthropic import Claude
12+
from agno.utils.media import download_file
13+
14+
pdf_path = Path(__file__).parent.joinpath("ThaiRecipes.pdf")
15+
16+
# Download the file using the download_file function
17+
download_file(
18+
"https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf", str(pdf_path)
19+
)
20+
21+
agent = Agent(
22+
model=Claude(id="claude-3-5-sonnet-20241022"),
23+
markdown=True,
24+
)
25+
26+
agent.print_response(
27+
"Summarize the contents of the attached file.",
28+
files=[
29+
File(
30+
content=pdf_path.read_bytes(),
31+
),
32+
],
33+
)
34+
35+
print("Citations:")
36+
print(agent.run_response.citations)
37+
```
38+
39+
## Usage
40+
41+
<Steps>
42+
<Snippet file="create-venv-step.mdx" />
43+
44+
<Step title="Set your API key">
45+
```bash
46+
export ANTHROPIC_API_KEY=xxx
47+
```
48+
</Step>
49+
50+
<Step title="Install libraries">
51+
```bash
52+
pip install -U anthropic agno
53+
```
54+
</Step>
55+
56+
<Step title="Run Agent">
57+
<CodeGroup>
58+
```bash Mac
59+
python cookbook/models/anthropic/pdf_input_bytes.py
60+
```
61+
62+
```bash Windows
63+
python cookbook/models/anthropic/pdf_input_bytes.py
64+
```
65+
</CodeGroup>
66+
</Step>
67+
</Steps>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: PDF Input Local Agent
3+
---
4+
5+
## Code
6+
7+
```python cookbook/models/anthropic/pdf_input_local.py
8+
from pathlib import Path
9+
from agno.agent import Agent
10+
from agno.media import File
11+
from agno.models.anthropic import Claude
12+
from agno.utils.media import download_file
13+
14+
pdf_path = Path(__file__).parent.joinpath("ThaiRecipes.pdf")
15+
16+
# Download the file using the download_file function
17+
download_file(
18+
"https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf", str(pdf_path)
19+
)
20+
21+
agent = Agent(
22+
model=Claude(id="claude-3-5-sonnet-20241022"),
23+
markdown=True,
24+
)
25+
26+
agent.print_response(
27+
"Summarize the contents of the attached file.",
28+
files=[
29+
File(
30+
filepath=pdf_path,
31+
),
32+
],
33+
)
34+
35+
print("Citations:")
36+
print(agent.run_response.citations)
37+
```
38+
39+
## Usage
40+
41+
<Steps>
42+
<Snippet file="create-venv-step.mdx" />
43+
44+
<Step title="Set your API key">
45+
```bash
46+
export ANTHROPIC_API_KEY=xxx
47+
```
48+
</Step>
49+
50+
<Step title="Install libraries">
51+
```bash
52+
pip install -U anthropic agno
53+
```
54+
</Step>
55+
56+
<Step title="Run Agent">
57+
<CodeGroup>
58+
```bash Mac
59+
python cookbook/models/anthropic/pdf_input_local.py
60+
```
61+
62+
```bash Windows
63+
python cookbook/models/anthropic/pdf_input_local.py
64+
```
65+
</CodeGroup>
66+
</Step>
67+
</Steps>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: PDF Input URL Agent
3+
---
4+
5+
## Code
6+
7+
```python cookbook/models/anthropic/pdf_input_url.py
8+
from agno.agent import Agent
9+
from agno.media import File
10+
from agno.models.anthropic import Claude
11+
12+
agent = Agent(
13+
model=Claude(id="claude-3-5-sonnet-20241022"),
14+
markdown=True,
15+
)
16+
17+
agent.print_response(
18+
"Summarize the contents of the attached file.",
19+
files=[
20+
File(url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"),
21+
],
22+
stream=True,
23+
)
24+
```
25+
26+
## Usage
27+
28+
<Steps>
29+
<Snippet file="create-venv-step.mdx" />
30+
31+
<Step title="Set your API key">
32+
```bash
33+
export ANTHROPIC_API_KEY=xxx
34+
```
35+
</Step>
36+
37+
<Step title="Install libraries">
38+
```bash
39+
pip install -U anthropic agno
40+
```
41+
</Step>
42+
43+
<Step title="Run Agent">
44+
<CodeGroup>
45+
```bash Mac
46+
python cookbook/models/anthropic/pdf_input_url.py
47+
```
48+
49+
```bash Windows
50+
python cookbook/models/anthropic/pdf_input_url.py
51+
```
52+
</CodeGroup>
53+
</Step>
54+
</Steps>

examples/models/gemini/audio_input.mdx renamed to examples/models/gemini/audio_input_bytes_content.mdx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
---
2-
title: Audio Agent
2+
title: Audio Input (Bytes Content)
33
---
44

55
## Code
66

7-
```python cookbook/models/google/gemini/audio_input.py
8-
from pathlib import Path
9-
7+
```python cookbook/models/google/gemini/audio_input_bytes_content.py
108
import requests
119
from agno.agent import Agent
1210
from agno.media import Audio
@@ -26,7 +24,6 @@ audio_content = response.content
2624
agent.print_response(
2725
"Tell me about this audio",
2826
audio=[Audio(content=audio_content)],
29-
stream=True,
3027
)
3128
```
3229

@@ -50,12 +47,12 @@ agent.print_response(
5047
<Step title="Run Agent">
5148
<CodeGroup>
5249
```bash Mac
53-
python cookbook/models/google/gemini/audio_input.py
50+
python cookbook/models/google/gemini/audio_input_bytes_content.py
5451
```
5552

5653
```bash Windows
57-
python cookbook/models/google/gemini/audio_input.py
54+
python cookbook/models/google/gemini/audio_input_bytes_content.py
5855
```
5956
</CodeGroup>
6057
</Step>
61-
</Steps>
58+
</Steps>

0 commit comments

Comments
 (0)