This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user