Refactor: Pricing/Draft-Pfad als Single Source of Truth (Phase 1)

- Neuer services/pricing.py: PRICING-Dict + compute_savings() aus dem
  system-Router extrahiert; Router ist jetzt dünn (nur role_map + Aufruf).
- /system/token-stats liefert zusätzlich das pricing-Dict → Frontend zeigt
  die Tarife daraus an statt sie im Text zu hartkodieren.
- SPEC_DRAFT_MODEL_PATH in config.py (MC_SPEC_DRAFT_MODEL); llamaswap.py und
  migrate_config.py referenzieren die Konstante statt des doppelten Literals.
- Ersparnis-Berechnung verhaltensneutral verifiziert (35,09 $ / 32,28 €).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hitonabi
2026-06-26 14:28:26 +02:00
parent 35dcc69ba5
commit a7c3f8f516
8 changed files with 155 additions and 133 deletions
+3 -4
View File
@@ -12,7 +12,7 @@ import re
import httpx
from ruamel.yaml.scalarstring import LiteralScalarString
from config import CMD_TEMPLATE, CONFIG_PATH, DEFAULT_TTL, LLAMA_SWAP_URL
from config import CMD_TEMPLATE, CONFIG_PATH, DEFAULT_TTL, LLAMA_SWAP_URL, SPEC_DRAFT_MODEL_PATH
# Kanonische Rollen (vereinheitlicht ggü. v1: kein manager/reviewer mehr).
ROLE_IDS = {"vision", "coder", "reasoning", "agent", "scout"}
@@ -188,9 +188,8 @@ def register_model(model_path: str, role: str | None = None, ctx: int = 8192,
if role_lower in ("fast", "coder"):
if "--parallel" not in cmd:
cmd += " --parallel 2"
draft_path = "/srv/models/drafts/qwen2.5-1.5b-instruct-q4_k_m.gguf"
if os.path.exists(draft_path) and "--spec-draft-model" not in cmd:
cmd += f" --spec-draft-model {draft_path}"
if os.path.exists(SPEC_DRAFT_MODEL_PATH) and "--spec-draft-model" not in cmd:
cmd += f" --spec-draft-model {SPEC_DRAFT_MODEL_PATH}"
cfg.setdefault("models", {})[model_id] = {
"cmd": LiteralScalarString(cmd + "\n"),