添加rag置信度判断
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m31s

This commit is contained in:
2026-05-06 01:15:52 +08:00
parent 3ae9daa01a
commit 1260bef5cb
35 changed files with 335 additions and 221 deletions

View File

@@ -10,9 +10,9 @@
from datetime import datetime
from ...core.intent import get_route_by_reasoning, ReasoningAction
from backend.app.core.intent import get_route_by_reasoning, ReasoningAction
from ...main_graph.state import MainGraphState
from ...logger import info
from backend.app.logger import info
# ========== 初始化状态节点 ==========
@@ -97,6 +97,12 @@ def route_by_reasoning(state: MainGraphState) -> str:
}
target = route_mapping.get(route, "llm_call")
# ========== RAG 次数硬限制 ==========
rag_attempts = getattr(state, 'rag_attempts', 0)
if target == "rag_retrieve" and rag_attempts >= 2:
info(f"[条件路由] RAG已尝试{rag_attempts}次,强制走联网搜索")
target = "web_search"
# ========== 循环防护检测 ==========
# 1. 路由模式检测A→B→A→B 交替)
if len(previous_actions) >= 4: