From d13ce36bc9c2edd75a7115e32a2c7d0587c40894 Mon Sep 17 00:00:00 2001 From: zstar <65890619+zstar1003@users.noreply.github.com> Date: Thu, 5 Jun 2025 09:33:46 +0800 Subject: [PATCH] =?UTF-8?q?refactor(write):=20=E5=A2=9E=E5=8A=A0=E5=BB=B6?= =?UTF-8?q?=E8=BF=9F=EF=BC=8C=E5=AE=9E=E7=8E=B0=E5=9B=BE=E7=89=87=E7=9A=84?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 write_dialog 函数末尾添加 0.1 秒的延迟 - 确保缓冲区在数据传输时能够及时 flush 出去 --- api/db/services/write_service.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/db/services/write_service.py b/api/db/services/write_service.py index 46b934a..b6243b6 100644 --- a/api/db/services/write_service.py +++ b/api/db/services/write_service.py @@ -1,3 +1,4 @@ +import time from api.db import LLMType, ParserType from api.db.services.knowledgebase_service import KnowledgebaseService from api.db.services.llm_service import LLMBundle @@ -83,6 +84,7 @@ def write_dialog(question, kb_ids, tenant_id, similarity_threshold, keyword_simi image_markdowns.append(f"\n![{img_url}]({img_url})") if image_markdowns: - final_answer += "".join(image_markdowns) + "123223" - print("追加后的答案:", final_answer) + final_answer += "".join(image_markdowns) yield {"answer": final_answer, "reference": {}} + + time.sleep(0.1) # 增加延迟,确保缓冲区 flush 出去