Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

fix: LLM generation sometimes fails in streaming, catch temporary errors

Clémence Lesné511ede9361fd
diff --git a/helpers/llm_worker.py b/helpers/llm_worker.py
index 0443b39..163ef32 100644
--- a/helpers/llm_worker.py
+++ b/helpers/llm_worker.py
@@ -189,6 +189,10 @@ async def _completion_stream_worker(
)
async for chunck in stream:
choices = chunck.choices
+ if (
+ not choices
+ ): # Skip empty choices, happens sometimes with GPT-4 Turbo
+ continue
delta = choices[0].delta
yield delta
to_cache.append(delta)