重构:移除对 debug_info 的依赖,只使用新的结构化状态字段
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
This commit is contained in:
@@ -44,9 +44,6 @@ async def fast_chitchat_node(state: MainGraphState, config: Optional[RunnableCon
|
||||
# 标记快速路径成功,但不设置 final_result,让 llm_call 生成回答
|
||||
state.success = True
|
||||
state.current_phase = "llm_call"
|
||||
state.debug_info["fast_chitchat_success"] = True
|
||||
|
||||
# 更新新的结构化字段
|
||||
state.fast_path.chitchat_success = True
|
||||
|
||||
# 发送完成事件
|
||||
@@ -168,7 +165,7 @@ async def _generate_fast_answer(state: MainGraphState, query: str) -> MainGraphS
|
||||
state.final_result = full_content
|
||||
state.success = True
|
||||
state.current_phase = "finalizing"
|
||||
state.debug_info["fast_rag_success"] = True
|
||||
state.fast_path.rag_success = True
|
||||
return state
|
||||
|
||||
except Exception as e:
|
||||
@@ -181,8 +178,8 @@ async def fast_tool_node(state: MainGraphState, config: Optional[RunnableConfig]
|
||||
"""快速工具节点"""
|
||||
state.current_phase = "fast_tool"
|
||||
|
||||
decision = state.debug_info.get("hybrid_decision", {})
|
||||
suggested_tools = decision.get("suggested_tools", [])
|
||||
decision = state.hybrid_router.decision
|
||||
suggested_tools = decision.suggested_tools if (decision and hasattr(decision, 'suggested_tools')) else []
|
||||
info(f"[Fast Tool] 开始处理,建议工具: {suggested_tools}")
|
||||
|
||||
await dispatch_custom_event("fast_path_start", {"path": "fast_tool", "suggested_tools": suggested_tools}, config)
|
||||
@@ -197,16 +194,23 @@ async def fast_tool_node(state: MainGraphState, config: Optional[RunnableConfig]
|
||||
return _mark_fast_path_failed(state, "快速工具调用暂未完善")
|
||||
|
||||
|
||||
# ========== 条件路由函数 ==========
|
||||
def check_fast_path_success(state: MainGraphState) -> str:
|
||||
"""检查快速路径是否成功 - 使用新的结构化字段"""
|
||||
if state.fast_path.failed:
|
||||
info("[Fast Path Check] 快速路径失败,升级到 React 循环")
|
||||
return "escalate"
|
||||
|
||||
info("[Fast Path Check] 快速路径成功,进入 llm_call")
|
||||
return "llm_call"
|
||||
|
||||
|
||||
# ========== 公共函数 ==========
|
||||
def _mark_fast_path_failed(state: MainGraphState, reason: str = "") -> MainGraphState:
|
||||
"""标记快速路径失败,准备升级到 React 循环"""
|
||||
state.debug_info["fast_path_failed"] = True
|
||||
state.debug_info["fast_path_fail_reason"] = reason
|
||||
state.success = False
|
||||
|
||||
# 更新新的结构化字段
|
||||
"""标记快速路径失败,准备升级到 React 循环 - 使用新的结构化字段"""
|
||||
state.fast_path.failed = True
|
||||
state.fast_path.fail_reason = reason
|
||||
state.success = False
|
||||
|
||||
info(f"[Fast Path] 标记失败,准备升级: {reason}")
|
||||
return state
|
||||
@@ -217,5 +221,6 @@ __all__ = [
|
||||
"fast_chitchat_node",
|
||||
"fast_rag_node",
|
||||
"fast_tool_node",
|
||||
"check_fast_path_success",
|
||||
"_mark_fast_path_failed",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user