Files

61 lines
2.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Step 03: 构建简单 Agent
## 🎯 学习目标
- 理解什么是 Agent(代理)
- 理解 Agent 的核心循环:思考 → 行动 → 观察
- 学会构建一个完整的 Agent
- 理解 LangGraph 的基本用法
---
## 📖 概念讲解
### 什么是 Agent
**Agent = LLM + Tool + Loop**
```
Agent 工作流程:
┌─────────────────────────────────────┐
│ │
│ ┌───────────┐ │
│ │ 思考 │ ◀────────────────┼── LLM 决定
│ └─────┬─────┘ │ 要执行什么
│ │ │
│ ▼ │
│ ┌───────────┐ ┌─────────┐ │
│ │ 行动 │───▶│ 执行工具 │ │
│ └───────────┘ └────┬────┘ │
│ │ │
│ ▼ │
│ ┌─────────┐ │
│ │ 观察结果 │ │
│ └────┬────┘ │
│ │ │
└──────────────────────────┼────────┘
┌───────────────┼───────────────┐
│ │ │
▼ ▼ ▼
继续思考 结束 结束
```
### Agent 的核心循环
```
while True:
1. Think(思考):LLM 分析当前状态,决定下一步行动
2. Act(行动):执行工具或返回结果
3. Observe(观察):获取执行结果,更新状态
如果决定结束 → break
```
---
## 💻 代码实现
请打开 `concept.py` 查看详细代码注释。