You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixopenai#1559: Handle empty choices array in LiteLLM model
Add defensive checks before accessing response.choices[0] to prevent
IndexError when Gemini or other providers return an empty choices array.
This follows the same pattern as PR openai#935 which fixed the identical issue
in openai_chatcompletions.py.
Changes:
- Add null checks for response.choices before array access
- Return empty output when choices array is empty
- Preserve usage information even when choices is empty
- Add appropriate type annotations for litellm types
0 commit comments