Shell 执行 · 流式输出 · RAG 知识库 · 多 Agent 协作 · 持久记忆 · Web UI
📘 前置基础:Agent Builder —— 6 步入门版,从 LLM 调用到插件系统。建议先学基础版再学 Pro。 Pro 版假设你已经理解 Agent 的四块拼图(大脑/手脚/记忆/循环),直接上实战能力。
| 基础版 | Pro 版 |
|---|---|
| 只能在聊天里"问答" | ✅ 执行终端命令(ls / cat / git) |
| 回复一下子全出来 | ✅ 逐字流式输出(像 ChatGPT) |
| 只能聊当前对话 | ✅ 关掉重开还能续聊(SQLite) |
| 不知道你文件里有啥 | ✅ RAG 检索增强(读你的文档回答问题) |
| 只有一个 Agent | ✅ 多个 Agent 分工协作 |
| 命令行黑窗口 | ✅ Gradio Web 聊天界面 |
| # | 文件 | 学什么 | 核心技能 |
|---|---|---|---|
| P1 | step_p1_shell_executor.py |
安全执行 Shell 命令 | subprocess、白名单沙箱 |
| P2 | step_p2_streaming.py |
SSE 流式逐字输出 | 异步生成器、yield |
| P3 | step_p3_rag.py |
文档向量化 + 语义检索 | sentence-transformers、余弦相似度 |
| P4 | step_p4_multi_agent.py |
多 Agent 分工协作 | 流水线模式、Agent 间通信 |
| P5 | step_p5_persistent_memory.py |
SQLite 持久化记忆 | sqlite3、会话恢复 |
| P6 | step_p6_web_ui.py |
Gradio 聊天界面 | 前后端分离、一键部署 |
| P7 | step_p7_full_pro.py |
组装完整 Pro Agent | 全部组件 + Web UI |
git clone https://github.com/yourusername/agent-builder-pro.git
cd agent-builder-pro
pip install -r requirements.txt
# 💡 报错了?→ TROUBLESHOOTING.md
export OPENAI_API_KEY="sk-你的key"
export OPENAI_BASE_URL="https://api.deepseek.com/v1" # 可选
# 按顺序跑
python step_p1_shell_executor.py
python step_p2_streaming.py
# ...
python step_p7_full_pro.py # 最终成品:Web 界面 + 全部能力agent-builder-pro/
├── README.md
├── ARCHITECTURE.md ← 深度架构
├── CHEATSHEET.md ← 速查表
├── requirements.txt
├── LICENSE
├── .gitignore
│
├── step_p1_shell_executor.py ← Shell 安全执行
├── step_p2_streaming.py ← 流式输出
├── step_p3_rag.py ← RAG 检索增强
├── step_p4_multi_agent.py ← 多 Agent 协作
├── step_p5_persistent_memory.py ← 持久化记忆
├── step_p6_web_ui.py ← Gradio Web UI
├── step_p7_full_pro.py ← 完整 Pro Agent
│
├── tools/ ← 进阶工具模块
├── agents/ ← 多 Agent 角色定义
├── memory/ ← 持久化记忆(SQLite + 向量)
├── plugins/ ← 插件系统
├── exercises/ ← 配套练习
└── outputs/ ← 运行示例
MIT © 2026