9e432dbd2d
Teil 1: VoiceLatencyCard auf dem Dashboard (GET /api/voice/metrics, C2) — zeigt STT/Vision/Chat-TTFB/TTS mit p50/p95/last + count. Teil 2: UI-editierbare Routing-Policy. Neuer routing_policy.py (hot-reload JSON unter MODELS_DIR/mc2-routing.json, Env=Defaults, atomarer Write, Validierung). router_logic, gateway_proxy und gateway.routing_summary lesen jetzt live via load_policy(); routing_summary ist lane-bewusst (chat/coding statt altem auto). Neue Endpoints GET/PUT /api/routing/policy. Teil 3: LaneEditor.tsx als ZONE im Cockpit (chat/coding-Aliase + Schwellen + fast_no_think, Speichern/Default-je-Feld); Gateway-Node zeigt die Lanes. Verifiziert: npm run build (tsc strict) clean, FastAPI TestClient (GET/PUT, Validierung, Persistenz, Hot-reload durch die API), venv-Smoke (Routing). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
"""
|
|
Routing-Gateway-Status (eingebauter Modus). MC2 IST der Gateway: serviert
|
|
`/v1/*` mit `model: auto`-Komplexitäts-Routing vor llama-swap. Kein externer
|
|
LiteLLM-Dienst nötig (baut auf Python 3.14 nicht); bleibt später austauschbar.
|
|
"""
|
|
|
|
from config import PORT
|
|
from services.llamaswap import engine_reachable
|
|
from services.routing_policy import load_policy
|
|
|
|
|
|
def routing_summary() -> dict:
|
|
p = load_policy()
|
|
coding_default = p["coder_lite"] or p["coder"]
|
|
return {
|
|
"mode": "builtin",
|
|
"endpoint": f":{PORT}/v1 (OpenAI-kompatibel)",
|
|
# Virtuelle Lanes, die Clients/IDEs als „Modell" wählen (Router pickt das echte Alias).
|
|
"lanes": [
|
|
{
|
|
"name": "chat",
|
|
"aka": "auto",
|
|
"target": f"{p['fast']} ↔ {p['heavy']} (nach Komplexität)",
|
|
"threshold_chars": p["heavy_chars"],
|
|
},
|
|
{
|
|
"name": "coding",
|
|
"target": f"{coding_default} ↔ {p['coder']} (Eskalation)",
|
|
"escalate_chars": p["coding_escalate_chars"],
|
|
},
|
|
],
|
|
# Rückwärtskompatible Flach-Liste (alte UI/Clients).
|
|
"routes": [
|
|
{"name": "chat", "target": f"{p['fast']} ↔ {p['heavy']} (nach Komplexität)"},
|
|
{"name": "coding", "target": f"{coding_default} ↔ {p['coder']} (Eskalation)"},
|
|
{"name": "<alias>", "target": "llama-swap-Passthrough (lädt bei Bedarf)"},
|
|
],
|
|
"heavy_threshold_chars": p["heavy_chars"],
|
|
"fallbacks": [],
|
|
"context_window_fallbacks": [],
|
|
}
|
|
|
|
|
|
def gateway_reachable() -> bool:
|
|
# Der eingebaute Gateway lebt in MC und proxyt llama-swap → erreichbar, wenn Engine läuft.
|
|
return engine_reachable()
|