If the list of choices in a chunk is empty, continue in openai response

This commit is contained in:
sabaimran
2024-08-11 15:30:09 +05:30
parent 6f94a076f7
commit d99f03e4f3

View File

@@ -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)