推理优化
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m36s

This commit is contained in:
2026-05-06 04:26:06 +08:00
parent 1260bef5cb
commit ef6fbc1521
12 changed files with 313 additions and 129 deletions

View File

@@ -21,7 +21,7 @@ from .nodes.fast_paths import (
fast_tool_node,
)
from .nodes.llm_call import create_dynamic_llm_call_node
from .nodes.rag_nodes import rag_retrieve_node, check_rag_confidence
from .nodes.rag_nodes import rag_retrieve_node
from .nodes.retrieve_memory import create_retrieve_memory_node
from .nodes.memory_trigger import memory_trigger_node, set_mem0_client
from .nodes.summarize import create_summarize_node
@@ -164,7 +164,7 @@ def _add_routing_edges(graph: StateGraph, use_hybrid_router: bool, llm_node) ->
}
)
# 快速路径的完成检查
# 快速路径的完成检查fast_rag 失败直接走 react_reason
for fast_node in ["fast_chitchat", "fast_rag", "fast_tool"]:
graph.add_conditional_edges(
fast_node,
@@ -198,17 +198,8 @@ def _add_react_loop_edges(graph: StateGraph, subgraph_nodes: Dict[str, Any]) ->
}
)
# RAG 检索后的置信度判断分支
graph.add_conditional_edges(
"rag_retrieve",
check_rag_confidence,
{
"high_confidence": "llm_call", # 高置信度 → 直接生成回答
"retry_rag": "rag_retrieve", # 低置信度 → 再次检索
"low_confidence": "web_search", # 两次RAG后仍低 → 联网搜索
"no_rag": "web_search", # 无结果 → 联网搜索
}
)
# RAG 检索后回到 react_reason由意图识别决定下一步
graph.add_edge("rag_retrieve", "react_reason")
# 循环边(回到 react_reason
loop_back_nodes = ["web_search", "handle_error"] + subgraph_names