146 lines
4.1 KiB
Markdown
146 lines
4.1 KiB
Markdown
# bbav5 项目总规划
|
||||
|
|
|
|||
|
|
## 项目目标
|
|||
|
|
将 bbav20311 迁移到 LangGraph 框架,实现 9 个 Agent 的图结构编排
|
|||
|
|
|
|||
|
|
## 当前状态
|
|||
|
|
- 项目路径: `/home/xia-lab/wutx/00test/bbav5`
|
|||
|
|
- 端口: 7867 ✅ 服务运行中
|
|||
|
|
- RAG端口: 8001 ✅ 服务运行中
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 任务清单
|
|||
|
|
|
|||
|
|
### Phase 1: 项目初始化 ✅
|
|||
|
|
- [x] 复制项目(排除 input/workspace)
|
|||
|
|
- [x] 修改端口 7865 → 7867
|
|||
|
|
- [x] 修改 RAG 端口 8000 → 8001
|
|||
|
|
- [x] 更新项目路径 bbav20311 → bbav5
|
|||
|
|
- [x] 添加 DiscoveryAgent(9个Agent)
|
|||
|
|
|
|||
|
|
### Phase 2: 代码清理 ✅
|
|||
|
|
- [x] 删除测试文件(test_*.py)
|
|||
|
|
- [x] 删除 demo 文件
|
|||
|
|
- [x] 保留微信集成文件(wechat_*.py)
|
|||
|
|
- [x] 删除旧 RAG 实现(kb/)
|
|||
|
|
- [x] 删除备份文件(backup/, *.bak, *.backup.*)
|
|||
|
|
- [x] 删除实验性代码(langchain_agent.py)
|
|||
|
|
- [x] 删除日志文件(logs/, *.log)
|
|||
|
|
- [x] 删除修订记录(REVISION_*.md)
|
|||
|
|
- [x] 保留文档(项目记录/, codeMiaoshu/)
|
|||
|
|
|
|||
|
|
### Phase 3: LangGraph 迁移 ✅
|
|||
|
|
- [x] 安装 langgraph 依赖 (0.2.0)
|
|||
|
|
- [x] 设计 StateGraph 结构
|
|||
|
|
- [x] 创建 LangGraphOrchestrator 类
|
|||
|
|
- [x] 实现 9 个 Agent 节点
|
|||
|
|
- [x] 构建条件边和路由
|
|||
|
|
- [x] 更新 apps/web/vue3/main.py 使用新的 LangGraphOrchestrator
|
|||
|
|
- [x] 保留原 orchestrator.py 作为参考
|
|||
|
|
- [x] 调整 RAG 集成(gene-family-mas-v2 端口 8001)
|
|||
|
|
|
|||
|
|
### Phase 4: 测试验证 ✅
|
|||
|
|
- [x] RAG 服务启动(gene-family-mas-v2 端口 8001)
|
|||
|
|
- [x] KnowledgeAgent 单测通过
|
|||
|
|
- [x] LangGraph Orchestrator FAQ 流程测试通过
|
|||
|
|
- [x] bbav5 服务启动(端口 7867)
|
|||
|
|
- [x] API 测试通过(/api/agent/chat)
|
|||
|
|
- [ ] 前端页面测试
|
|||
|
|
- [ ] 完整分析流程测试(ANALYSIS 模式)
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 9 个 Agent 清单
|
|||
|
|
1. RouterAgent - 意图路由 ✅
|
|||
|
|
2. PlanningAgent - 任务规划 ✅
|
|||
|
|
3. ExecutionAgent - 任务执行 ✅
|
|||
|
|
4. KnowledgeAgent - 知识检索(RAG)✅
|
|||
|
|
5. DiagnosisAgent - 错误诊断 ✅
|
|||
|
|
6. ValidatorAgent - 结果验证 ✅
|
|||
|
|
7. ResultParserAgent - 结果解析 ✅
|
|||
|
|
8. LearningAgent - 学习优化 ✅
|
|||
|
|
9. DiscoveryAgent - 科学发现(新增)✅
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## LangGraph 工作流图
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
Router -> [条件分支]
|
|||
|
|
├── FAQ/CONSULTATION/INTERPRETATION -> Knowledge -> END ✅ 已测试
|
|||
|
|
└── ANALYSIS -> Planning -> Execution -> Validator
|
|||
|
|
├── 失败 -> Diagnosis -> [重试/结束]
|
|||
|
|
└── 成功 -> ResultParser -> Discovery -> Learning -> END
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 测试结果
|
|||
|
|
|
|||
|
|
### ✅ API 测试 (FAQ 模式)
|
|||
|
|
```bash
|
|||
|
|
curl http://localhost:7867/api/agent/chat \
|
|||
|
|
-X POST \
|
|||
|
|
-H "Content-Type: application/json" \
|
|||
|
|
-d '{"message": "什么是SPL基因家族", "model": "kimi"}'
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**响应:**
|
|||
|
|
```json
|
|||
|
|
{
|
|||
|
|
"success": true,
|
|||
|
|
"intent": {
|
|||
|
|
"stage": "identify",
|
|||
|
|
"taskType": "faq",
|
|||
|
|
"params": {},
|
|||
|
|
"confidence": 0.9,
|
|||
|
|
"message": "处理完成"
|
|||
|
|
},
|
|||
|
|
"model_used": "kimi",
|
|||
|
|
"session_id": "test_api_007",
|
|||
|
|
"mode": "langgraph",
|
|||
|
|
"current_agent": "knowledge"
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### ✅ RAG 集成测试
|
|||
|
|
```
|
|||
|
|
查询: "什么是SPL基因家族的功能?"
|
|||
|
|
回答: 找到 5 条相关文献。涉及物种: Arabidopsis。涉及基因家族: NAC, SPL。
|
|||
|
|
来源: Arabidopsis_SPL_2010, Arabidopsis_SPL_2025_Hortic_Res 等
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 服务状态
|
|||
|
|
|
|||
|
|
| 服务 | 端口 | 状态 |
|
|||
|
|
|------|------|------|
|
|||
|
|
| bbav5 | 7867 | ✅ 运行中 |
|
|||
|
|
| gene-family-mas-v2 | 8001 | ✅ 运行中 |
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 下一步任务
|
|||
|
|
**Phase 4 完成: 最终验证**
|
|||
|
|
|
|||
|
|
可选执行:
|
|||
|
|
1. 前端页面测试(浏览器访问 http://localhost:7867)
|
|||
|
|
2. 完整分析流程测试(ANALYSIS 模式,需要配置 LLM API Key)
|
|||
|
|
3. 微信集成测试
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 修订记录
|
|||
|
|
| 时间 | 任务 | 状态 |
|
|||
|
|
|------|------|------|
|
|||
|
|
| 2026-04-12 11:37 | Phase 1 完成 | ✅ |
|
|||
|
|
| 2026-04-12 11:47 | 添加 DiscoveryAgent | ✅ |
|
|||
|
|
| 2026-04-12 12:07 | Phase 2 代码清理完成 | ✅ |
|
|||
|
|
| 2026-04-12 12:15 | LangGraph 编排器创建完成 | ✅ |
|
|||
|
|
| 2026-04-12 12:25 | 更新 main.py 使用 LangGraphOrchestrator | ✅ |
|
|||
|
|
| 2026-04-12 12:35 | RAG 服务启动,KnowledgeAgent 测试通过 | ✅ |
|
|||
|
|
| 2026-04-12 12:40 | LangGraph Orchestrator FAQ 流程测试通过 | ✅ |
|
|||
|
|
| 2026-04-12 12:50 | bbav5 服务启动,API 测试通过 | ✅ |
|