From a393a5aa354369e3b90fbbcf6040668e8e39b24c Mon Sep 17 00:00:00 2001 From: N0bodycan <49983270+N0bodycan@users.noreply.github.com> Date: Tue, 9 Dec 2025 14:01:30 +0800 Subject: [PATCH] fix: fix infinite retry loop in async_chat_streamly when success The original code continues the retry loop even after a successful response. --- rag/llm/chat_model.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py index f3f207eb2..8a2743866 100644 --- a/rag/llm/chat_model.py +++ b/rag/llm/chat_model.py @@ -187,6 +187,9 @@ class Base(ABC): ans = delta_ans total_tokens += tol yield ans + + yield total_tokens + return except Exception as e: e = await self._exceptions_async(e, attempt) if e: @@ -194,8 +197,6 @@ class Base(ABC): yield total_tokens return - yield total_tokens - def _length_stop(self, ans): if is_chinese([ans]): return ans + LENGTH_NOTIFICATION_CN