160 Commits

Author SHA1 Message Date
4c119073bc 优化输出
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 6m6s
2026-05-09 01:51:18 +08:00
b30f7b00a7 优化查询代码,优化工具代码
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m33s
2026-05-08 22:30:26 +08:00
5c2380e31c feat: 适配 finalize 节点返回的 final_reply 和 metadata
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-08 02:06:29 +08:00
d16ad6185e refactor: 重构图为标准 agent/tools 分离结构 2026-05-08 01:59:19 +08:00
ef07b05c22 refactor: 重构 agent 节点为单步推理(移除 while 循环) 2026-05-08 01:48:46 +08:00
e851e40763 feat: 添加 finalize 节点实现 2026-05-08 01:45:30 +08:00
ce4d7515d9 feat: 添加 tools 节点实现
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-08 01:44:13 +08:00
527d7a0b1d feat: 添加 tool_call_history, stop, tools_used 等新状态字段
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-08 01:29:55 +08:00
6dfa9f572e 重构:清理废弃代码 + 优化 Agent 架构
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m24s
主要变更:
- 删除 deprecated 文件夹(intent/hybrid_router/rag_nodes 等)
- 删除 intent_classifier.py(未使用)
- 删除 subgraph_wrapper.py(死代码)
- 重构 agent.py:简化工厂函数,支持动态模型切换
- 重构 prompts.py:添加信息获取优先级、思维链要求、工具调用约束
- 优化 tools:统一位置,rag_search 返回置信度评估
- 新增 RAG 置信度评估:embedding(25%) + rerank(25%) + LLM(50%)
- 添加循环检测:防止工具无限重复调用

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-08 00:29:12 +08:00
a155b6e5ea 修复:调整事件格式匹配前端期望
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m30s
2026-05-07 03:15:47 +08:00
19bccc1941 修复:移除 graph_update 事件避免 JSON 序列化错误
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 6m24s
2026-05-07 03:06:12 +08:00
5b41598d50 重构:简化流式架构,将 ReAct 循环移入 agent 节点
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m41s
主要变更:
- 简化 agent_service:移除复杂双协程,只用 stream_mode=["updates"]
- stream_context:提供更清晰的 API (set_stream_queue/get_stream_queue)
- main_graph_builder:简化图结构,移除 tools 节点和条件边
- agent 节点:包含完整 ReAct 循环 + 流式 Tool Calling 拼接
- 前端:适配新的事件格式
- 添加测试文件:test_full_react_streaming.py, test_stream.py
2026-05-07 02:56:35 +08:00
eb33203b5c feat: 优化后的流式方案:双协程 + 结束哨兵 + turn/phase 元数据
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m26s
2026-05-07 02:21:09 +08:00
58a2c8c081 refactor: 改用 LangGraph 原生 create_react_agent + astream_events
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m43s
2026-05-07 02:11:20 +08:00
6d7f8758d2 feat: 实现真正的 LLM 流式 token 发送
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
2026-05-07 02:05:23 +08:00
6332e30d2f revert: 撤销假流式修改
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
2026-05-07 01:59:41 +08:00
c5ea93b754 fix: 把完整消息拆成单个字符模拟流式输出
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
2026-05-07 01:58:29 +08:00
2160dbced0 debug: 添加流式事件详细日志
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m43s
2026-05-07 01:49:40 +08:00
7bbb1bf152 debug: 给 agent 节点添加详细日志和异常捕获
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m55s
2026-05-07 01:41:51 +08:00
eca5678354 fix: 修复 __init__.py 导入旧工具的问题
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m40s
2026-05-07 01:31:06 +08:00
2d62bf956b refactor: 整理文件夹结构,修复 create_serde 导入问题
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m50s
- 移动 main_graph/tools/ 到 deprecated/main_graph_tools/(旧架构工具)
- 移动 rag_initializer.py 和 retry_utils.py 到 core/
- 清理 main_graph/nodes/ 里的旧节点到 deprecated/
- 修复 backend.py 中 create_serde 导入问题
2026-05-07 01:19:15 +08:00
22fdb625a4 feat: 完成极简 LangGraph 架构迁移,添加 Baosi API 支持
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m36s
主要变更:
- 迁移到极简 LangGraph 标准架构(START → init_state → 记忆 → Agent ⇄ Tools → finalize → END)
- 添加 Baosi API 支持,配置 ops4.7 模型
- 保留本地模型作为默认首选,Baosi 作为备选
- 新架构使用 LangGraph 原生 ToolNode 和 bind_tools
- 移除旧的混合路由、JSON 解析等复杂逻辑
- 把旧代码移到 deprecated/ 目录
- 添加新的 Agent 节点和 Tools 模块
- 添加测试脚本验证新架构
- 所有测试通过 ✓
2026-05-07 00:48:17 +08:00
5e762da740 修复导入路径:从.nodes._utils导入
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m49s
2026-05-06 19:33:59 +08:00
b80ad9519a 修复dispatch_custom_event:用config参数
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m26s
2026-05-06 19:15:30 +08:00
47e35bfd00 修复子图包装器:使用dispatch_custom_event,用ainvoke
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
2026-05-06 19:10:20 +08:00
47ccac5b35 优化:复用 hybrid_router 的推理结果,避免重复 LLM 调用
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 6m22s
2026-05-06 18:50:22 +08:00
000af774a3 优化:统一意图分类逻辑,复用 intent.py,删除冗余的 intent_classifier.py
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m44s
2026-05-06 18:41:14 +08:00
1dc1ecad62 优化: LLM降级重排一次调用给所有文档打分
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 9m56s
2026-05-06 17:25:42 +08:00
a6813a5ab0 优化: 重排前增加向量初筛,只让前20个进入重排
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 7m32s
2026-05-06 17:08:47 +08:00
d09b0d16ce 修改日志用项目统一的 logger
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 10m46s
2026-05-06 16:15:09 +08:00
13499ecf2a 添加详细日志: 在关键节点加日志以便定位卡住问题
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 6m26s
2026-05-06 16:02:53 +08:00
e70a2919dd 兼容:同时注册新旧路径到 allowed_msgpack_modules
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m49s
避免旧 checkpoint 反序列化时出现警告
2026-05-06 15:21:32 +08:00
adb25a2e22 优化:重构 state,分离持久化和临时字段,完善 init_state_node
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m37s
主要改动:
1. 移除无用字段 system_prompt
2. 重新组织 state,明确标注「持久化字段」和「临时字段」
3. 完善 init_state_node,重置所有临时字段
4. 解决数据残留隐患,确保每轮对话开始时状态干净
2026-05-06 15:10:33 +08:00
304e1318e5 重构:继续移除对 debug_info 的依赖,主要模块已完成迁移
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 7m28s
2026-05-06 14:47:51 +08:00
dceb9061e8 重构:移除对 debug_info 的依赖,只使用新的结构化状态字段
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
2026-05-06 14:45:40 +08:00
0f1691b578 修复:更新 msgpack 序列化配置,加入新的类型
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
修复问题:
1. 更新模块路径从 "app.core.intent" 到 "backend.app.core.intent"
2. 添加新的状态类型:
   - ReactReasoningState
   - HybridRouterState
   - FastPathState
3. 添加 HybridRouterResult
2026-05-06 14:36:16 +08:00
d96301e4d5 重构:增强 JSON 解析稳定性,优化 Prompt,改进状态结构
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m36s
主要改进:

1. 新增 json_parser.py - 统一的 JSON 解析工具
   - 支持多种格式(纯 JSON、markdown、文本中的 JSON)
   - 多层 fallback 策略
   - 安全的字段提取函数

2. 优化 intent.py 和 hybrid_router.py
   - 使用新的 json_parser
   - 优化 Prompt,更清晰的格式要求
   - 更好的错误处理

3. 改进 state.py - 新增结构化状态字段
   - ReactReasoningState、HybridRouterState、FastPathState
   - 向后兼容旧的 debug_info

4. 更新各节点模块 - 同时更新旧字段保持兼容
   - reasoning.py - 更新 state.react_reasoning
   - hybrid_router.py - 更新 state.hybrid_router
   - fast_paths.py - 更新 state.fast_path
2026-05-06 13:34:32 +08:00
ef6fbc1521 推理优化
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m36s
2026-05-06 04:26:06 +08:00
1260bef5cb 添加rag置信度判断
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m31s
2026-05-06 01:15:52 +08:00
3ae9daa01a 导入方式修改
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m44s
2026-05-05 23:17:00 +08:00
b5c15ef445 refactor: 单图方案重构 + 动态模型选择 + chat_services优化
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 12m9s
## 核心改动

### 1. 单图方案重构
- 删除了多图(self.graphs),改为单图(self.graph)
- 新增 MainGraphState.current_model 字段用于运行时注入模型
- llm_call 节点改为动态选择模型(create_dynamic_llm_call_node)

### 2. chat_services 优化
- 添加 _cached_services 缓存,避免重复初始化
- 新增 get_cached_chat_services() 函数,用于单图注入
- 新增 _check_http_service_available() 统一HTTP探测逻辑
- 减少重复代码,LocalVLLMChatProvider和LocalSmallModelProvider共用探测方法

### 3. AIAgentService 重构
- initialize() 只构建一次图,传入 chat_services 字典
- 新增 _resolve_model() 模型回退逻辑
- 新增 _build_invocation() 统一构建调用参数
- process_message() 和 process_message_stream() 改为注入 current_model
- 流式处理代码拆分,增加可读性

### 4. 新增和删除文件
- 新增:backend/app/main_graph/main_graph_builder.py(图构建)
- 新增:backend/app/main_graph/subgraph_wrapper.py(子图封装)
- 新增:tools/test/test_tavily_search.py(测试)
- 删除:backend/app/main_graph/graph.py(旧图)
- 删除:backend/app/main_graph/utils/main_graph_builder.py(旧构建器)
- 删除:backend/app/main_graph/utils/__init__.py

### 5. 其他更新
- README.md:新增模型服务使用情况详解章节
- backend/app/model_services/__init__.py:新增 get_cached_chat_services 导出

## 方案优势

- 内存优化:N张图 → 1张图
- 灵活性:运行时动态选择模型,支持同会话不同模型
- 性能:模型服务缓存,初始化仅一次
- 可维护性:减少重复代码,统一HTTP探测逻辑
2026-05-05 17:30:55 +08:00
8b5fbbd395 修改readme
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m35s
2026-05-05 14:06:36 +08:00
8c021c264e 修改readme
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m28s
2026-05-05 13:30:31 +08:00
128aad0c22 refactor: 重构快速路径流程,统一通过 llm_call 输出
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m31s
- 重构 fast_paths.py,让 fast_chitchat 和 fast_rag 都进入 llm_call 而不是直接设置 final_result
- 修改 check_fast_path_success 函数返回 'llm_call' 而不是 'success'
- 更新 main_graph_builder.py 的条件边配置,支持路由到 llm_call
- 在快速路径节点中添加清除 state.final_result 的逻辑,避免复用旧结果
- 重构 RAG 工具初始化方式,使用模块级变量管理
- 修改 finalize.py 让它返回 final_result
- 更新 agent_service.py 的 RAG 工具注入方式
- 简化 hybrid_router.py 的代码结构
- 清理 rag_nodes.py 的全局变量相关代码
- 更新相关测试文件
2026-05-05 04:32:42 +08:00
b64dade9e9 修复循环推理bug 2026-05-05 00:54:04 +08:00
acc8d801f3 修复代码,实现rag测试
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 6m11s
2026-05-04 20:31:04 +08:00
0543a4da8b fix: 彻底修复 RAG 无限循环问题
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m33s
关键修复:
1. rag_nodes.py: history 里记录的 action 改成大写 RETRIEVE_RAG
2. react_nodes.py: route_by_reasoning 优先检查 DIRECT_RESPONSE
3. 优化路由判断顺序,避免不必要的循环
2026-05-04 19:03:41 +08:00
c9bf21be0e fix: 修复 RAG 无限循环问题和导入错误
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
主要修复:
1. 修复 RAG 推理无限循环问题(大小写不匹配 + 缺少已检索结果检查)
2. 修复 intent_classifier.py 的绝对导入错误
3. 删除旧的 start.sh 脚本,添加新的启动脚本
4. 优化路由逻辑和状态管理
2026-05-04 18:59:15 +08:00
9841f47432 refactor: 重构RAG核心组件,简化代码结构和测试文件
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m53s
2026-05-04 17:58:10 +08:00
a07e398739 refactor!: 完全异步化 RAG 系统,移除 LangChain ParentDocumentRetriever 依赖
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m34s
- 重写 rag_core/vector_store.py:完全异步实现 aadd_documents、asimilarity_search
- 重写 app/rag/retriever.py:异步混合检索,移除同步兼容代码
- 修改 rag_indexer/index_builder.py:全链路异步调用
- 删除 rag_core/retriever_factory.py:不再使用 LangChain ParentDocumentRetriever
- 清理冗余导入和代码:移除 model_services 兼容、不需要的异常导入
- 更新 rag_indexer/README.md:反映新架构

核心改进:
- 完全异步化:索引构建和检索全链路 async/await
- 自定义实现:不再依赖 LangChain 的 ParentDocumentRetriever
- 双向量支持:子文档同时存储 dense + sparse 向量到 Qdrant
- 架构清晰:rag_core 公共组件、rag_indexer 索引、app/rag 检索
2026-05-04 14:33:12 +08:00