feat(2.0): DELETE /api/models/{id} (Eintrag + Gruppen-Mitgliedschaft entfernen)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hitonabi
2026-06-25 12:41:58 +02:00
parent fc0153d0de
commit db1f62227b
2 changed files with 21 additions and 0 deletions
+7
View File
@@ -124,6 +124,13 @@ def cancel(job_id: str) -> dict:
return {"ok": jobengine.cancel_job(job_id)} return {"ok": jobengine.cancel_job(job_id)}
@router.delete("/models/{model_id}")
def delete(model_id: str) -> dict:
if not llamaswap.delete_model(model_id):
raise HTTPException(404, "Modell nicht gefunden")
return {"ok": True}
@router.get("/groups") @router.get("/groups")
def groups() -> dict: def groups() -> dict:
return {"groups": llamaswap.list_groups()} return {"groups": llamaswap.list_groups()}
+14
View File
@@ -186,3 +186,17 @@ def set_group(group: str, members: list[str], swap: bool = False, persist: bool
def list_groups() -> dict: def list_groups() -> dict:
return read_config().get("groups") or {} return read_config().get("groups") or {}
def delete_model(model_id: str) -> bool:
"""Entfernt einen Modell-Eintrag aus der config.yaml (und aus allen Gruppen)."""
cfg = read_config()
models = cfg.get("models") or {}
if model_id not in models:
return False
del models[model_id]
for g in (cfg.get("groups") or {}).values():
if isinstance(g, dict) and model_id in (g.get("members") or []):
g["members"] = [m for m in g["members"] if m != model_id]
write_config(cfg)
return True