跳转至

Agent(智能体)

ReAct / Function Calling / 多 Agent 协作

Agent 核心循环

Text Only
感知(Observe) → 推理(Think) → 行动(Act) → 观察(Observe) → ...

Agent 模式

模式 论文 说明
ReAct arXiv:2210.03629 推理+行动交替
Plan-and-Solve arXiv:2305.04091 先规划再执行
Reflexion arXiv:2303.11366 自我反思纠错
AutoGPT 模式 自主目标分解

Function Calling / Tool Use

  • LLM 输出工具调用请求(函数名 + 参数)
  • 执行器执行工具,返回结果
  • LLM 根据结果继续推理或生成回答
Text Only
1
2
3
User Query → LLM → Tool Call (search_api, "weather in Beijing")
           ← Tool Result ← "Beijing: 25°C, sunny"
           → LLM → Final Answer: "北京今天25°C,晴天"

多 Agent 协作

模式 说明
编排者模式 一个 Agent 调度其他 Agent
辩论模式 多个 Agent 讨论达成共识
流水线模式 Agent 按流程顺序处理
层级模式 管理者 → 专家 Agent

框架

框架 链接 特点
LangChain https://python.langchain.com/docs/ Agent + 工具生态
LangGraph https://github.com/langchain-ai/langgraph 状态图 Agent,更灵活
CrewAI https://github.com/crewAIInc/crewAI 多 Agent 协作,角色扮演
AutoGen https://github.com/microsoft/autogen 微软多 Agent 对话
MetaGPT https://github.com/geekan/MetaGPT 多 Agent 软件开发

练习

  • 实现 ReAct Agent,能搜索+计算
  • 实现 Function Calling,连接天气 API + 数据库查询
  • 用 CrewAI 构建多 Agent 协作任务
  • 用 LangGraph 构建有状态的多步骤 Agent

资源

资源 链接
ReAct 论文 https://arxiv.org/abs/2210.03629
Lilian Weng Agent 博客 https://lilianweng.github.io/posts/2023-06-23-agent/
LangChain Agent 文档 https://python.langchain.com/docs/concepts/agents/
HuggingFace Agents Course https://huggingface.co/learn/agents-course