FileGenerationTools to generate files in different formats.
file_generation.py
Usage
1
Set up your virtual environment
2
Install dependencies
3
Export your OpenAI API key
4
Run Agent
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Generate files in different formats with Agno agents.
FileGenerationTools to generate files in different formats.
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.tools.file_generation import FileGenerationTools
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
db=SqliteDb(db_file="tmp/test.db"),
tools=[FileGenerationTools(output_directory="tmp")],
description="You are a helpful assistant that can generate files in various formats.",
instructions=[
"When asked to create files, use the appropriate file generation tools.",
"Always provide meaningful content and appropriate filenames.",
"Explain what you've created and how it can be used.",
],
markdown=True,
)
response = agent.run(
"Create a PDF report about renewable energy trends in 2024. Include sections on solar, wind, and hydroelectric power."
)
print(response.content)
if response.files:
for file in response.files:
print(f"Generated file: {file.filename} ({file.size} bytes)")
if file.url:
print(f"File location: {file.url}")
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 openai sqlalchemy reportlab python-docx agno
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
Run Agent
python file_generation.py
Was this page helpful?