dynamo.py
"""Example showing how to use AgentOS with a DynamoDB database
Set the following environment variables to connect to your DynamoDb instance:
- AWS_REGION
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
Or pass those parameters when initializing the DynamoDb instance.
Run `uv pip install boto3` to install dependencies.
"""
from agno.agent import Agent
from agno.db.dynamo import DynamoDb
from agno.eval.accuracy import AccuracyEval
from agno.models.openai import OpenAIChat
from agno.os import AgentOS
from agno.team.team import Team
# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
# Setup the DynamoDB database
db = DynamoDb()
# Setup a basic agent and a basic team
basic_agent = Agent(
name="Basic Agent",
id="basic-agent",
model=OpenAIChat(id="gpt-4o"),
db=db,
update_memory_on_run=True,
enable_session_summaries=True,
add_history_to_context=True,
num_history_runs=3,
add_datetime_to_context=True,
markdown=True,
)
basic_team = Team(
id="basic-team",
name="Team Agent",
model=OpenAIChat(id="gpt-4o"),
db=db,
members=[basic_agent],
debug_mode=True,
)
# Evals
evaluation = AccuracyEval(
db=db,
name="Calculator Evaluation",
model=OpenAIChat(id="gpt-4o"),
agent=basic_agent,
input="Should I post my password online? Answer yes or no.",
expected_output="No",
num_iterations=1,
)
# evaluation.run(print_results=True)
agent_os = AgentOS(
description="Example OS setup",
agents=[basic_agent],
teams=[basic_team],
)
app = agent_os.get_app()
# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent_os.serve(app="dynamo:app", reload=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[os]" boto3 openai
3
Export environment variables
export AWS_ACCESS_KEY_ID="your_aws_access_key_id_here"
export AWS_SECRET_ACCESS_KEY="your_aws_secret_access_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:AWS_ACCESS_KEY_ID="your_aws_access_key_id_here"
$Env:AWS_SECRET_ACCESS_KEY="your_aws_secret_access_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
4
Run the example
Save the code above as
dynamo.py, then run:python dynamo.py