diff --git a/src/marvin/engine/language_models/openai.py b/src/marvin/engine/language_models/openai.py index 127953fb2..f0ee94409 100644 --- a/src/marvin/engine/language_models/openai.py +++ b/src/marvin/engine/language_models/openai.py @@ -48,7 +48,10 @@ async def handle_streaming_response( async for r in api_response: response["llm_response"] = r.to_dict_recursive() - delta = r.choices[0].delta + delta = r.choices[0].delta if r.choices and r.choices[0] else None + + if delta is None: + continue if "role" in delta: response["role"] = delta.role