添加自定义事件的调试日志
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m18s

This commit is contained in:
2026-05-02 09:39:18 +08:00
parent 3f6bbdec92
commit e67ec97a12

View File

@@ -302,19 +302,32 @@ class AIAgentService:
}
elif chunk_type == "custom":
info(f"🎯 处理custom chunk: {chunk['data']}")
info(f"🎯 处理custom chunk, 完整数据: {repr(chunk)}")
custom_data = chunk["data"]
info(f"🎯 custom_data 内容: {repr(custom_data)}")
info(f"🎯 custom_data 类型: {type(custom_data)}")
# 关键修复:处理我们从 react_reason_node 发送的自定义推理事件
if isinstance(custom_data, dict) and custom_data.get("type") == "react_reasoning":
info(f"[Agent Service] 收到自定义推理事件")
yield {
"type": "react_reasoning",
"step": custom_data.get("step", 1),
"action": custom_data.get("action", "unknown"),
"confidence": custom_data.get("confidence", 0),
"reasoning": custom_data.get("reasoning", "")
}
# LangGraph 的 adispatch_custom_event 发送的事件格式:
# chunk["data"] 是我们传的第二个参数dict
if isinstance(custom_data, dict):
# 检查是否是我们的推理事件
if "action" in custom_data and "reasoning" in custom_data:
info(f"[Agent Service] 收到自定义推理事件: {custom_data}")
yield {
"type": "react_reasoning",
"step": custom_data.get("step", 1),
"action": custom_data.get("action", "unknown"),
"confidence": custom_data.get("confidence", 0),
"reasoning": custom_data.get("reasoning", "")
}
else:
# 处理其他自定义事件
serialized_data = self._serialize_value(custom_data)
processed_event = {
"type": "custom",
"data": serialized_data
}
else:
# 处理其他自定义事件
serialized_data = self._serialize_value(custom_data)