fix(providers): handle empty choices in custom provider response
This commit is contained in:
@@ -54,6 +54,11 @@ class CustomProvider(LLMProvider):
|
||||
return LLMResponse(content=f"Error: {e}", finish_reason="error")
|
||||
|
||||
def _parse(self, response: Any) -> LLMResponse:
|
||||
if not response.choices:
|
||||
return LLMResponse(
|
||||
content="Error: API returned empty choices. This may indicate a temporary service issue or an invalid model response.",
|
||||
finish_reason="error"
|
||||
)
|
||||
choice = response.choices[0]
|
||||
msg = choice.message
|
||||
tool_calls = [
|
||||
|
||||
Reference in New Issue
Block a user