This commit is contained in:
@@ -21,15 +21,15 @@ 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
|
||||
from .nodes.rag_nodes import rag_retrieve_node, check_rag_confidence
|
||||
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
|
||||
from .nodes.finalize import finalize_node
|
||||
from ..subgraphs.contact import build_contact_subgraph
|
||||
from ..subgraphs.dictionary import build_dictionary_subgraph
|
||||
from ..subgraphs.news_analysis import build_news_analysis_subgraph
|
||||
from ..logger import info
|
||||
from backend.app.subgraphs.contact import build_contact_subgraph
|
||||
from backend.app.subgraphs.dictionary import build_dictionary_subgraph
|
||||
from backend.app.subgraphs.news_analysis import build_news_analysis_subgraph
|
||||
from backend.app.logger import info
|
||||
|
||||
from .subgraph_wrapper import create_subgraph_nodes
|
||||
|
||||
@@ -198,8 +198,20 @@ 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", # 无结果 → 联网搜索
|
||||
}
|
||||
)
|
||||
|
||||
# 循环边(回到 react_reason)
|
||||
loop_back_nodes = ["rag_retrieve", "web_search", "handle_error"] + subgraph_names
|
||||
loop_back_nodes = ["web_search", "handle_error"] + subgraph_names
|
||||
for node_name in loop_back_nodes:
|
||||
graph.add_edge(node_name, "react_reason")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user