deer-flow icon indicating copy to clipboard operation
deer-flow copied to clipboard

输出是event_data 应该是AIMessagechunk 类型的 但是我的 event_data 输出的是AIMessage类型的 不是分块流式输出 作者这是怎么回事

Open CmyLjj opened this issue 3 months ago • 2 comments

以下是我重构的原始部分代码
async for agent, mode, event_data in graph.astream(
input=initial_state, config={ "thread_id": thread_id, "max_plan_iterations": max_plan_iterations, "max_step_num": max_step_num,
}, stream_mode=["updates", "custom", "messages"], #stream_mode=["values"], subgraphs=True ): print("event_data**:",event_data)

CmyLjj avatar Sep 13 '25 08:09 CmyLjj

你提供的上下文信息十分很有限,读了好几遍没有明白你说的意思。 有关chunck message的单元测试 你可以参考一下https://github.com/bytedance/deer-flow/blob/main/tests/unit/checkpoint/test_checkpoint.py#L120 ,复现一下错误。

WillemJiang avatar Sep 13 '25 12:09 WillemJiang

你的LLM模型支持stream模式么,我这样是可以的,langgraph版本 0.5.4

async def chat_with_agent_with_astream_with_messages_mode():
    agent = create_react_agent(
        model=model,
        tools=[get_weather_with_message],
        prompt="你是一名助手,帮忙解决用户问题"
    )

    async for mode, chunk in agent.astream(
        {"messages": [{"role": "user", "content": "北京的天气怎么样"}]},
        stream_mode=["messages"] # custom模式会输出用户自定义的流式输出内容, updates模式会输出每个节点的输出内容
    ):
        print(chunk)
        print("\n")

asyncio.run(chat_with_agent_with_astream_with_messages_mode())

以下是我重构的原始部分代码 async for agent, mode, event_data in graph.astream( input=initial_state, config={ "thread_id": thread_id, "max_plan_iterations": max_plan_iterations, "max_step_num": max_step_num, }, stream_mode=["updates", "custom", "messages"], #stream_mode=["values"], subgraphs=True ): print("event_data**:",event_data)

Fancy-hjyp avatar Sep 16 '25 12:09 Fancy-hjyp