Skip to content

Commit 026d847

Browse files
authored
Merge branch 'main' into feat/model-litellm
2 parents 3371c7e + b7f1f49 commit 026d847

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2056
-220
lines changed

cookbook/examples/apps/mcp_agent/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ UAgI (Universal Agent Interface) is a powerful agent application that leverages
3030
- Only works with 1 MCP server at a time
3131
- Changing MCP servers resets the agent
3232
- Only supports 2 MCP servers at the moment
33+
- Chat history is broken
34+
- MCP Cleanup is not working, so memory leaks are possible
3335

3436
## 🚀 Quick Start
3537

File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from pathlib import Path
2+
3+
from agno.agent import Agent
4+
from agno.media import File
5+
from agno.models.anthropic import Claude
6+
from agno.utils.media import download_file
7+
8+
pdf_path = Path(__file__).parent.joinpath("ThaiRecipes.pdf")
9+
10+
# Download the file using the download_file function
11+
download_file(
12+
"https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf", str(pdf_path)
13+
)
14+
15+
agent = Agent(
16+
model=Claude(id="claude-3-5-sonnet-20241022"),
17+
markdown=True,
18+
)
19+
20+
agent.print_response(
21+
"Summarize the contents of the attached file.",
22+
files=[
23+
File(
24+
filepath=pdf_path,
25+
),
26+
],
27+
stream=True,
28+
)
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from agno.agent import Agent
2+
from agno.media import File
3+
from agno.models.anthropic import Claude
4+
5+
agent = Agent(
6+
model=Claude(id="claude-3-5-sonnet-20241022"),
7+
markdown=True,
8+
)
9+
10+
agent.print_response(
11+
"Summarize the contents of the attached file.",
12+
files=[
13+
File(url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"),
14+
],
15+
stream=True,
16+
)

cookbook/models/aws/bedrock/image_agent_bytes.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from agno.media import Image
55
from agno.models.aws import AwsBedrock
66
from agno.tools.duckduckgo import DuckDuckGoTools
7+
from agno.utils.media import download_image
78

89
agent = Agent(
910
model=AwsBedrock(id="amazon.nova-pro-v1:0"),
@@ -13,9 +14,13 @@
1314

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

17+
download_image(
18+
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
19+
output_path=str(image_path),
20+
)
21+
1622
# Read the image file content as bytes
17-
with open(image_path, "rb") as img_file:
18-
image_bytes = img_file.read()
23+
image_bytes = image_path.read_bytes()
1924

2025
agent.print_response(
2126
"Tell me about this image and give me the latest news about it.",

cookbook/models/azure/ai_foundry/image_agent_bytes.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from agno.agent import Agent
44
from agno.media import Image
55
from agno.models.azure import AzureAIFoundry
6+
from agno.utils.media import download_image
67

78
agent = Agent(
89
model=AzureAIFoundry(id="Llama-3.2-11B-Vision-Instruct"),
@@ -11,9 +12,13 @@
1112

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

15+
download_image(
16+
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
17+
output_path=str(image_path),
18+
)
19+
1420
# Read the image file content as bytes
15-
with open(image_path, "rb") as img_file:
16-
image_bytes = img_file.read()
21+
image_bytes = image_path.read_bytes()
1722

1823
agent.print_response(
1924
"Tell me about this image.",

cookbook/models/cohere/image_agent.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from agno.agent import Agent
2+
from agno.media import Image
3+
from agno.models.cohere import Cohere
4+
5+
agent = Agent(
6+
model=Cohere(id="c4ai-aya-vision-8b"),
7+
markdown=True,
8+
)
9+
10+
agent.print_response(
11+
"Tell me about this image.",
12+
images=[
13+
Image(
14+
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg"
15+
)
16+
],
17+
stream=True,
18+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from pathlib import Path
2+
3+
from agno.agent import Agent
4+
from agno.media import Image
5+
from agno.models.cohere.chat import Cohere
6+
from agno.utils.media import download_image
7+
8+
agent = Agent(
9+
model=Cohere(id="c4ai-aya-vision-8b"),
10+
markdown=True,
11+
)
12+
13+
image_path = Path(__file__).parent.joinpath("sample.jpg")
14+
15+
download_image(
16+
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
17+
output_path=str(image_path),
18+
)
19+
20+
# Read the image file content as bytes
21+
image_bytes = image_path.read_bytes()
22+
23+
agent.print_response(
24+
"Tell me about this image.",
25+
images=[
26+
Image(content=image_bytes),
27+
],
28+
stream=True,
29+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from pathlib import Path
2+
3+
from agno.agent import Agent
4+
from agno.media import Image
5+
from agno.models.cohere.chat import Cohere
6+
from agno.utils.media import download_image
7+
8+
agent = Agent(
9+
model=Cohere(id="c4ai-aya-vision-8b"),
10+
markdown=True,
11+
)
12+
13+
image_path = Path(__file__).parent.joinpath("sample.jpg")
14+
15+
download_image(
16+
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
17+
output_path=str(image_path),
18+
)
19+
20+
agent.print_response(
21+
"Tell me about this image.",
22+
images=[
23+
Image(filepath=image_path),
24+
],
25+
stream=True,
26+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pathlib import Path
2+
3+
from agno.agent import Agent
4+
from agno.media import File
5+
from agno.models.google import Gemini
6+
from agno.utils.media import download_file
7+
8+
pdf_path = Path(__file__).parent.joinpath("ThaiRecipes.pdf")
9+
10+
# Download the file using the download_file function
11+
download_file(
12+
"https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf", str(pdf_path)
13+
)
14+
15+
agent = Agent(
16+
model=Gemini(id="gemini-2.0-flash-exp"),
17+
markdown=True,
18+
add_history_to_messages=True,
19+
)
20+
21+
agent.print_response(
22+
"Summarize the contents of the attached file.",
23+
files=[File(filepath=pdf_path)],
24+
)
25+
agent.print_response("Suggest me a recipe from the attached file.")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from agno.agent import Agent
2+
from agno.media import File
3+
from agno.models.google import Gemini
4+
5+
agent = Agent(
6+
model=Gemini(id="gemini-2.0-flash-exp"),
7+
markdown=True,
8+
)
9+
10+
agent.print_response(
11+
"Summarize the contents of the attached file.",
12+
files=[File(url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf")],
13+
)

cookbook/models/ibm/watsonx/image_agent_bytes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from agno.agent import Agent
44
from agno.media import Image
55
from agno.models.ibm import WatsonX
6-
from agno.tools.duckduckgo import DuckDuckGoTools
76

87
agent = Agent(
98
model=WatsonX(id="meta-llama/llama-3-2-11b-vision-instruct"),
@@ -13,8 +12,7 @@
1312
image_path = Path(__file__).parent.joinpath("sample.jpg")
1413

1514
# Read the image file content as bytes
16-
with open(image_path, "rb") as img_file:
17-
image_bytes = img_file.read()
15+
image_bytes = image_path.read_bytes()
1816

1917
agent.print_response(
2018
"Tell me about this image and and give me the latest news about it.",

cookbook/models/openai/image_agent_bytes.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from agno.media import Image
55
from agno.models.openai import OpenAIChat
66
from agno.tools.duckduckgo import DuckDuckGoTools
7+
from agno.utils.media import download_image
78

89
agent = Agent(
910
model=OpenAIChat(id="gpt-4o"),
@@ -13,9 +14,13 @@
1314

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

17+
download_image(
18+
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
19+
output_path=str(image_path),
20+
)
21+
1622
# Read the image file content as bytes
17-
with open(image_path, "rb") as img_file:
18-
image_bytes = img_file.read()
23+
image_bytes = image_path.read_bytes()
1924

2025
agent.print_response(
2126
"Tell me about this image and give me the latest news about it.",

cookbook/models/together/image_agent_bytes.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
image_path = Path(__file__).parent.joinpath("sample.jpg")
1313

1414
# Read the image file content as bytes
15-
with open(image_path, "rb") as img_file:
16-
image_bytes = img_file.read()
15+
image_bytes = image_path.read_bytes()
1716

1817
agent.print_response(
1918
"Tell me about this image",

cookbook/models/xai/image_agent_bytes.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from agno.media import Image
55
from agno.models.xai import xAI
66
from agno.tools.duckduckgo import DuckDuckGoTools
7+
from agno.utils.media import download_image
78

89
agent = Agent(
910
model=xAI(id="grok-2-vision-latest"),
@@ -13,9 +14,13 @@
1314

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

17+
download_image(
18+
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
19+
output_path=str(image_path),
20+
)
21+
1622
# Read the image file content as bytes
17-
with open(image_path, "rb") as img_file:
18-
image_bytes = img_file.read()
23+
image_bytes = image_path.read_bytes()
1924

2025
agent.print_response(
2126
"Tell me about this image and give me the latest news about it.",

cookbook/tools/agentql_tools.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
AgentQL Tools for scraping websites.
3+
4+
Prerequisites:
5+
- Set the environment variable `AGENTQL_API_KEY` with your AgentQL API key.
6+
You can obtain the API key from the AgentQL website:
7+
https://agentql.com/
8+
- Run `playwright install` to install a browser extension for playwright.
9+
10+
AgentQL will open up a browser instance (don't close it) and do scraping on the site.
11+
"""
12+
13+
from agno.agent import Agent
14+
from agno.models.openai import OpenAIChat
15+
from agno.tools.agentql import AgentQLTools
16+
17+
# Create agent with default AgentQL tool
18+
agent = Agent(
19+
model=OpenAIChat(id="gpt-4o"), tools=[AgentQLTools()], show_tool_calls=True
20+
)
21+
agent.print_response("https://docs.agno.com/introduction", markdown=True)
22+
23+
# Define custom AgentQL query for specific data extraction (see https://docs.agentql.com/concepts/query-language)
24+
custom_query = """
25+
{
26+
title
27+
text_content[]
28+
}
29+
"""
30+
31+
# Create AgentQL tool with custom query
32+
custom_scraper = AgentQLTools(agentql_query=custom_query, custom_scrape=True)
33+
34+
# Create agent with custom AgentQL tool
35+
custom_agent = Agent(
36+
model=OpenAIChat(id="gpt-4o"), tools=[custom_scraper], show_tool_calls=True
37+
)
38+
custom_agent.print_response("https://docs.agno.com/introduction", markdown=True)

cookbook/tools/browserbase_tools.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from os import getenv
2+
3+
from agno.agent import Agent
4+
from agno.tools.browserbase import BrowserbaseTools
5+
6+
# Browserbase Configuration
7+
# -------------------------------
8+
# These environment variables are required for the BrowserbaseTools to function properly.
9+
# You can set them in your .env file or export them directly in your terminal.
10+
11+
# BROWSERBASE_API_KEY: Your API key from Browserbase dashboard
12+
# - Required for authentication
13+
# - Format: Starts with "bb_live_" or "bb_test_" followed by a unique string
14+
15+
# BROWSERBASE_PROJECT_ID: The project ID from your Browserbase dashboard
16+
# - Required to identify which project to use for browser sessions
17+
# - Format: UUID string (8-4-4-4-12 format)
18+
19+
# BROWSERBASE_BASE_URL: The Browserbase API endpoint
20+
# - Optional: Defaults to https://api.browserbase.com if not specified
21+
# - Only change this if you're using a custom API endpoint or proxy
22+
23+
agent = Agent(
24+
name="Web Automation Assistant",
25+
tools=[BrowserbaseTools()],
26+
instructions=[
27+
"You are a web automation assistant that can help with:",
28+
"1. Capturing screenshots of websites",
29+
"2. Extracting content from web pages",
30+
"3. Monitoring website changes",
31+
"4. Taking visual snapshots of responsive layouts",
32+
"5. Automated web testing and verification",
33+
],
34+
show_tool_calls=True,
35+
markdown=True,
36+
debug_mode=True,
37+
)
38+
39+
# Content Extraction and SS
40+
# agent.print_response("""
41+
# Go to https://news.ycombinator.com and extract:
42+
# 1. The page title
43+
# 2. Take a screenshot of the top stories section
44+
# """)
45+
46+
agent.print_response("""
47+
Visit https://quotes.toscrape.com and:
48+
1. Extract the first 5 quotes and their authors
49+
2. Navigate to page 2
50+
3. Extract the first 5 quotes from page 2
51+
""")

0 commit comments

Comments
 (0)