什么是agno ?
agno是一个全栈框架,用于构建具有内存,知识和推理的多代理系统。
使用agno构建5个级别的代理系统:
- 1级:具有工具和说明的代理。
- 级别2:具有知识和存储的代理。
- 级别3:具有内存和推理的代理。
- 第4级:可以推理和协作的代理团队。
- 第5级:具有状态和决定论的代理工作流程。
示例:使用Yfinance API回答问题的1级推理代理:
from agno . agent import Agent
from agno . models . anthropic import Claude
from agno . tools . reasoning import ReasoningTools
from agno . tools . yfinance import YFinanceTools
reasoning_agent = Agent (
model = Claude ( id = "claude-sonnet-4-20250514" ),
tools = [
ReasoningTools ( add_instructions = True ),
YFinanceTools ( stock_price = True , analyst_recommendations = True , company_info = True , company_news = True ),
],
instructions = "Use tables to display data." ,
markdown = True ,
)
clunching_finance_agent.mp4
开始
如果您是agno的新手,请阅读文档以构建您的第一个代理,在操场上与它进行聊天,然后在agno .com上进行监视。
之后,结帐示例画廊并使用agno构建真实的应用程序。
为什么要agno ?
agno将帮助您建立一流的,高度表现的代理系统,为您节省数小时的研究和样板。这是一些将agno与众不同的关键功能:
- Model agno Stic : agno为23+模型提供商提供了一个统一的接口,没有锁定。
- 高性能剂:代理在〜3μs中进行实例化,平均使用〜6.5KIB记忆。
- 推理是一流的公民:推理提高了可靠性,对于复杂的自主代理人来说是必不可少的。 agno支持3种推理方法:推理模型,推理工具或我们的定制链条方法。
- 本地多模式: agno代理是本地多模式的,他们接受文本,图像,音频和视频作为输入,并生成文本,图像,音频和视频作为输出。
- 高级多代理体系结构: agno为行业领先的多代理体系结构(代理团队)提供了推理,内存和共享上下文。
- 内置代理搜索:代理可以使用20+矢量数据库在运行时搜索信息。 agno提供了最先进的代理抹布,完全异步和高性能。
- 内置内存和会话存储:代理带有内置存储和内存驱动程序,可为您的代理提供长期内存和会话存储。
- 结构化输出: agno代理可以使用模型提供的结构化输出或JSON_MODE返回完全类型的响应。
- 预先建造的FastApi路线:建造代理后,使用预先构建的FastApi路线为其服务。 0在几分钟内生产。
- 监视:在agno .com上实时实时的监视代理会话和性能。
安装
pip install -U agno 示例 - 推理代理
让我们建立一个推理代理,以了解agno的能力。
将此代码保存到文件:clunching_agent.py。
from agno . agent import Agent
from agno . models . anthropic import Claude
from agno . tools . reasoning import ReasoningTools
from agno . tools . yfinance import YFinanceTools
agent = Agent (
model = Claude ( id = "claude-sonnet-4-20250514" ),
tools = [
ReasoningTools ( add_instructions = True ),
YFinanceTools ( stock_price = True , analyst_recommendations = True , company_info = True , company_news = True ),
],
instructions = [
"Use tables to display data" ,
"Only output the report, no other text" ,
],
markdown = True ,
)
agent . print_response (
"Write a report on NVDA" ,
stream = True ,
show_full_reasoning = True ,
stream_intermediate_steps = True ,
)
然后创建一个虚拟环境,安装依赖项,导出您的Anthropic_api_key并运行代理。
uv venv --python 3.12
source .venv/bin/activate
uv pip install agno anthropic yfinance
export ANTHROPIC_API_KEY=sk-ant-api03-xxxx
python reasoning_agent.py
我们可以看到代理通过任务推理,使用推理工具和yfinancetools收集信息。这就是输出的样子:
clunching_finance_agent.mp4
示例 - 多代理团队
代理人是原子能部门,当它们具有狭窄的范围和少量工具时,它们的运作效果最好。当工具的数量超出模型可以处理的内容或您需要处理多个概念的数量时,请使用代理团队来分散负载。
from agno . agent import Agent
from agno . models . openai import OpenAIChat
from agno . tools . duckduckgo import DuckDuckGoTools
from agno . tools . yfinance import YFinanceTools
from agno . team import Team
web_agent = Agent (
name = "Web Agent" ,
role = "Search the web for information" ,
model = OpenAIChat ( id = "gpt-4o" ),
tools = [ DuckDuckGoTools ()],
instructions = "Always include sources" ,
show_tool_calls = True ,
markdown = True ,
)
finance_agent = Agent (
name = "Finance Agent" ,
role = "Get financial data" ,
model = OpenAIChat ( id = "gpt-4o" ),
tools = [ YFinanceTools ( stock_price = True , analyst_recommendations = True , company_info = True )],
instructions = "Use tables to display data" ,
show_tool_calls = True ,
markdown = True ,
)
agent_team = Team (
mode = "coordinate" ,
members = [ web_agent , finance_agent ],
model = OpenAIChat ( id = "gpt-4o" ),
success_criteria = "A comprehensive financial news report with clear sections and data-driven insights." ,
instructions = [ "Always include sources" , "Use tables to display data" ],
show_tool_calls = True ,
markdown = True ,
)
agent_team . print_response ( "What's the market outlook and financial performance of AI semiconductor companies?" , stream = True )
安装依赖项并运行代理团队:
pip install duckduckgo-search yfinance
python agent_team.py在食谱中查看此示例
表现
在agno ,我们迷上了表现。为什么?因为即使是简单的AI工作流也可以产生数千个代理。将其扩展到适度的用户,性能成为瓶颈。 agno专为建造高性能代理系统而设计:
- 代理实例:平均约3μs
- 内存足迹:平均〜6.5KIB
在Apple M4 Mackbook Pro上测试。
虽然通过推理对代理的运行时间进行瓶颈,但我们必须尽一切可能最小化执行时间,减少内存使用情况并并行化工具调用。这些数字起初似乎很容易,但是我们的经验表明它们甚至在相当小的规模上加起来。
实例化时间
让我们衡量具有1个工具启动的代理所花费的时间。我们将进行评估1000次以获得基线测量。
您应该自己在自己的机器上进行评估,请不要以面值来获得这些结果。
# Setup virtual environment
./scripts/perf_setup.sh
source .venvs/perfenv/bin/activate
# OR Install dependencies manually
# pip install openai agno langgraph langchain_openai
# agno
python evals/performance/instantiation_with_tool.py
# LangGraph
python evals/performance/other/langgraph_instantiation.py
以下评估在Apple M4 Mackbook Pro上进行。它还可以作为该仓库的github动作运行。
langgraph在右边,让我们先启动它,然后让它开始。
agno在左边,请注意在Langgraph通过运行时测量1/2之前的结束,甚至没有开始记忆测量。这就是agno速度。
内存使用
为了测量内存使用情况,我们使用Tracemalloc库。我们首先通过运行空功能来计算基线内存使用量,然后运行代理1000倍并计算差异。这给出了对代理的内存使用情况的(合理)孤立的测量。
我们建议您自己在自己的机器上运行评估,然后挖掘代码以查看其工作原理。如果我们犯了一个错误,请告诉我们。
结论
agno代理是为性能而设计的,尽管我们确实针对其他框架共享一些基准,但我们应该注意准确性和可靠性比速度更重要。
鉴于每个框架都是不同的,我们将无法像与agno那样调整其性能,因为将来的基准标准我们只会与自己进行比较。
完整的文档索引
为了使LLMS和AI助手了解和导航agno的完整文档,我们提供了llms.txt或llms-full.txt文件。
该文件专门为AI系统有效解析和引用我们的文档。
光标设置
在构建agno代理时,将agno文档作为光标中的来源是加快开发的好方法。
- 在光标中,转到“光标设置”菜单。
- 找到“索引和文档”部分。
- 将https://docs.*a**gno.com/llms-full.txt添加到文档URL列表中。
- 保存更改。
现在,光标将可以访问agno文档。
文档,社区和更多示例
- 文档:文档。 agno .com
- 食谱:食谱
- 社区论坛:社区。 agno .com
- 不和谐:不和谐
贡献
我们欢迎贡献,阅读我们的贡献指南以入门。
遥测
代理使用的agno日志,以便我们将更新优先为最受欢迎的提供商。您可以通过在环境中设置agno _telemetry = false来禁用此问题。
⬆️回到顶部
通过命令行克隆项目: