From 7160b7a18b9ffab3844d3ad242da4aebb8ee1f5d Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 24 Nov 2025 15:04:15 +0800 Subject: [PATCH] fix: dify workflow streaming mode --- astrbot/core/agent/runners/dify/dify_agent_runner.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/astrbot/core/agent/runners/dify/dify_agent_runner.py b/astrbot/core/agent/runners/dify/dify_agent_runner.py index c586cc550..1b7642266 100644 --- a/astrbot/core/agent/runners/dify/dify_agent_runner.py +++ b/astrbot/core/agent/runners/dify/dify_agent_runner.py @@ -215,6 +215,7 @@ class DifyAgentRunner(BaseAgentRunner[TContext]): files=files_payload, timeout=self.timeout, ): + logger.debug(f"dify workflow resp chunk: {chunk}") match chunk["event"]: case "workflow_started": logger.info( @@ -224,6 +225,16 @@ class DifyAgentRunner(BaseAgentRunner[TContext]): logger.debug( f"Dify 工作流节点(ID: {chunk['data']['node_id']} Title: {chunk['data'].get('title', '')})运行结束。" ) + case "text_chunk": + if self.streaming and chunk["data"]["text"]: + yield AgentResponse( + type="streaming_delta", + data=AgentResponseData( + chain=MessageChain().message( + chunk["data"]["text"] + ) + ), + ) case "workflow_finished": logger.info( f"Dify 工作流(ID: {chunk['workflow_run_id']})运行结束"