Initial commit: Agentic OS troubleshooting platform
Self-hosted, Docker-based agentic troubleshooting platform: FastAPI backend + LangGraph agent, Next.js UI, tiered LLM routing (local Ollama -> Gemini -> DeepSeek -> OpenRouter), MCP server manager, encrypted device credentials, RBAC, audit log, project-memory + Obsidian integrations, and editable troubleshooting decision rules tuned for the GeneseasX vessel stack. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
67
backend/tests/test_model_routing.py
Normal file
67
backend/tests/test_model_routing.py
Normal file
@@ -0,0 +1,67 @@
|
||||
"""Tests for tiered model routing."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
os.environ.setdefault("SECRET_KEY", "test-secret-key-for-unit-tests-only")
|
||||
|
||||
from app.services.model_config import ( # noqa: E402
|
||||
LlmRoutingConfig,
|
||||
resolve_tier_model,
|
||||
resolve_tier_models,
|
||||
)
|
||||
from app.services.model_router import plan_reasoning_tiers # noqa: E402
|
||||
|
||||
|
||||
def test_resolve_tier_models_provider_order(monkeypatch):
|
||||
monkeypatch.setenv("GEMINI_API_KEY", "test-gemini")
|
||||
monkeypatch.setenv("DEEPSEEK_API_KEY", "test-deepseek")
|
||||
monkeypatch.setenv("OPENROUTER_API_KEY", "test-openrouter")
|
||||
|
||||
from app.config import get_settings
|
||||
|
||||
get_settings.cache_clear()
|
||||
|
||||
cfg = LlmRoutingConfig(
|
||||
cloud_provider_order=["gemini", "deepseek", "openrouter"],
|
||||
)
|
||||
models = resolve_tier_models(cfg, "economy")
|
||||
backends = [m.backend for m in models]
|
||||
assert backends == ["gemini", "deepseek", "openrouter"]
|
||||
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
def test_resolve_tier_model_returns_first_provider(monkeypatch):
|
||||
monkeypatch.setenv("GEMINI_API_KEY", "test-gemini")
|
||||
monkeypatch.setenv("DEEPSEEK_API_KEY", "test-deepseek")
|
||||
|
||||
from app.config import get_settings
|
||||
|
||||
get_settings.cache_clear()
|
||||
|
||||
cfg = LlmRoutingConfig(cloud_provider_order=["gemini", "deepseek", "openrouter"])
|
||||
entry = resolve_tier_model(cfg, "economy")
|
||||
assert entry is not None
|
||||
assert entry.backend == "gemini"
|
||||
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
def test_plan_reasoning_local_first():
|
||||
tiers, reason = plan_reasoning_tiers(
|
||||
{"severity": "low", "needs_cloud_reasoning": False, "recommended_tier": "local"},
|
||||
[],
|
||||
cfg=LlmRoutingConfig(),
|
||||
)
|
||||
assert tiers == ["local"]
|
||||
assert "local" in reason.lower()
|
||||
|
||||
|
||||
def test_plan_reasoning_escalates_critical():
|
||||
tiers, _ = plan_reasoning_tiers(
|
||||
{"severity": "critical", "needs_cloud_reasoning": True, "recommended_tier": "premium"},
|
||||
[{"ok": False}, {"ok": False}],
|
||||
cfg=LlmRoutingConfig(),
|
||||
)
|
||||
assert tiers == ["local", "economy", "premium"]
|
||||
Reference in New Issue
Block a user