|
|
846380879b
|
fix(langchain-chat): R1 思考过程显示 + 选题推荐放宽 + RAG 诊断日志
三个独立修复 / 排查:
1. R1 思考过程不显示
- 根因: chat_test.py 等 <think> 开标签出现才进思考态,但 R1
流式输出本来就在 reasoning 态启动,永远不出 <think>,所有
reasoning 全部当 text 走到答案区
- 修法: 引入 r1_thinking_done 状态机,默认在思考态,
看到 </think> 切换;R1-70B 直连本地代理 deepseek-r1
(官方 deepseek-reasoner 把 reasoning 放独立字段,旧版
callback 取不到)
- 结果验证: "1+1" → 269 think + 40 text,思考与答案正确分流
2. 选题推荐场景拒答 + chat 模板标记泄漏
- 根因: prompt 写死了 "你只能回答有关选题推荐的问题"
+ 直接嵌入 <|im_start|>/<|im_end|> Qwen chat 标记
- 修法: 改写 Topic Recommend Assistant prompt,删 chat 标记,
行为准则改为"沾边查询用工具回答";agent_v2 增加 strip
防守层
- 结果验证: "钢铁行业研究重点方向" → agent 调工具,不再拒答
3. 知识库召回 0 排查(数据问题,未根治)
- 根因: kb_config.py 把所有 KB(政策库/钢铁库/报告库等)
都映射到 t_policy_total_bge_new_v2,但 Milvus 里根本没有
这个 collection(实际只有 11 个 p_* 个人库 + 1 个
t_journal_article_bge_v1)
- 临时改: search_tool.py 加诊断日志 [RAG诊断] 输出每个 KB
召回数;rag_search 内 for 循环里首个 KB 空就 return 的
bug 改 continue
- 待决策: kb_config 是否把默认 KB 映射到唯一存在的
t_journal_article_bge_v1,或重建对应集合
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-07 15:44:05 +08:00 |
|
|
|
316def2145
|
feat(langchain-chat): LangGraph 重写 agent 内核
主要变化:
- 新增 agent_v2.py: 用 LangGraph create_react_agent + astream_events
替代原 agent_chat_test 的 LLM step-routing 死循环
- 新增 tools_v2.py: 闭包工厂模式,每个请求按 uuid 生成工具列表,
消除 toolinput 字符串拼 JSON 注入 uuid 的旧 hack
- chat_test.py:266-346: 删 11 次 count_process 重试外层和事件
分发 spaghetti,换成 agent_run 单次调用 + 简单事件 dispatcher
- policy_fun_iast.py:168-187: 修 broken <think> filter
老代码把 start_flag 设反了(看见 <think> 才开始 yield)导致
非 think 模型 yield 不出任何内容;改为正确跳过 <think>...</think> 块
模型函数调用通过 langchain_openai.ChatOpenAI(不能用旧版
langchain_community.chat_models.ChatOpenAI,没有现代 tool calling)。
依赖: langgraph==0.0.49 + langchain-core==0.1.53(已在服务器装好)。
非 stream 分支保留旧 agent_chat_test 路径(极少触发,回归风险低)。
旧版回滚: git checkout backup/pre-langgraph
实测对比:
- 旧版 30-60s,答案 0 字(filter 卡死后展示 11 次重试)
- 新版 25-40s,答案完整(含工具调用、参考文献、推荐问题、摘要)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-07 15:20:00 +08:00 |
|
|
|
911f7adee6
|
checkpoint: 重写 langchain agent 前的快照
包含未合入 main 的工作:
- CAS 单点登录接入 (CasSecurityConfig + 4 个 CAS 类)
- LoginController 改 POST + body, 修 URL 密码暴露
- chat_test.py 修 texts→text typo
- 前端外部系统侧边栏 + login API POST
- gateway-nginx.conf
下一步: 从这个分支拉 feat/langgraph-rewrite 做 langchain-chat agent 重写
回滚点: git checkout backup/pre-langgraph
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-05-07 14:58:53 +08:00 |
|
|
|
87e571d9ec
|
[全量] 初始化项目代码、配置、文档及Agent协同harness
|
2026-04-02 11:36:05 +08:00 |
|