fix(providers): handle empty choices in custom provider response

This commit is contained in:
Jiajun Xie
2026-03-17 13:25:08 +08:00
committed by Xubin Ren
parent b939a916f0
commit 2eb0c283e9

View File

@@ -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 = [