This commit is contained in:
@@ -254,6 +254,8 @@ class AIAgentService:
|
||||
try:
|
||||
info(f"📡 开始调用 graph.astream()...")
|
||||
|
||||
event_count = 0
|
||||
|
||||
async for chunk in self.graph.astream(
|
||||
input_state,
|
||||
config=config,
|
||||
@@ -263,6 +265,10 @@ class AIAgentService:
|
||||
):
|
||||
chunk_count += 1
|
||||
chunk_type = chunk["type"]
|
||||
|
||||
# 记录原始 chunk 信息(前 10 个和后 10 个)
|
||||
if chunk_count <= 10 or chunk_count % 50 == 0:
|
||||
info(f" [{chunk_count}] chunk_type={chunk_type}, data={type(chunk.get('data'))}")
|
||||
|
||||
if chunk_type == "messages":
|
||||
async for event in self._handle_message_chunk(
|
||||
@@ -271,6 +277,11 @@ class AIAgentService:
|
||||
if event.get("type") == "_update_state":
|
||||
current_node = event.get("current_node", current_node)
|
||||
else:
|
||||
event_count += 1
|
||||
# 记录前 10 个事件
|
||||
if event_count <= 10:
|
||||
info(f" → yield event #{event_count}: {event.get('type')}")
|
||||
|
||||
# 如果是 agent 节点的 token,收集完整消息
|
||||
if (
|
||||
event.get("type") == "llm_token"
|
||||
@@ -287,10 +298,13 @@ class AIAgentService:
|
||||
if event.get("type") == "_update_state":
|
||||
actual_model_used = event.get("actual_model_used", actual_model_used)
|
||||
else:
|
||||
event_count += 1
|
||||
if event_count <= 10:
|
||||
info(f" → yield event #{event_count}: {event.get('type')}")
|
||||
yield event
|
||||
|
||||
# 完整消息集合完成后,一次性打印
|
||||
info(f"✅ graph.astream() 完成,共 {chunk_count} 个 chunks")
|
||||
info(f"✅ graph.astream() 完成,共 {chunk_count} 个 chunks, {event_count} 个 events")
|
||||
if full_message_content:
|
||||
info(f"📄 完整消息内容: {repr(full_message_content)}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user