file_output.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export your OpenAI API key
4
Run the example
Save the code above as
file_output.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Serve an agent that generates downloadable files with FileGenerationTools in AgentOS.
"""
File Output
===========
Demonstrates file output.
"""
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIChat
from agno.os import AgentOS
from agno.tools.file_generation import FileGenerationTools
# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
db = SqliteDb(db_file="tmp/agentos.db")
file_agent = Agent(
name="File Output Agent",
model=OpenAIChat(id="gpt-4o"),
db=db,
send_media_to_model=False,
tools=[FileGenerationTools(output_directory="tmp")],
instructions="Just return the file url as it is don't do anythings.",
)
agent_os = AgentOS(
id="agentos-demo",
agents=[file_agent],
)
app = agent_os.get_app()
# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent_os.serve(app="file_output:app", reload=True)
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U "agno[os]" openai python-docx reportlab
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
Run the example
file_output.py, then run:python file_output.py
Was this page helpful?