fix(provider): clarify local 502 recovery hints
This commit is contained in:
committed by
Xubin Ren
parent
f879d81b28
commit
c68b3edb9d
@@ -4,6 +4,7 @@ from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
|
||||
from nanobot.providers.openai_compat_provider import OpenAICompatProvider
|
||||
from nanobot.providers.registry import find_by_name
|
||||
|
||||
|
||||
def test_custom_provider_parse_handles_empty_choices() -> None:
|
||||
@@ -53,3 +54,16 @@ def test_custom_provider_parse_chunks_accepts_plain_text_chunks() -> None:
|
||||
|
||||
assert result.finish_reason == "stop"
|
||||
assert result.content == "hello world"
|
||||
|
||||
|
||||
def test_local_provider_502_error_includes_reachability_hint() -> None:
|
||||
spec = find_by_name("ollama")
|
||||
with patch("nanobot.providers.openai_compat_provider.AsyncOpenAI"):
|
||||
provider = OpenAICompatProvider(api_base="http://localhost:11434/v1", spec=spec)
|
||||
|
||||
result = provider._handle_error(Exception("Error code: 502"))
|
||||
|
||||
assert result.finish_reason == "error"
|
||||
assert "local model endpoint" in result.content
|
||||
assert "http://localhost:11434/v1" in result.content
|
||||
assert "proxy/tunnel" in result.content
|
||||
|
||||
Reference in New Issue
Block a user