Examples
- Examples
- Getting Started
- Agents
- Teams
- Workflows
- Applications
- FastAPI
- WhatsApp
- Slack
- Playground
- AG-UI
- Streamlit Apps
- Evals
Agent Concepts
- Reasoning
- Multimodal
- RAG
- User Control Flows
- Knowledge
- Memory
- Async
- Hybrid Search
- Storage
- Tools
- Vector Databases
- Context
- Embedders
- Agent State
- Observability
- Miscellaneous
Models
- Anthropic
- AWS Bedrock
- AWS Bedrock Claude
- Azure AI Foundry
- Azure OpenAI
- Cerebras
- Cerebras OpenAI
- Cohere
- DeepInfra
- DeepSeek
- Fireworks
- Gemini
- Groq
- Hugging Face
- IBM
- LM Studio
- LiteLLM
- LiteLLM OpenAI
- Meta
- Mistral
- NVIDIA
- Ollama
- OpenAI
- Perplexity
- Together
- XAI
- Vercel
- vLLM
Playground
Upload Files
Code
cookbook/apps/playground/upload_files.py
Copy
Ask AI
from agno.agent import Agent
from agno.knowledge.combined import CombinedKnowledgeBase
from agno.knowledge.csv import CSVKnowledgeBase
from agno.knowledge.docx import DocxKnowledgeBase
from agno.knowledge.json import JSONKnowledgeBase
from agno.knowledge.pdf import PDFKnowledgeBase
from agno.knowledge.text import TextKnowledgeBase
from agno.models.google.gemini import Gemini
from agno.models.openai import OpenAIChat
from agno.playground import Playground
from agno.storage.postgres import PostgresStorage
from agno.vectordb.pgvector import PgVector
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
knowledge_base = CombinedKnowledgeBase(
sources=[
PDFKnowledgeBase(
vector_db=PgVector(table_name="recipes_pdf", db_url=db_url), path=""
),
CSVKnowledgeBase(
vector_db=PgVector(table_name="recipes_csv", db_url=db_url), path=""
),
DocxKnowledgeBase(
vector_db=PgVector(table_name="recipes_docx", db_url=db_url), path=""
),
JSONKnowledgeBase(
vector_db=PgVector(table_name="recipes_json", db_url=db_url), path=""
),
TextKnowledgeBase(
vector_db=PgVector(table_name="recipes_text", db_url=db_url), path=""
),
],
vector_db=PgVector(table_name="recipes_combined", db_url=db_url),
)
file_agent = Agent(
name="File Upload Agent",
agent_id="file-upload-agent",
role="Answer questions about the uploaded files",
model=OpenAIChat(id="gpt-4o-mini"),
storage=PostgresStorage(
table_name="agent_sessions", db_url=db_url, auto_upgrade_schema=True
),
knowledge=knowledge_base,
show_tool_calls=True,
markdown=True,
)
audio_agent = Agent(
name="Audio Understanding Agent",
agent_id="audio-understanding-agent",
role="Answer questions about audio files",
model=OpenAIChat(id="gpt-4o-audio-preview"),
storage=PostgresStorage(
table_name="agent_sessions", db_url=db_url, auto_upgrade_schema=True
),
add_history_to_messages=True,
add_datetime_to_instructions=True,
show_tool_calls=True,
markdown=True,
)
video_agent = Agent(
name="Video Understanding Agent",
model=Gemini(id="gemini-2.0-flash"),
agent_id="video-understanding-agent",
role="Answer questions about video files",
storage=PostgresStorage(
table_name="agent_sessions", db_url=db_url, auto_upgrade_schema=True
),
add_history_to_messages=True,
add_datetime_to_instructions=True,
show_tool_calls=True,
markdown=True,
)
playground = Playground(
agents=[file_agent, audio_agent, video_agent],
name="Upload Files Playground",
description="Upload files and ask questions about them",
app_id="upload-files-playground",
)
app = playground.get_app()
if __name__ == "__main__":
playground.serve(app="upload_files:app", reload=True)
Usage
1
Create a virtual environment
Open the Terminal
and create a python virtual environment.
Copy
Ask AI
python3 -m venv .venv
source .venv/bin/activate
2
Set your API keys
Copy
Ask AI
export OPENAI_API_KEY=xxx
export GOOGLE_API_KEY=xxx
3
Install libraries
Copy
Ask AI
pip install -U agno "uvicorn[standard]" openai google-generativeai psycopg-binary
pip install -U "agno[pdf,csv,docx,json,text]"
4
Run Agent
Copy
Ask AI
python cookbook/apps/playground/upload_files.py
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.