This commit is contained in:
@@ -302,12 +302,18 @@ 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] 收到自定义推理事件")
|
||||
# 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),
|
||||
@@ -322,6 +328,13 @@ class AIAgentService:
|
||||
"type": "custom",
|
||||
"data": serialized_data
|
||||
}
|
||||
else:
|
||||
# 处理其他自定义事件
|
||||
serialized_data = self._serialize_value(custom_data)
|
||||
processed_event = {
|
||||
"type": "custom",
|
||||
"data": serialized_data
|
||||
}
|
||||
|
||||
if processed_event:
|
||||
yield processed_event
|
||||
|
||||
Reference in New Issue
Block a user