Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkbrnd committed Feb 18, 2025
2 parents ee487a9 + 299827b commit 116e1d8
Show file tree
Hide file tree
Showing 146 changed files with 6,699 additions and 634 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@

## Overview

[Agno](https://docs.agno.com) is a lightweight framework for building multi-modal Agents.
[Agno](https://docs.agno.com) is a lightweight library for building multi-modal Agents.

## Simple, Fast, and Agnostic

Agno is designed with three core principles:

- **Simplicity**: No graphs, chains, or convoluted patterns — just pure python.
- **Uncompromising Performance**: Blazing fast agents with a minimal memory footprint.
- **Truly Agnostic**: Any model, any provider, any modality. Future-proof agents.
- **Truly Agnostic**: Any model, any provider, any modality. Agno is designed to be the container for AGI.

## Key features

Here's why you should build Agents with Agno:

- **Lightning Fast**: Agent creation is ~10,000x faster than LangGraph (see [performance](#performance)).
- **Model Agnostic**: Use any model, any provider, no lock-in.
- **Multi Modal**: Native support for text, image, audio and video.
- **Multi Modal**: Native support for input and output text, image, audio and video.
- **Multi Agent**: Delegate tasks across a team of specialized agents.
- **Memory Management**: Store user sessions and agent state in a database.
- **Memory Management**: Store agent sessions and state in a database.
- **Knowledge Stores**: Use vector databases for Agentic RAG or dynamic few-shot.
- **Structured Outputs**: Make Agents respond with structured data.
- **Monitoring**: Track agent sessions and performance in real-time on [agno.com](https://app.agno.com).
Expand All @@ -47,7 +47,7 @@ pip install -U agno

## What are Agents?

Agents are autonomous programs that use language models to achieve tasks. They solve problems by running tools, accessing knowledge and memory to improve responses.
Agents are autonomous programs that use language models to achieve tasks. They solve problems by running tools and using knowledge and memory to improve responses.

Instead of a rigid binary definition, let's think of Agents in terms of agency and autonomy.

Expand Down Expand Up @@ -220,14 +220,14 @@ python agent_team.py

## Performance

Agno is designed for high performance agentic systems:
At Agno, we're obsessed with performance. Agno is designed to power high performance agentic systems:

- Agent instantiation: <5μs on average (~10,000x faster than LangGraph).
- Memory footprint: <0.01Mib on average (~50x less memory than LangGraph).
- Agent instantiation: ~2μs on average (~10,000x faster than LangGraph).
- Memory footprint: ~3.75Kib on average (~50x less memory than LangGraph).

> Tested on an Apple M4 Mackbook Pro.
While an Agent's performance is bottlenecked by inference, we must do everything possible to minimize execution time, reduce memory usage, and parallelize tool calls. These numbers are may seem trivial, but they add up even at medium scale.
While an Agent's performance is bottlenecked by inference, we must do everything possible to minimize execution time, reduce memory usage, and parallelize tool calls. These numbers may seem trivial at first, but they add up even at a reasonably small scale.

### Instantiation time

Expand Down
48 changes: 48 additions & 0 deletions cookbook/agent_concepts/async/delay.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import asyncio

from agno.agent import Agent, RunResponse
from agno.models.openai import OpenAIChat
from agno.tools.duckduckgo import DuckDuckGoTools
from rich.pretty import pprint

providers = ["openai", "anthropic", "ollama", "cohere", "google"]
instructions = [
"Your task is to write a well researched report on AI providers.",
"The report should be unbiased and factual.",
]


async def get_agent(delay, provider):
agent = Agent(
model=OpenAIChat(id="gpt-4"),
instructions=instructions,
tools=[DuckDuckGoTools()],
)
await asyncio.sleep(delay)
response: RunResponse = await agent.arun(
f"Write a report on the following AI provider: {provider}"
)
return response


async def get_reports():
tasks = []
for delay, provider in enumerate(providers):
delay = delay * 2
tasks.append(get_agent(delay, provider))

results = await asyncio.gather(*tasks)
return results


async def main():
results = await get_reports()
for result in results:
print("************")
pprint(result.content)
print("************")
print("\n")


if __name__ == "__main__":
asyncio.run(main())
6 changes: 3 additions & 3 deletions cookbook/agent_concepts/knowledge/vector_dbs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ python cookbook/vector_dbs/pinecone_db.py

#### Create the database

- Visit http://localhost:8080 and login with `root` and `admin`
- Create the database with your choice of name. Default setup script requires AGNO as database name.
- Visit http://localhost:8080 and login with username: `root` and password: `admin`
- Create the database with your choice of name. Default setup script requires AGNO as database name. `CREATE DATABASE your_database_name;`

#### Add credentials

Expand Down Expand Up @@ -174,4 +174,4 @@ python cookbook/vector_dbs/qdrant_db.py

```shell
python cookbook/vector_dbs/weaviate_db.py
```
```
2 changes: 1 addition & 1 deletion cookbook/agent_concepts/knowledge/vector_dbs/lance_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# By default, it stores data in /tmp/lancedb
vector_db = LanceDb(
table_name="recipes",
uri="/tmp/lancedb", # You can change this path to store data elsewhere
uri="tmp/lancedb", # You can change this path to store data elsewhere
)

# Create knowledge base
Expand Down
30 changes: 28 additions & 2 deletions cookbook/agent_concepts/knowledge/vector_dbs/mongodb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
# install pymongo - `pip install pymongo`
"""
1. Create a MongoDB Atlas Account:
- Go to https://www.mongodb.com/cloud/atlas/register
- Sign up for a free account
2. Create a New Cluster:
- Click "Build a Database"
- Choose the FREE tier (M0)
- Select your preferred cloud provider and region
- Click "Create Cluster"
3. Set Up Database Access:
- Follow the instructions in the MongoDB Atlas UI
- Create a username and password
- Click "Add New Database User"
5. Get Connection String:
- Select "Drivers" as connection method
- Select "Python" as driver
- Copy the connection string
7. Test Connection:
- Use the connection string in your code
- Ensure pymongo is installed: pip install "pymongo[srv]"
- Test with a simple query to verify connectivity
"""

from agno.agent import Agent
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
Expand All @@ -21,7 +46,8 @@
wait_after_insert=300,
),
) # adjust wait_after_insert and wait_until_index_ready to your needs
knowledge_base.load(recreate=True)

knowledge_base.load(recreate=False)

# Create and use the agent
agent = Agent(knowledge=knowledge_base, show_tool_calls=True)
Expand Down
12 changes: 12 additions & 0 deletions cookbook/agent_concepts/knowledge/vector_dbs/singlestore.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
"""
# Run the setup script
```shell
./cookbook/scripts/run_singlestore.sh
```
# Create the database
- Visit http://localhost:8080 and login with `root` and `admin`
- Create the database with your choice of name. Default setup script requires AGNO as database name. `CREATE DATABASE your_database_name;`
"""

from os import getenv

from agno.agent import Agent
Expand Down
1 change: 0 additions & 1 deletion cookbook/agent_concepts/multimodal/video_caption_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
process_video=True, generate_captions=True, embed_captions=True
)


openai_tools = OpenAITools()

video_caption_agent = Agent(
Expand Down
26 changes: 9 additions & 17 deletions cookbook/agent_concepts/multimodal/video_to_shorts.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
"""
1. Install dependencies using: `pip install opencv-python google-generativeai sqlalchemy`
1. Install dependencies using: `pip install opencv-python google-geneai sqlalchemy`
2. Install ffmpeg `brew install ffmpeg`
2. Run the script using: `python cookbook/agent_concepts/video_to_shorts.py`
"""

import subprocess
import time
from pathlib import Path

from agno.agent import Agent
from agno.media import Video
from agno.models.google import Gemini
from agno.utils.log import logger
from google.generativeai import get_file, upload_file

video_path = Path(__file__).parent.joinpath("sample.mp4")
video_path = Path(__file__).parent.joinpath("sample_video.mp4")
output_dir = Path("tmp/shorts")

agent = Agent(
Expand All @@ -36,13 +34,7 @@
],
)

# 2. Upload and process video
video_file = upload_file(video_path)
while video_file.state.name == "PROCESSING":
time.sleep(2)
video_file = get_file(video_file.name)

# 3. Multimodal Query for Video Analysis
# 2. Multimodal Query for Video Analysis
query = """
You are an expert in video content creation, specializing in crafting engaging short-form content for platforms like YouTube Shorts and Instagram Reels. Your task is to analyze the provided video and identify segments that maximize viewer engagement.
Expand Down Expand Up @@ -72,15 +64,15 @@
Your goal is to identify moments that are visually compelling, emotionally engaging, and perfectly optimized for short-form platforms.
"""

# 4. Generate Video Analysis
response = agent.run(query, videos=[Video(content=video_file)])
# 3. Generate Video Analysis
response = agent.run(query, videos=[Video(filepath=video_path)])

# 5. Create output directory
# 4. Create output directory
output_dir = Path(output_dir)
output_dir.mkdir(parents=True, exist_ok=True)


# 6. Extract and cut video segments - Optional
# 5. Extract and cut video segments - Optional
def extract_segments(response_text):
import re

Expand Down Expand Up @@ -134,10 +126,10 @@ def extract_segments(response_text):

logger.debug(f"{response.content}")

# 7. Process segments
# 6. Process segments
shorts = extract_segments(response.content)

# 8. Print results
# 7. Print results
print("\n--- Generated Shorts ---")
for short in shorts:
print(f"Short at {short['path']}")
Expand Down
22 changes: 22 additions & 0 deletions cookbook/agent_concepts/reasoning/openai/9_11_or_9_9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from agno.agent import Agent
from agno.cli.console import console
from agno.models.anthropic import Claude
from agno.models.openai import OpenAIChat

task = "9.11 and 9.9 -- which is bigger?"

reasoning_agent_claude = Agent(
model=Claude("claude-3-5-sonnet-20241022"),
reasoning_model=OpenAIChat(id="o3-mini"),
)

reasoning_agent_openai = Agent(
model=OpenAIChat(id="gpt-4o"),
reasoning_model=OpenAIChat(id="o3-mini"),
)

console.rule("[bold green]Claude Reasoning Agent[/bold green]")
reasoning_agent_claude.print_response(task, stream=True)

console.rule("[bold yellow]OpenAI Reasoning Agent[/bold yellow]")
reasoning_agent_openai.print_response(task, stream=True)
Empty file.
Loading

0 comments on commit 116e1d8

Please sign in to comment.