Update configuration and documentation for LLM support and local watchdog

- Added `ollama-models.yaml` to .gitignore and implemented logic to copy it in gpu-rent.ps1 and gpu-rent.sh.
- Enhanced env.example to include new variables for LLM runtime options and local watchdog configuration.
- Updated CLI commands to support LLM options during setup and execution, including new flags for Ollama and llama.cpp.
- Improved documentation in cli.md and README.md to reflect changes in LLM integration and local watchdog functionality.
- Adjusted architecture and decisions documentation to clarify the role of LLMs and local watchdog in the system.
This commit is contained in:
Leonid Pershin
2026-08-21 05:29:23 +03:00
parent a9cf2e0f90
commit 2005b00175
43 changed files with 2258 additions and 197 deletions
+100
View File
@@ -0,0 +1,100 @@
"""Interactive setup wizard: files + LLM_RUNTIME + optional watchdog."""
from __future__ import annotations
import shutil
from collections.abc import Callable
from pathlib import Path
from gpu_rent.llm_runtime import (
PRESET_HELP,
append_vars_llm_runtime,
ensure_ollama_manifest_from_example,
normalize_runtime,
write_ollama_models_preset,
)
from gpu_rent.paths import (
app_root,
env_path,
extensions_manifest_path,
models_manifest_path,
ollama_models_example_path,
ollama_models_manifest_path,
vars_example_path,
vars_path,
)
Log = Callable[[str], None]
def _copy_if_missing(src: Path, dst: Path, label: str, log: Log) -> None:
if dst.is_file():
log(f"есть {label}")
return
if src.is_file():
shutil.copy2(src, dst)
log(f"создал {label} из example")
else:
log(f"нет example для {label}: {src}")
def run_setup(
*,
llm: str | None = None,
ollama_preset: str | None = None,
install_watchdog: bool | None = None,
confirm: Callable[[str], bool] | None = None,
ask: Callable[[str, str], str] | None = None,
log: Log = print,
) -> None:
root = app_root()
log(f"setup в {root}")
_copy_if_missing(root / "env.example", env_path(), ".env", log)
_copy_if_missing(root / "models.example.yaml", models_manifest_path(), "models.yaml", log)
_copy_if_missing(
root / "extensions.example.yaml", extensions_manifest_path(), "extensions.yaml", log
)
_copy_if_missing(vars_example_path(), vars_path(), "gpu-rent.vars", log)
_copy_if_missing(
ollama_models_example_path(), ollama_models_manifest_path(), "ollama-models.yaml", log
)
runtime = llm
if runtime is None:
if ask:
runtime = ask(
"LLM runtime [none/ollama/llamacpp]",
"none",
)
else:
runtime = "none"
runtime = normalize_runtime(runtime)
append_vars_llm_runtime(vars_path(), runtime)
log(f"LLM_RUNTIME={runtime} → gpu-rent.vars")
if runtime == "ollama":
preset = ollama_preset
if preset is None and ask:
log(PRESET_HELP)
preset = ask("Ollama preset [recommended/light/stock/alt/empty]", "recommended")
if preset is None:
preset = "recommended"
if preset.strip().lower() in {"keep", "example", ""}:
ensure_ollama_manifest_from_example()
log("ollama-models.yaml из example")
else:
write_ollama_models_preset(ollama_models_manifest_path(), preset)
log(f"ollama-models.yaml пресет={preset}")
do_wd = install_watchdog
if do_wd is None and confirm:
do_wd = confirm("Установить local-watchdog (аварийный stop без Ctrl+C)?")
if do_wd:
from gpu_rent.local_watchdog import install_watchdog as _install
_install(log=log)
elif do_wd is False:
log("local-watchdog: skip")
log("готово. Заполни .env (OS_*), потом: gpu-rent doctor && gpu-rent up")