fix(llm): strengthen embed skip-verification test; add DEMO_MODE check to embed()
This commit is contained in:
parent
8e2d15bcd4
commit
7526092481
2 changed files with 9 additions and 1 deletions
|
|
@ -398,6 +398,11 @@ class LLMRouter:
|
|||
Raises:
|
||||
RuntimeError: If all eligible backends are exhausted.
|
||||
"""
|
||||
if os.environ.get("DEMO_MODE", "").lower() in ("1", "true", "yes"):
|
||||
raise RuntimeError(
|
||||
"AI inference is disabled in the public demo. "
|
||||
"Run your own instance to use AI features."
|
||||
)
|
||||
order = (
|
||||
fallback_order
|
||||
if fallback_order is not None
|
||||
|
|
|
|||
|
|
@ -189,13 +189,16 @@ def test_embed_skips_non_openai_compat_backends():
|
|||
mock_client.embeddings.create.return_value = MagicMock(
|
||||
data=[MagicMock(embedding=[0.1])]
|
||||
)
|
||||
mock_openai = MagicMock(return_value=mock_client)
|
||||
with (
|
||||
patch.object(router, "_is_reachable", return_value=True),
|
||||
patch("circuitforge_core.llm.router.OpenAI", return_value=mock_client),
|
||||
patch("circuitforge_core.llm.router.OpenAI", mock_openai),
|
||||
):
|
||||
result = router.embed(["hello"])
|
||||
|
||||
assert result == [[0.1]]
|
||||
# Only ollama reached the OpenAI constructor; anthropic was skipped by type check
|
||||
mock_openai.assert_called_once()
|
||||
|
||||
|
||||
def test_embed_raises_when_all_backends_exhausted():
|
||||
|
|
|
|||
Loading…
Reference in a new issue