This repository has been archived on 2026-07-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mission-control/config.py
T
Hitonabi 720b47a6e1 feat: Cookbook-Download-Fix, Live-Update-Konsole, Profi-Highlight, OpenCode-Guide
Backend:
- hf_bin() + HF_DOWNLOAD_ENV zentral in config.py; install-recipe und
  install-model in cookbook.py nutzten weiter das fehlende `hf` + falsches
  XET-Env -> Haupt-Installationsweg war ebenso kaputt, jetzt konsistent gefixt

Frontend:
- Server: laufende Updates (LLM-Engine/OS) live auf der Server-Seite mitlesbar,
  inkl. klarer Fertig-/Fehlgeschlagen-Meldung (onJobs + Aktueller-Vorgang-Karte)
- Cookbook/Profi-Modus: meistgeladenes, passendes Modell wird als
  "★ Beste Wahl für dein System" hervorgehoben (analog zu den Templates)
- Verbinden: OpenCode korrekt per opencode.json (@ai-sdk/openai-compatible)
  statt irrefuehrender Felder; erklaert "Connect to API"-Fehler (LAN-IP statt
  localhost)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 18:03:12 +02:00

53 lines
2.3 KiB
Python

"""
Zentrale Konfiguration fuer Mission Control.
Alles ueber Umgebungsvariablen ueberschreibbar. Wird von allen Modulen importiert,
damit es genau eine Quelle der Wahrheit fuer Pfade, URLs und Defaults gibt.
"""
import os
import sys
from pathlib import Path
from ruamel.yaml import YAML
# ---------------------------------------------------------------------------
# Env-Vars (siehe README fuer Bedeutung)
# ---------------------------------------------------------------------------
LLAMA_SWAP_URL = os.environ.get("MC_LLAMA_SWAP_URL", "http://127.0.0.1:8080").rstrip("/")
CONFIG_PATH = Path(os.environ.get("MC_CONFIG_PATH", "/etc/llama-swap/config.yaml"))
MODELS_DIR = Path(os.environ.get("MC_MODELS_DIR", "/srv/models"))
# Befehl, der zum Starten eines Modells in die config.yaml geschrieben wird.
# {model} = Pfad zur GGUF-Datei, {ctx} = Kontextlaenge, ${PORT} bleibt fuer llama-swap stehen.
# WICHTIG: an deinen Container-/llama-server-Aufruf anpassen (siehe README).
CMD_TEMPLATE = os.environ.get(
"MC_CMD_TEMPLATE",
"llama-server -m {model} --host 127.0.0.1 --port ${PORT} "
"-c {ctx} -ngl 999 -fa 1 --no-mmap",
)
# Befehl fuer "Container/Toolbox aktualisieren". Standard: kyuz0 refresh-Skript.
UPDATE_CMD = os.environ.get("MC_UPDATE_CMD", "")
DEFAULT_TTL = int(os.environ.get("MC_DEFAULT_TTL", "300"))
TOKEN = os.environ.get("MC_TOKEN", "") # leer = keine Auth (nur LAN!)
# Self-Update ("Mission Control aktualisieren"): Quelle = git-Repo, Prod = laufende Installation.
SOURCE_DIR = os.path.expanduser(os.environ.get("MC_SOURCE_DIR", "~/mission-control"))
PROD_DIR = str(Path(__file__).resolve().parent)
# Env fuer alle HuggingFace-Downloads: XET deaktivieren (mit aktivem XET haengt der
# Download reproduzierbar bei ~6 MB, siehe CLAUDE.md). Token wird je Job ergaenzt.
HF_DOWNLOAD_ENV = {"HF_HUB_DISABLE_XET": "1"}
def hf_bin() -> str:
"""Pfad zur `hf`-CLI fuer Modell-Downloads. Bevorzugt die im venv installierte
(neben dem laufenden Python), da der Dienst-PATH das venv/bin meist nicht
enthaelt. Faellt sonst auf ein global installiertes `hf` zurueck."""
cand = os.path.join(os.path.dirname(sys.executable), "hf")
return cand if os.path.exists(cand) else "hf"
# Gemeinsame YAML-Instanz (preserve_quotes haelt Kommentare/Quotes in config.yaml).
yaml = YAML()
yaml.preserve_quotes = True