微信扫码
添加专属顾问
我要投稿
LangGraph与Agno-AGI两大框架深度对比,揭秘新一代AI智能体开发的核心竞争力。 核心内容: 1. Agno-AGI框架的多级智能体架构与核心特性解析 2. LangGraph在复杂状态管理方面的独特优势 3. 两大框架在实际开发中的性能对比与应用场景选择
pip install -U agno
# basic_Agent.py
from agno.agent import Agent
from agno.models.openai import OpenAIChat
# 创建 Agent
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
instructions="你是一个热情的新闻记者",
markdown=True
)
agent.print_response("分享一则纽约新闻,只输出新闻的摘要信息,字数控制在100个以内")
# agent_with_knowledge.py
import asyncio
from agno.agent import Agent
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.models.openai import OpenAIChat
from agno.tools.reasoning import ReasoningTools
from agno.vectordb.lancedb import LanceDb, SearchType
# 加载公司文档到知识库
knowledge = Knowledge(
vector_db=LanceDb(
uri="tmp/financial",
table_name="financial",
search_type=SearchType.hybrid, # 使用混合搜索
),
# 使用OpenAI进行嵌入
embedder=OpenAIEmbedder(id="text-embedding-3-small", dimensions=1536),
)
asyncio.run(knowledge.add_content_async(path="data/公司日常报销流程及步骤.docx"))
agent = Agent(
name="Agno Assist",
model=OpenAIChat(id="gpt-4o"),
instructions=[
"Use tables to display data.",
"Include sources in your response.",
"search your knowledge before answering the question.",
"only include the output in your response. No other text.",
],
knowledge=knowledge,
tools=[ReasoningTools(add_instructions=True)],
add_datetime_to_context=True,
markdown=True,
)
if __name__ == "__main__":
agent.print_response("公司日常报销流程及步骤?",
stream=True,
show_full_reasoning=True,
stream_events=True)
# agent_with_tools.py
from agno.agent import Agent
from agno.tools.baidusearch import BaiduSearchTools
agent = Agent(
tools=[BaiduSearchTools()],
description="You are a search agent that helps users find the most relevant information using Baidu.",
instructions=[
"根据用户提供的主题,提供该主题最相关的三条搜索结果。",
"搜索5个结果并选择排名前3的选项。",
"回复字数限定在300以内。"
],
)
agent.print_response("介绍一下聚客AI学院?", markdown=True)
# agent_team.py
from agno.agent import Agent
from agno.models.DeepSeek import DeepSeek
from agno.models.openai import OpenAIChat
from agno.team.team import Team
english_agent = Agent(
name="English Agent",
role="You only answer in English",
model=OpenAIChat(id="gpt-4o"),
)
chinese_agent = Agent(
name="Chinese Agent",
role="You only answer in Chinese",
model=DeepSeek(id="deepseek-chat"),
)
multi_language_team = Team(
name="Multi Language Team",
model=OpenAIChat("gpt-4o"),
members=[english_agent, chinese_agent],
markdown=True,
description="You are a language router that directs questions to the appropriate language agent.",
instructions=[
"Identify the language of the user's question and direct it to the appropriate language agent.",
"Let the language agent answer the question in the language of the user's question.",
"If the user asks in a language whose agent is not a team member, respond in English with:",
"'I can only answer in the following languages: English, Chinese. Please ask your question in one of these languages.'",
"Always check the language of the user's input before routing to an agent.",
"For unsupported languages like Italian, respond in English with the above message."
],
respond_directly=True,
determine_input_for_members=False,
show_members_responses=True,
)
if __name__ == "__main__":
# 测试多语言支持
multi_language_team.print_response("How are you?", stream=True) # English
multi_language_team.print_response("你好吗?", stream=True) # Chinese
multi_language_team.print_response("Come stai?", stream=True) # Italian
# agentos_basic.py
from agno.agent import Agent
from agno.models.deepseek import DeepSeek
from agno.models.openai import OpenAIChat
from agno.team.team import Team
from agno.os import AgentOS
english_agent = Agent(
name="English Agent",
role="You only answer in English",
model=OpenAIChat(id="gpt-4o"),
)
chinese_agent = Agent(
name="Chinese Agent",
role="You only answer in Chinese",
model=DeepSeek(id="deepseek-chat"),
)
multi_language_team = Team(
name="Multi Language Team",
model=OpenAIChat("gpt-4o"),
members=[english_agent, chinese_agent],
markdown=True,
description="You are a language router that directs questions to the appropriate language agent.",
instructions=[
"Identify the language of the user's question and direct it to the appropriate language agent.",
"Let the language agent answer the question in the language of the user's question."
"If the user asks in a language whose agent is not a team member, respond in English with:"
"'I can only answer in the following languages: English, Chinese. Please ask your question in one of these languages.'",
"Always check the language of the user's input before routing to an agent.",
"For unsupported languages like Italian, respond in English with the above message.",
],
respond_directly=True,
determine_input_for_members=False,
show_members_responses=True,
)
agent_os = AgentOS(
id="my-first-os",
description="My first AgentOS",
teams=[multi_language_team],
)
app = agent_os.get_app()
if __name__ == "__main__":
"""运行AgentOS
可以在 http://localhost:7777/config 查看配置和可用应用
"""
agent_os.serve(app="agentos_basic:app", reload=True)
(agno) PS D:\Kevin\Workspace\agno_test> python .\agentos_basic.py
AgentOS https://os.agno.com/OS running on: http://localhost:7777
INFO: Will watch for changes in these directories: ['D:\\Kevin\\Workspace\\agno_test']
INFO: Uvicorn running on http://localhost:7777 (Press CTRL+C to quit)
INFO: Started reloader process [11388] using WatchFiles
INFO: Started server process [26552]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: 127.0.0.1:6513 - "WebSocket /workflows/ws" [accepted]
INFO: connection open
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2026-01-29
自建一个 Agent 很难吗?一语道破,万语难明
2026-01-28
全球首个Skills Vibe Agents,AtomStorm技术揭秘:我是怎么用Context Engineering让Agent不"变傻"的
2026-01-22
Deepagents落地场景来了:用openwork实现专属办公小管家
2026-01-05
快速上手:LangChain + AgentRun 浏览器沙箱极简集成指南
2026-01-05
为什么大模型企业都在强调可以连续工作XX小时的Agent和模型?长时运行Agent解析(Long-Running Agents)
2025-12-29
单agent落幕,双agent才能解决复杂问题!附LangGraph+Milvus实操
2025-12-28
为什么说LangGraph是企业级AI智能体的「终极答案」?
2025-12-26
跟我学LangChain:提示词模板,PromptTemplate包装器,工程化管理你的提示词
2025-11-06
2025-12-21
2025-12-21
2025-11-25
2025-12-08
2025-11-08
2025-11-18
2025-11-07
2025-11-25
2025-11-19
2025-11-03
2025-10-29
2025-07-14
2025-07-13
2025-07-05
2025-06-26
2025-06-13
2025-05-21