Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document-upload-ag-2793 #2325

Merged
merged 9 commits into from
Mar 12, 2025
28 changes: 28 additions & 0 deletions cookbook/models/anthropic/pdf_input_local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from pathlib import Path

from agno.agent import Agent
from agno.media import File
from agno.models.anthropic import Claude
from agno.utils.media import download_file

pdf_path = Path(__file__).parent.joinpath("ThaiRecipes.pdf")

# Download the file using the download_file function
download_file(
"https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf", str(pdf_path)
)

agent = Agent(
model=Claude(id="claude-3-5-sonnet-20241022"),
markdown=True,
)

agent.print_response(
"Summarize the contents of the attached file.",
files=[
File(
filepath=pdf_path,
),
],
stream=True,
)
16 changes: 16 additions & 0 deletions cookbook/models/anthropic/pdf_input_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from agno.agent import Agent
from agno.media import File
from agno.models.anthropic import Claude

agent = Agent(
model=Claude(id="claude-3-5-sonnet-20241022"),
markdown=True,
)

agent.print_response(
"Summarize the contents of the attached file.",
files=[
File(url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"),
],
stream=True,
)
5 changes: 4 additions & 1 deletion cookbook/models/aws/bedrock/image_agent_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

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

download_image(url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg", save_path=str(image_path))
download_image(
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
output_path=str(image_path),
)

# Read the image file content as bytes
image_bytes = image_path.read_bytes()
Expand Down
5 changes: 4 additions & 1 deletion cookbook/models/azure/ai_foundry/image_agent_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

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

download_image(url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg", save_path=str(image_path))
download_image(
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
output_path=str(image_path),
)

# Read the image file content as bytes
image_bytes = image_path.read_bytes()
Expand Down
5 changes: 4 additions & 1 deletion cookbook/models/cohere/image_agent_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

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

download_image(url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg", save_path=str(image_path))
download_image(
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
output_path=str(image_path),
)

# Read the image file content as bytes
image_bytes = image_path.read_bytes()
Expand Down
5 changes: 4 additions & 1 deletion cookbook/models/cohere/image_agent_local_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

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

download_image(url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg", save_path=str(image_path))
download_image(
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
output_path=str(image_path),
)

agent.print_response(
"Tell me about this image.",
Expand Down
25 changes: 25 additions & 0 deletions cookbook/models/google/gemini/pdf_input_local.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 File
from agno.models.google import Gemini
from agno.utils.media import download_file

pdf_path = Path(__file__).parent.joinpath("ThaiRecipes.pdf")

# Download the file using the download_file function
download_file(
"https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf", str(pdf_path)
)

agent = Agent(
model=Gemini(id="gemini-2.0-flash-exp"),
markdown=True,
add_history_to_messages=True,
)

agent.print_response(
"Summarize the contents of the attached file.",
files=[File(filepath=pdf_path)],
)
agent.print_response("Suggest me a recipe from the attached file.")
13 changes: 13 additions & 0 deletions cookbook/models/google/gemini/pdf_input_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from agno.agent import Agent
from agno.media import File
from agno.models.google import Gemini

agent = Agent(
model=Gemini(id="gemini-2.0-flash-exp"),
markdown=True,
)

agent.print_response(
"Summarize the contents of the attached file.",
files=[File(url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf")],
)
5 changes: 4 additions & 1 deletion cookbook/models/openai/image_agent_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

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

download_image(url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg", save_path=str(image_path))
download_image(
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
output_path=str(image_path),
)

# Read the image file content as bytes
image_bytes = image_path.read_bytes()
Expand Down
5 changes: 4 additions & 1 deletion cookbook/models/xai/image_agent_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

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

download_image(url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg", save_path=str(image_path))
download_image(
url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg",
output_path=str(image_path),
)

# Read the image file content as bytes
image_bytes = image_path.read_bytes()
Expand Down
2 changes: 1 addition & 1 deletion cookbook/tools/dalle_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
if response.images:
download_image(
url=response.images[0].url,
save_path=Path(__file__).parent.joinpath("tmp/nature.jpg"),
output_path=Path(__file__).parent.joinpath("tmp/nature.jpg"),
)
Loading