workflow_with_file_input.py
"""
Workflow With File Input
========================
Demonstrates passing file inputs through workflow steps for reading and summarization.
"""
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.media import File
from agno.models.anthropic import Claude
from agno.models.openai import OpenAIChat
from agno.workflow.step import Step
from agno.workflow.workflow import Workflow
# ---------------------------------------------------------------------------
# Create Agents
# ---------------------------------------------------------------------------
read_agent = Agent(
name="Agent",
model=Claude(id="claude-sonnet-4-20250514"),
role="Read the contents of the attached file.",
)
summarize_agent = Agent(
name="Summarize Agent",
model=OpenAIChat(id="gpt-4o"),
instructions=[
"Summarize the contents of the attached file.",
],
)
# ---------------------------------------------------------------------------
# Define Steps
# ---------------------------------------------------------------------------
read_step = Step(
name="Read Step",
agent=read_agent,
)
summarize_step = Step(
name="Summarize Step",
agent=summarize_agent,
)
# ---------------------------------------------------------------------------
# Create Workflow
# ---------------------------------------------------------------------------
content_creation_workflow = Workflow(
name="Content Creation Workflow",
description="Automated content creation from blog posts to social media",
db=SqliteDb(
session_table="workflow",
db_file="tmp/workflow.db",
),
steps=[read_step, summarize_step],
)
# ---------------------------------------------------------------------------
# Run Workflow
# ---------------------------------------------------------------------------
if __name__ == "__main__":
content_creation_workflow.print_response(
input="Summarize the contents of the attached file.",
files=[
File(url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf")
],
markdown=True,
)
Run the Example
1
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2
Install dependencies
uv pip install -U agno anthropic fastapi openai sqlalchemy
3
Export your API keys
export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:ANTHROPIC_API_KEY="your_anthropic_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
4
Run the example
Save the code above as
workflow_with_file_input.py, then run:python workflow_with_file_input.py