feat(webui): show the actual fallback model (#5017)

This commit is contained in:
chengyongru
2026-07-23 15:57:13 +08:00
committed by GitHub
parent 4188ffc88d
commit 96eb965aae
15 changed files with 352 additions and 8 deletions
+24
View File
@@ -285,6 +285,30 @@ class TestFallbackOnPrimaryError:
assert primary.chat_calls[0]["model"] == "primary-model"
assert fallback.chat_calls[0]["model"] == "fallback-a"
@pytest.mark.asyncio
async def test_reports_the_fallback_model_before_its_request(self) -> None:
primary = _FakeProvider("primary", _error_response())
fallback = _FakeProvider("fallback", _make_response("fallback ok"))
fallback_models: list[str] = []
async def _observe(model: str) -> None:
fallback_models.append(model)
fb = FallbackProvider(
primary=primary,
fallback_presets=[_fallback("fallback-a", provider="backup")],
provider_factory=MagicMock(return_value=fallback),
fallback_model_observer=_observe,
)
result = await fb.chat_with_retry(
messages=[{"role": "user", "content": "hi"}],
model="primary-model",
)
assert result.content == "fallback ok"
assert fallback_models == ["fallback-a"]
@pytest.mark.asyncio
async def test_logs_primary_error_before_fallback(self) -> None:
primary = _FakeProvider("primary", _error_response("primary overloaded"))