Compare commits
3 Commits
0613b2879f
...
06ee68d871
| Author | SHA1 | Date | |
|---|---|---|---|
| 06ee68d871 | |||
|
|
49fc50b1e6 | ||
|
|
2eb0c283e9 |
@@ -54,6 +54,11 @@ class CustomProvider(LLMProvider):
|
|||||||
return LLMResponse(content=f"Error: {e}", finish_reason="error")
|
return LLMResponse(content=f"Error: {e}", finish_reason="error")
|
||||||
|
|
||||||
def _parse(self, response: Any) -> LLMResponse:
|
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]
|
choice = response.choices[0]
|
||||||
msg = choice.message
|
msg = choice.message
|
||||||
tool_calls = [
|
tool_calls = [
|
||||||
|
|||||||
13
tests/test_custom_provider.py
Normal file
13
tests/test_custom_provider.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
from nanobot.providers.custom_provider import CustomProvider
|
||||||
|
|
||||||
|
|
||||||
|
def test_custom_provider_parse_handles_empty_choices() -> None:
|
||||||
|
provider = CustomProvider()
|
||||||
|
response = SimpleNamespace(choices=[])
|
||||||
|
|
||||||
|
result = provider._parse(response)
|
||||||
|
|
||||||
|
assert result.finish_reason == "error"
|
||||||
|
assert "empty choices" in result.content
|
||||||
Reference in New Issue
Block a user