Fix: /running-Objekte zu Namen normalisieren (Live-Panel + warm-Badges)

Neuere llama-swap-Versionen liefern /running als Liste von Objekten
({model,state,...}) statt Strings. get_running_models() normalisiert nun auf
Namens-Strings → running.includes(name) im Frontend matcht wieder (ActiveModels-
Card + RolesCard 'warm'-Badges). Logger in llamaswap.py ergänzt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hitonabi
2026-06-26 19:29:22 +02:00
parent 1e8e114550
commit b51f30b49a
+9 -3
View File
@@ -6,6 +6,7 @@ NEU in 2.0: `groups` für Ko-Residenz (schnell + schwer gleichzeitig geladen,
`swap:false`) → Multi-Model-Delegation ohne Nachlade-Latenz. `swap:false`) → Multi-Model-Delegation ohne Nachlade-Latenz.
""" """
import logging
import os import os
import re import re
@@ -14,6 +15,8 @@ from ruamel.yaml.scalarstring import LiteralScalarString
from config import CMD_TEMPLATE, CONFIG_PATH, DEFAULT_TTL, LLAMA_SWAP_URL, SPEC_DRAFT_MODEL_PATH from config import CMD_TEMPLATE, CONFIG_PATH, DEFAULT_TTL, LLAMA_SWAP_URL, SPEC_DRAFT_MODEL_PATH
log = logging.getLogger(__name__)
# Kanonische Rollen (vereinheitlicht ggü. v1: kein manager/reviewer mehr). # Kanonische Rollen (vereinheitlicht ggü. v1: kein manager/reviewer mehr).
ROLE_IDS = {"vision", "coder", "reasoning", "agent", "scout"} ROLE_IDS = {"vision", "coder", "reasoning", "agent", "scout"}
@@ -304,12 +307,15 @@ def delete_model(model_id: str) -> bool:
def get_running_models() -> list[str]: def get_running_models() -> list[str]:
"""Fragt den /running Endpunkt von llama-swap ab. Gibt geladene Modelle zurück.""" """Fragt den /running Endpunkt von llama-swap ab. Gibt die Namen der geladenen
Modelle zurück. Neuere llama-swap-Versionen liefern Objekte ({model, state, ...})
statt Strings — beide Formen werden auf Namens-Strings normalisiert."""
try: try:
with httpx.Client(timeout=2.0) as c: with httpx.Client(timeout=2.0) as c:
r = c.get(f"{LLAMA_SWAP_URL}/running") r = c.get(f"{LLAMA_SWAP_URL}/running")
if r.status_code == 200: if r.status_code == 200:
return r.json().get("running") or [] data = r.json().get("running") or []
return [x.get("model", "") if isinstance(x, dict) else x for x in data]
except Exception: except Exception:
pass log.warning("get_running_models fehlgeschlagen", exc_info=True)
return [] return []