Files
VoiceStudio/tests/test_llm_openai_available.py
Palash DebnathandClaude Fable 5 d3822c4976 feat(engines): open the door between the LLM family and its providers (#1538)
* feat(engines): open the door between the LLM family and its providers

The openai-compat family entry and the LLM Providers panel are one
system — llm_backend resolves every call through the active provider —
but the UI presented them as unrelated (council coherence finding). Now:

- the catalogue's openai-compat row carries a 'Provider · model' hint
  naming the endpoint that actually answers (decorative: a provider
  registry hiccup degrades to no hint, never a failed listing)
- the row offers 'Configure providers' straight into Settings → LLM
  Providers; the panel gains the backlink into catalogue → LLM family
- three new strings in all 21 locales, matching each file's provider
  terminology

Also: bugReport's encoded-ceiling test is hermetic now — it was the one
test in its file trusting ambient fetch, and hung on any machine where a
local backend holds the port without answering.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(i18n): the catalogue note names the ACTIVE provider, not the edited one

CodeRabbit on #1538: the panel can be editing a provider that is not
active, and 'this provider answers…' then points at the wrong one. The
note now says the provider MARKED ACTIVE answers, which is true under
any selection — no state-dependent copy needed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 20:46:36 +00:00

50 lines
2.1 KiB
Python

"""Regression guard: the `openai` client must stay a declared dependency.
Cinematic dub refinement, glossary auto-extract, and LLM-based translation all
`from openai import OpenAI`. It was previously undeclared in pyproject, so a fresh
`uv sync` never installed it and Cinematic was dead-on-arrival on every source
install — the UI showed "Cinematic needs an LLM" even with Ollama running and
configured, because `OpenAICompatBackend.is_available()` returned "openai package
missing" (reported on Discord). These tests fail loudly if the dep is dropped.
"""
from __future__ import annotations
def test_openai_client_importable():
import openai # noqa: F401
from openai import OpenAI # noqa: F401
def test_llm_backend_not_blocked_by_missing_openai_package():
from services.llm_backend import OpenAICompatBackend
ok, msg = OpenAICompatBackend.is_available()
# Without a configured endpoint it's still unavailable — but the reason must
# be "configure an endpoint", NOT "openai package missing".
assert "package missing" not in msg.lower(), msg
def test_provider_hint_names_the_active_provider_only_for_openai_compat(monkeypatch):
"""The catalogue's LLM row must say WHICH provider answers (#coherence):
llm_backend and the LLM Providers panel are one system, and the hint is
the row-level proof of that. Other backends carry no hint, and a
provider-registry failure degrades to no hint, never to a crash."""
from services import llm_backend, llm_providers
class _P:
display_name = "OrcaRouter"
monkeypatch.setattr(llm_providers, "active_provider", lambda: _P())
monkeypatch.setattr(llm_providers, "resolve_model", lambda p: "gpt-4o-mini")
assert llm_backend._provider_hint("openai-compat") == "OrcaRouter · gpt-4o-mini"
assert llm_backend._provider_hint("off") is None
monkeypatch.setattr(llm_providers, "resolve_model", lambda p: "")
assert llm_backend._provider_hint("openai-compat") == "OrcaRouter"
def _boom():
raise RuntimeError("registry unavailable")
monkeypatch.setattr(llm_providers, "active_provider", _boom)
assert llm_backend._provider_hint("openai-compat") is None