fix(webui): recover model failures and align chat controls
This commit is contained in:
1 parent
688976bcb9
commit
28f6c26946
42 files changed
+646
-82
No files matched your search
@@ -44,6 +44,20 @@ class ScriptedProvider(LLMProvider):
|
||||
return "test-model"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("response", "expected"), [
|
||||
(LLMResponse(content=None, finish_reason="error", error_kind="oauth_auth_required"), "authentication"),
|
||||
(LLMResponse(content=None, finish_reason="error", error_status_code=401), "authentication"),
|
||||
(LLMResponse(content=None, finish_reason="error", error_status_code=403), "unknown"),
|
||||
(LLMResponse(
|
||||
content=None, finish_reason="error", error_status_code=403, error_code="content_filter",
|
||||
), "unknown"),
|
||||
])
|
||||
def test_public_authentication_diagnosis_requires_credential_evidence(
|
||||
response: LLMResponse, expected: str,
|
||||
) -> None:
|
||||
assert LLMProvider.public_error_kind(response) == expected
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_chat_with_retry_retries_transient_error_then_succeeds(monkeypatch) -> None:
|
||||
provider = ScriptedProvider([
|
||||
@@ -134,7 +148,7 @@ async def test_chat_with_retry_clears_waiting_status_on_terminal_non_transient_e
|
||||
assert response.content == "401 unauthorized"
|
||||
assert [status.state for status in statuses] == ["waiting", "cleared"]
|
||||
assert statuses[-1].attempt == 2
|
||||
assert statuses[-1].error_kind == "unknown"
|
||||
assert statuses[-1].error_kind == "authentication"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -403,6 +417,36 @@ async def test_chat_with_retry_explicit_override_beats_defaults() -> None:
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Image fallback tests
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("error", [
|
||||
LLMResponse(content="unauthorized", finish_reason="error", error_status_code=401),
|
||||
LLMResponse(content="login expired", finish_reason="error", error_kind="authentication"),
|
||||
LLMResponse(
|
||||
content="Sign in again.", finish_reason="error",
|
||||
error_kind="oauth_auth_required", error_should_retry=False,
|
||||
),
|
||||
LLMResponse(content="billing", finish_reason="error", error_status_code=402),
|
||||
])
|
||||
async def test_account_failure_does_not_retry_without_images(error: LLMResponse) -> None:
|
||||
provider = ScriptedProvider([error])
|
||||
messages = copy.deepcopy(_IMAGE_MSG)
|
||||
original = copy.deepcopy(messages)
|
||||
state = ProviderConversationState(
|
||||
provider="scripted", model="test-model", kind="test", version=1, payload={},
|
||||
)
|
||||
context = ProviderCallContext(conversation_state=state)
|
||||
|
||||
response = await provider.chat_with_retry(messages=messages, provider_context=context)
|
||||
|
||||
assert response is error
|
||||
assert provider.calls == 1
|
||||
assert messages == original
|
||||
assert context.conversation_state is state
|
||||
assert LLMProvider.public_error_kind(response) in {"authentication", "billing"}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
_IMAGE_MSG = [
|
||||
|
||||
Reference in new issue
Block a user