From 75b24ba02adccdb1c5d3be263adcfb666ace05a5 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Tue, 6 May 2025 19:30:00 +0800 Subject: [PATCH] Fix: chat solo issue. (#7479) ### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/db/services/dialog_service.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/db/services/dialog_service.py b/api/db/services/dialog_service.py index d2efd559e..c98756ae1 100644 --- a/api/db/services/dialog_service.py +++ b/api/db/services/dialog_service.py @@ -109,6 +109,7 @@ def chat_solo(dialog, messages, stream=True): msg = [{"role": m["role"], "content": re.sub(r"##\d+\$\$", "", m["content"])} for m in messages if m["role"] != "system"] if stream: last_ans = "" + delta_ans = "" for ans in chat_mdl.chat_streamly(prompt_config.get("system", ""), msg, dialog.llm_setting): answer = ans delta_ans = ans[len(last_ans) :] @@ -116,6 +117,7 @@ def chat_solo(dialog, messages, stream=True): continue last_ans = answer yield {"answer": answer, "reference": {}, "audio_binary": tts(tts_mdl, delta_ans), "prompt": "", "created_at": time.time()} + delta_ans = "" if delta_ans: yield {"answer": answer, "reference": {}, "audio_binary": tts(tts_mdl, delta_ans), "prompt": "", "created_at": time.time()} else: