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