From d99f03e4f3ae6d85f6b0e2b69433bb5121a7051a Mon Sep 17 00:00:00 2001 From: sabaimran Date: Sun, 11 Aug 2024 15:30:09 +0530 Subject: [PATCH] If the list of choices in a chunk is empty, continue in openai response --- src/khoj/processor/conversation/openai/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/khoj/processor/conversation/openai/utils.py b/src/khoj/processor/conversation/openai/utils.py index b17e5c3d..bfc70482 100644 --- a/src/khoj/processor/conversation/openai/utils.py +++ b/src/khoj/processor/conversation/openai/utils.py @@ -120,6 +120,8 @@ def llm_thread(g, messages, model_name, temperature, openai_api_key=None, api_ba ) for chunk in chat: + if len(chunk.choices) == 0: + continue delta_chunk = chunk.choices[0].delta if isinstance(delta_chunk, str): g.send(delta_chunk)