Loading...
Loading...
Compare original and translation side by side
from agno.agent import Agent
from agno.tools.duckduckgo import DuckDuckGoTools
agent = Agent(
tools=[DuckDuckGoTools()],
markdown=True,
)
agent.print_response("Search for the latest AI news", stream=True)from agno.agent import Agent
from agno.tools.duckduckgo import DuckDuckGoTools
agent = Agent(
tools=[DuckDuckGoTools()],
markdown=True,
)
agent.print_response("Search for the latest AI news", stream=True)from agno.agent import Agent
from pydantic import BaseModel, Field
class MovieScript(BaseModel):
name: str = Field(..., description="Movie title")
genre: str = Field(..., description="Movie genre")
storyline: str = Field(..., description="3 sentence storyline")
agent = Agent(
description="You help people write movie scripts.",
output_schema=MovieScript,
)
result = agent.run("Write a sci-fi thriller")
print(result.content.name) # Access structured outputfrom agno.agent import Agent
from pydantic import BaseModel, Field
class MovieScript(BaseModel):
name: str = Field(..., description="Movie title")
genre: str = Field(..., description="Movie genre")
storyline: str = Field(..., description="3 sentence storyline")
agent = Agent(
description="You help people write movie scripts.",
output_schema=MovieScript,
)
result = agent.run("Write a sci-fi thriller")
print(result.content.name) # Access structured outputimport asyncio
from agno.agent import Agent
from agno.tools.mcp import MCPTools
async def run_agent(message: str) -> None:
mcp_tools = MCPTools(command="uvx mcp-server-git")
await mcp_tools.connect()
try:
agent = Agent(tools=[mcp_tools])
await agent.aprint_response(message, stream=True)
finally:
await mcp_tools.close()
asyncio.run(run_agent("What is the license for this project?"))import asyncio
from agno.agent import Agent
from agno.tools.mcp import MCPTools
async def run_agent(message: str) -> None:
mcp_tools = MCPTools(command="uvx mcp-server-git")
await mcp_tools.connect()
try:
agent = Agent(tools=[mcp_tools])
await agent.aprint_response(message, stream=True)
finally:
await mcp_tools.close()
asyncio.run(run_agent("What is the license for this project?"))import asyncio
import os
from agno.agent import Agent
from agno.tools.mcp import MultiMCPTools
async def run_agent(message: str) -> None:
env = {
**os.environ,
"GOOGLE_MAPS_API_KEY": os.getenv("GOOGLE_MAPS_API_KEY"),
}
mcp_tools = MultiMCPTools(
commands=[
"npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt",
"npx -y @modelcontextprotocol/server-google-maps",
],
env=env,
)
await mcp_tools.connect()
try:
agent = Agent(tools=[mcp_tools], markdown=True)
await agent.aprint_response(message, stream=True)
finally:
await mcp_tools.close()import asyncio
import os
from agno.agent import Agent
from agno.tools.mcp import MultiMCPTools
async def run_agent(message: str) -> None:
env = {
**os.environ,
"GOOGLE_MAPS_API_KEY": os.getenv("GOOGLE_MAPS_API_KEY"),
}
mcp_tools = MultiMCPTools(
commands=[
"npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt",
"npx -y @modelcontextprotocol/server-google-maps",
],
env=env,
)
await mcp_tools.connect()
try:
agent = Agent(tools=[mcp_tools], markdown=True)
await agent.aprint_response(message, stream=True)
finally:
await mcp_tools.close()from agno.agent import Agent
from agno.team import Team
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.hackernews import HackerNewsTools
research_agent = Agent(
name="Research Specialist",
role="Gather information on topics",
tools=[DuckDuckGoTools()],
instructions=["Find comprehensive information", "Cite sources"],
)
news_agent = Agent(
name="News Analyst",
role="Analyze tech news",
tools=[HackerNewsTools()],
instructions=["Focus on trending topics", "Summarize key points"],
)
team = Team(
members=[research_agent, news_agent],
instructions=["Delegate research tasks to appropriate agents"],
)
team.print_response("Research AI trends and latest HN discussions", stream=True)from agno.agent import Agent
from agno.team import Team
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.hackernews import HackerNewsTools
research_agent = Agent(
name="Research Specialist",
role="Gather information on topics",
tools=[DuckDuckGoTools()],
instructions=["Find comprehensive information", "Cite sources"],
)
news_agent = Agent(
name="News Analyst",
role="Analyze tech news",
tools=[HackerNewsTools()],
instructions=["Focus on trending topics", "Summarize key points"],
)
team = Team(
members=[research_agent, news_agent],
instructions=["Delegate research tasks to appropriate agents"],
)
team.print_response("Research AI trends and latest HN discussions", stream=True)from agno.agent import Agent
from agno.workflow.workflow import Workflow
from agno.workflow.router import Router
from agno.workflow.step import Step
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.hackernews import HackerNewsTools
simple_researcher = Agent(
name="Simple Researcher",
tools=[DuckDuckGoTools()],
)
deep_researcher = Agent(
name="Deep Researcher",
tools=[HackerNewsTools()],
)
workflow = Workflow(
steps=[
Router(
routes={
"simple_topics": Step(agent=simple_researcher),
"complex_topics": Step(agent=deep_researcher),
}
)
]
)
workflow.run("Research quantum computing")from agno.agent import Agent
from agno.workflow.workflow import Workflow
from agno.workflow.router import Router
from agno.workflow.step import Step
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.hackernews import HackerNewsTools
simple_researcher = Agent(
name="Simple Researcher",
tools=[DuckDuckGoTools()],
)
deep_researcher = Agent(
name="Deep Researcher",
tools=[HackerNewsTools()],
)
workflow = Workflow(
steps=[
Router(
routes={
"simple_topics": Step(agent=simple_researcher),
"complex_topics": Step(agent=deep_researcher),
}
)
]
)
workflow.run("Research quantum computing")from agno.agent import Agent
from agno.db.postgres import PostgresDb
db = PostgresDb(
db_url="postgresql://user:pass@localhost:5432/agno", schema="agno_sessions"
)
agent = Agent(
db=db,
session_id="user-123", # Persistent session
add_history_to_messages=True,
)from agno.agent import Agent
from agno.db.postgres import PostgresDb
db = PostgresDb(
db_url="postgresql://user:pass@localhost:5432/agno", schema="agno_sessions"
)
agent = Agent(
db=db,
session_id="user-123", # Persistent session
add_history_to_messages=True,
)undefinedundefinedfrom fastapi import FastAPI
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.os import AgentOSfrom fastapi import FastAPI
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.os import AgentOSundefinedundefinedfrom agno.agent import Agent
from agno.tools.hackernews import HackerNewsTools
agent = Agent(
tools=[HackerNewsTools()],
debug_mode=True, # Enable detailed logging
# debug_level=2, # More verbose output
)from agno.agent import Agent
from agno.tools.hackernews import HackerNewsTools
agent = Agent(
tools=[HackerNewsTools()],
debug_mode=True, # Enable detailed logging
# debug_level=2, # More verbose output
)undefinedundefinedfrom typing import List
from agno.agent import Agent
from agno.workflow.workflow import Workflow
from agno.workflow.step import Step
from pydantic import BaseModel, Field
class ResearchTopic(BaseModel):
"""Structured research topic with specific requirements"""
topic: str
focus_areas: List[str] = Field(description="Specific areas to focus on")
target_audience: str = Field(description="Who this research is for")
sources_required: int = Field(description="Number of sources needed", default=5)
workflow = Workflow(
input_schema=ResearchTopic, # Validate inputs
steps=[Step(agent=Agent(instructions=["Research based on focus areas"]))],
)from typing import List
from agno.agent import Agent
from agno.workflow.workflow import Workflow
from agno.workflow.step import Step
from pydantic import BaseModel, Field
class ResearchTopic(BaseModel):
"""Structured research topic with specific requirements"""
topic: str
focus_areas: List[str] = Field(description="Specific areas to focus on")
target_audience: str = Field(description="Who this research is for")
sources_required: int = Field(description="Number of sources needed", default=5)
workflow = Workflow(
input_schema=ResearchTopic, # Validate inputs
steps=[Step(agent=Agent(instructions=["Research based on focus areas"]))],
)undefinedundefinedreferences/references/Agent().print_response().run()from agno.agent import Agent
from agno.tools.duckduckgo import DuckDuckGoTools
agent = Agent(tools=[DuckDuckGoTools()])
agent.print_response("Your question here")Agent().print_response().run()from agno.agent import Agent
from agno.tools.duckduckgo import DuckDuckGoTools
agent = Agent(tools=[DuckDuckGoTools()])
agent.print_response("Your question here")from agno.team import Team
team = Team(
members=[researcher, analyst, writer],
instructions=["Delegate tasks based on agent roles"],
)from agno.team import Team
team = Team(
members=[researcher, analyst, writer],
instructions=["Delegate tasks based on agent roles"],
)from agno.os import AgentOS
agent_os = AgentOS(
agents=[agent1, agent2], db=PostgresDb(...), base_app=custom_fastapi_app
)
agent_os.serve()from agno.os import AgentOS
agent_os = AgentOS(
agents=[agent1, agent2], db=PostgresDb(...), base_app=custom_fastapi_app
)
agent_os.serve()examples.mdagents.mdagentos.mdintegration.mddebug_mode=Trueexamples.mdagents.mdagentos.mdintegration.mddebug_mode=Trueasync def run_with_mcp():
mcp_tools = MCPTools(command="uvx mcp-server-git")
await mcp_tools.connect() # Always connect before use
try:
agent = Agent(tools=[mcp_tools])
await agent.aprint_response("Your query")
finally:
await mcp_tools.close() # Always close when doneasync def run_with_mcp():
mcp_tools = MCPTools(command="uvx mcp-server-git")
await mcp_tools.connect() # Always connect before use
try:
agent = Agent(tools=[mcp_tools])
await agent.aprint_response("Your query")
finally:
await mcp_tools.close() # Always close when donefrom agno.agent import Agent
from agno.db.postgres import PostgresDb
db = PostgresDb(db_url="postgresql://...")
agent = Agent(
db=db,
session_id="unique-user-id",
add_history_to_messages=True, # Include conversation history
)from agno.agent import Agent
from agno.db.postgres import PostgresDb
db = PostgresDb(db_url="postgresql://...")
agent = Agent(
db=db,
session_id="unique-user-id",
add_history_to_messages=True, # Include conversation history
)from agno.workflow.router import Router
workflow = Workflow(
steps=[
Router(
routes={
"route_a": Step(agent=agent_a),
"route_b": Step(agent=b),
}
)
]
)from agno.workflow.router import Router
workflow = Workflow(
steps=[
Router(
routes={
"route_a": Step(agent=agent_a),
"route_b": Step(agent=b),
}
)
]
)debug_mode=Trueoutput_schema=AGNO_TELEMETRY=falsetelemetry=Falsedebug_mode=Trueoutput_schema=AGNO_TELEMETRY=falsetelemetry=False