This commit is contained in:
@@ -130,12 +130,16 @@ class ReactIntentReasoner:
|
||||
retrieved_docs = context.get("retrieved_docs", [])
|
||||
messages = context.get("messages", [])
|
||||
|
||||
# 关键修复 2:如果已经有 rag_context 或 web_search_results(通过 messages 推断),直接回答
|
||||
# 检查是否已经执行过 rag_retrieve 或 web_search
|
||||
if "rag_retrieve" in previous_actions or "web_search" in previous_actions:
|
||||
# 关键修改:不要在第一次 rag_retrieve 后就直接回答,允许再推理一次
|
||||
# 让推理逻辑有机会判断 RAG 结果好不好,要不要再检索或转 web search
|
||||
rag_count = previous_actions.count("rag_retrieve")
|
||||
web_search_count = previous_actions.count("web_search")
|
||||
|
||||
# 只有当 rag 或 web search 已经超过 1 次,或者已经有推理在 rag 之后,才直接回答
|
||||
if rag_count >= 2 or web_search_count >= 1:
|
||||
result.action = ReasoningAction.DIRECT_RESPONSE
|
||||
result.confidence = 0.95
|
||||
result.reasoning = "已获取信息,直接回答"
|
||||
result.reasoning = "已获取足够信息,直接回答"
|
||||
return result
|
||||
|
||||
# 策略1:尝试使用 LLM 推理
|
||||
|
||||
Reference in New Issue
Block a user