主要修复: 1. 修复 RAG 推理无限循环问题(大小写不匹配 + 缺少已检索结果检查) 2. 修复 intent_classifier.py 的绝对导入错误 3. 删除旧的 start.sh 脚本,添加新的启动脚本 4. 优化路由逻辑和状态管理
This commit is contained in:
@@ -132,8 +132,17 @@ class ReactIntentReasoner:
|
||||
|
||||
# 关键修改:不要在第一次 rag_retrieve 后就直接回答,允许再推理一次
|
||||
# 让推理逻辑有机会判断 RAG 结果好不好,要不要再检索或转 web search
|
||||
rag_count = previous_actions.count("rag_retrieve")
|
||||
previous_actions = context.get("previous_actions", [])
|
||||
rag_count = previous_actions.count("RETRIEVE_RAG") # 修复:大写
|
||||
web_search_count = previous_actions.count("web_search")
|
||||
retrieved_docs = context.get("retrieved_docs", [])
|
||||
|
||||
# 如果已经有检索文档了,直接回答
|
||||
if retrieved_docs and len(retrieved_docs) > 0:
|
||||
result.action = ReasoningAction.DIRECT_RESPONSE
|
||||
result.confidence = 0.95
|
||||
result.reasoning = "已获取检索文档,直接回答"
|
||||
return result
|
||||
|
||||
# 只有当 rag 或 web search 已经超过 1 次,或者已经有推理在 rag 之后,才直接回答
|
||||
if rag_count >= 2 or web_search_count >= 1:
|
||||
|
||||
Reference in New Issue
Block a user