Feat: Add Hermes brain change buttons and skills.sh guide source
This commit is contained in:
@@ -46,3 +46,47 @@ def agent_status() -> dict:
|
||||
"has_skills": (home / "skills").exists(),
|
||||
"has_memories": (home / "memories").exists(),
|
||||
}
|
||||
|
||||
|
||||
def update_brain_model(new_model: str) -> bool:
|
||||
from config import HERMES_HOME
|
||||
home = HERMES_HOME
|
||||
config_path = home / "config.yaml"
|
||||
|
||||
# Ensure home directory exists
|
||||
home.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
cfg = {}
|
||||
if config_path.exists():
|
||||
try:
|
||||
from ruamel.yaml import YAML
|
||||
r_yaml = YAML()
|
||||
with config_path.open("r", encoding="utf-8") as f:
|
||||
cfg = r_yaml.load(f) or {}
|
||||
except Exception:
|
||||
cfg = {}
|
||||
|
||||
if not isinstance(cfg, dict):
|
||||
cfg = {}
|
||||
|
||||
if "model" not in cfg or not isinstance(cfg["model"], dict):
|
||||
cfg["model"] = {}
|
||||
|
||||
cfg["model"]["model"] = new_model
|
||||
|
||||
try:
|
||||
from ruamel.yaml import YAML
|
||||
r_yaml = YAML()
|
||||
with config_path.open("w", encoding="utf-8") as f:
|
||||
r_yaml.dump(cfg, f)
|
||||
|
||||
# Restart the user-space service to apply changes
|
||||
try:
|
||||
import services.maintenance as maintenance
|
||||
maintenance.restart_service("hermes-gateway")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
@@ -70,9 +70,20 @@ def model_upgrades() -> list[dict]:
|
||||
cmds = " ".join(str(s.get("cmd", "")).lower()
|
||||
for s in (llamaswap.read_config().get("models") or {}).values())
|
||||
out = []
|
||||
|
||||
ROLE_MAP = {
|
||||
"reasoning": "heavy",
|
||||
"agent": "fast",
|
||||
"scout": "fast",
|
||||
"coder": "coder",
|
||||
"vision": "vision"
|
||||
}
|
||||
|
||||
for c in disc.get("categories", []):
|
||||
role = c["role"]
|
||||
if role not in active_roles:
|
||||
disc_role = c["role"]
|
||||
mapped_role = ROLE_MAP.get(disc_role, disc_role)
|
||||
|
||||
if mapped_role not in active_roles:
|
||||
continue
|
||||
|
||||
rec = c.get("recommended")
|
||||
@@ -82,7 +93,7 @@ def model_upgrades() -> list[dict]:
|
||||
stem = base[:-5] if base.endswith("-gguf") else base
|
||||
if base in cmds or (stem and stem in cmds):
|
||||
continue
|
||||
out.append({"role": role, "title": c["title"], "repo": rec})
|
||||
out.append({"role": mapped_role, "title": c["title"], "repo": rec})
|
||||
return out
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user