微信扫码
添加专属顾问
我要投稿
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+中大型企业
2025-11-06
LangChain v1.0正式版发布,5分钟快速上手实战
2025-11-06
LangChain重磅升级!DeepAgents 0.2带来可插拔后端,重新定义AI智能体开发
2025-11-05
LangChain 1.0 全面进化指南
2025-11-03
不再搞Chain 设计的LangChain 1.0,与LangGraph有哪些区别?
2025-11-03
构建企业级多智能体系统:精通LangChain中间件框架与深度智能体架构
2025-11-02
LangChain 1.0的深度解析
2025-11-01
LangSmith+LangGraph本地化部署与离线调试全流程
2025-10-31
Spring AI Alibaba/Dify/LangGraph/LangChain 一文讲清四大AI框架怎么选
2025-09-13
2025-09-21
2025-10-19
2025-08-19
2025-11-03
2025-10-31
2025-08-17
2025-09-06
2025-10-23
2025-09-12
2025-11-03
2025-10-29
2025-07-14
2025-07-13
2025-07-05
2025-06-26
2025-06-13
2025-05-21