From 6284a74a6ec0b17bb39f70378b969c8f6af891be Mon Sep 17 00:00:00 2001 From: haotian Date: Mon, 14 Apr 2025 21:43:55 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E4=BF=AE=E5=A4=8DDify=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5=E6=9C=AA=E8=BF=87=E6=BB=A4=E5=85=A8=E9=87=8F=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/providers/llm/dify/dify.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/xiaozhi-server/core/providers/llm/dify/dify.py b/main/xiaozhi-server/core/providers/llm/dify/dify.py index 26bb48b7..030aba05 100644 --- a/main/xiaozhi-server/core/providers/llm/dify/dify.py +++ b/main/xiaozhi-server/core/providers/llm/dify/dify.py @@ -58,7 +58,8 @@ class LLMProvider(LLMProviderBase): self.session_conversation_map[session_id] = ( conversation_id # 更新映射 ) - if event.get("answer"): + # 过滤 message_replace 事件,此事件会全量推一次 + if event.get("event") != "message_replace" and event.get("answer"): yield event["answer"] elif self.mode == "workflows/run": for line in r.iter_lines(): @@ -73,7 +74,8 @@ class LLMProvider(LLMProviderBase): for line in r.iter_lines(): if line.startswith(b"data: "): event = json.loads(line[6:]) - if event.get("answer"): + # 过滤 message_replace 事件,此事件会全量推一次 + if event.get("event") != "message_replace" and event.get("answer"): yield event["answer"] except Exception as e: