From 21453ffff0d012044e40a2637ce5d61c456e42af Mon Sep 17 00:00:00 2001 From: dashi6174 Date: Wed, 22 May 2024 15:29:07 +0800 Subject: [PATCH] fixed: The choices may be empty. (#876) ### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/llm/chat_model.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py index a652972a2cf..9a2eec5d545 100644 --- a/rag/llm/chat_model.py +++ b/rag/llm/chat_model.py @@ -56,6 +56,7 @@ def chat_streamly(self, system, history, gen_conf): stream=True, **gen_conf) for resp in response: + if len(resp.choices) == 0:continue if not resp.choices[0].delta.content:continue ans += resp.choices[0].delta.content total_tokens += 1