fix: adds checks for empty openai choices

This commit is contained in:
sauravniraula 2025-11-13 03:25:18 +05:45
parent b146596ee6
commit aa610d5c86
No known key found for this signature in database
GPG key ID: 60FCC1B5A5E83326

View file

@ -204,6 +204,10 @@ class LLMClient:
tools=tools,
extra_body=extra_body,
)
if len(response.choices) == 0:
return None
tool_calls = response.choices[0].message.tool_calls
if tool_calls:
parsed_tool_calls = [
@ -506,6 +510,9 @@ class LLMClient:
extra_body=extra_body,
)
if len(response.choices) == 0:
return None
content = response.choices[0].message.content
tool_calls = response.choices[0].message.tool_calls