phase2e: Modelltausch schreibt die llama-swap-Config einmal statt bis zu siebenmal
- llamaswap.sammeln(): Aenderungen lesen dieselbe Config aus dem Speicher, geschrieben wird einmal am Ende, bei einem Fehler gar nicht - Radar-Tausch und Hirn-Umstellung nutzen es; Hermes wird erst nach dem Schreiben umgestellt - Test-Attrappe fuer update_brain_model: der Radar-Test faesst auf der Box nie die echte Hermes-Config an - Doku: Ziel-Modell, strukturierter Verlauf, Sammel-Schreiben Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
589c14d5e9
commit
a47489fa85
+25
-19
@@ -1383,8 +1383,9 @@ def _tausche_ein(k: dict) -> dict:
|
||||
else:
|
||||
ziel = quelle # schon verschoben (früherer, abgebrochener Versuch)
|
||||
pfade = _lokale_pfade(k, ziel)
|
||||
# Eintragen, Befehl ersetzen und Zwilling anlegen unter EINER Config-Sperre (24.09.2026).
|
||||
with llamaswap.config_sperre():
|
||||
# Eintragen, Befehl, Zwilling, Rollen, Gruppe und ttl als EIN Schreibvorgang (24.09.2026): Vorher
|
||||
# schrieb ein Tausch die Config bis zu siebenmal, und jedes Mal entlud llama-swap alle Modelle.
|
||||
with llamaswap.sammeln():
|
||||
modell_id = llamaswap.register_model(pfade["gguf"], role=ALIAS[rolle],
|
||||
ctx=int(k.get("ctx") or CTX_ROLLE[rolle]),
|
||||
mmproj_path=None, jinja=True, set_alias=False)
|
||||
@@ -1396,27 +1397,32 @@ def _tausche_ein(k: dict) -> dict:
|
||||
if pfade.get("mmproj"):
|
||||
_zwilling_eintragen(cfg, rolle, modell_id, pfade, k)
|
||||
llamaswap.write_config(cfg)
|
||||
antwort: dict = {}
|
||||
if rolle == "hirn":
|
||||
from services.agent import set_agent_brain
|
||||
# hermes-Alias, brains-Gruppe, ttl 0 — Hermes selbst erst nach dem Schreiben (unten).
|
||||
antwort = set_agent_brain(modell_id, hermes_umstellen=False)
|
||||
if not antwort.get("ok"):
|
||||
raise RuntimeError(antwort.get("reason") or "Hirn-Wechsel fehlgeschlagen")
|
||||
# Das Hirn ist heute hermes UND fast (Chat-Spur, warmup.sh, Oberfläche). Bliebe fast am alten
|
||||
# Modell, lüde warmup.sh es nachts neben das neue Hirn.
|
||||
if alt and "fast" in {str(a).lower() for a in alt.get("aliases") or []}:
|
||||
llamaswap.add_role(modell_id, "fast")
|
||||
else:
|
||||
if not llamaswap.set_role(modell_id, "coder"):
|
||||
raise RuntimeError(f"Die Rolle coder ließ sich nicht auf {modell_id} setzen.")
|
||||
# heavy ist heute derselbe Coder (OpenCode plant damit). Bliebe es am alten Modell, lägen zwei
|
||||
# Coder bereit und der alte ließe sich nie löschen.
|
||||
if alt and "heavy" in {str(a).lower() for a in alt.get("aliases") or []}:
|
||||
llamaswap.add_role(modell_id, "heavy")
|
||||
if alt and alt.get("ttl") is not None:
|
||||
llamaswap.set_ttl(modell_id, int(alt["ttl"]))
|
||||
hinweis = None
|
||||
if rolle == "hirn":
|
||||
from services.agent import set_agent_brain
|
||||
antwort = set_agent_brain(modell_id) # hermes-Alias, brains-Gruppe, ttl 0, Hermes-Config
|
||||
if not antwort.get("ok"):
|
||||
raise RuntimeError(antwort.get("reason") or "Hirn-Wechsel fehlgeschlagen")
|
||||
# Das Hirn ist heute hermes UND fast (Chat-Spur, warmup.sh, Oberfläche). Bliebe fast am alten
|
||||
# Modell, lüde warmup.sh es nachts neben das neue Hirn.
|
||||
if alt and "fast" in {str(a).lower() for a in alt.get("aliases") or []}:
|
||||
llamaswap.add_role(modell_id, "fast")
|
||||
from services.agent import update_brain_model
|
||||
update_brain_model("hermes") # Hermes-Config + Neustart, jetzt mit fertiger Config
|
||||
hinweis = " ".join(h for h in (antwort.get("warning"), _warmset_umstellen((alt or {}).get("name"), modell_id))
|
||||
if h) or None
|
||||
else:
|
||||
if not llamaswap.set_role(modell_id, "coder"):
|
||||
raise RuntimeError(f"Die Rolle coder ließ sich nicht auf {modell_id} setzen.")
|
||||
# heavy ist heute derselbe Coder (OpenCode plant damit). Bliebe es am alten Modell, lägen zwei Coder
|
||||
# bereit und der alte ließe sich nie löschen.
|
||||
if alt and "heavy" in {str(a).lower() for a in alt.get("aliases") or []}:
|
||||
llamaswap.add_role(modell_id, "heavy")
|
||||
if alt and alt.get("ttl") is not None:
|
||||
llamaswap.set_ttl(modell_id, int(alt["ttl"]))
|
||||
return {"modell_id": modell_id, "pfad": str(ziel), "alt": (alt or {}).get("name"), "hinweis": hinweis}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user