Enhance LLM and SwarmUI integration with improved configuration options
- Updated `env.example` and `gpu-rent.vars.example` to include new variables for LLM runtime and SwarmUI options. - Refactored CLI commands to support interactive selection of LLM runtime and workload type (SwarmUI, LLM, or both). - Improved access link generation to handle cases where SwarmUI is disabled, providing clearer user feedback. - Enhanced provisioning logic to conditionally bootstrap SwarmUI based on user configuration, allowing for LLM-only setups. - Updated documentation across multiple files to reflect changes in LLM integration, CLI usage, and configuration management.
This commit is contained in:
+57
-25
@@ -440,33 +440,68 @@ def provision_vm(
|
||||
server_id: str | None = None,
|
||||
update: bool = True,
|
||||
) -> None:
|
||||
from gpu_rent.llm_runtime import normalize_runtime
|
||||
from gpu_rent.state import load_state, save_state
|
||||
|
||||
swarm = bool(getattr(cfg, "enable_swarmui", True))
|
||||
rt = normalize_runtime(cfg.llm_runtime)
|
||||
if not swarm and rt == "none":
|
||||
raise CloudError(
|
||||
"llm-only: нужен LLM_RUNTIME=ollama|llamacpp (или --ollama / --llamacpp)"
|
||||
)
|
||||
|
||||
restart = bool(update)
|
||||
try:
|
||||
if seed_extensions(cfg, host, log, update=update):
|
||||
restart = True
|
||||
except GpuRentError as exc:
|
||||
log(f"extensions: {exc}")
|
||||
raise
|
||||
try:
|
||||
if seed_autocomplete(cfg, host, log):
|
||||
restart = True
|
||||
except GpuRentError as exc:
|
||||
log(f"autocomplete: {exc}")
|
||||
seed_civitai(cfg, host, log)
|
||||
push_tree(cfg, host, cfg.local_models_dir, f"{DATA}/Models", log, models=True)
|
||||
push_tree(cfg, host, cfg.local_wildcards_dir, f"{DATA}/Data/Wildcards", log, models=False)
|
||||
push_tree(cfg, host, cfg.local_workflows_dir, f"{DATA}/CustomWorkflows", log, models=False)
|
||||
if cfg.pull_output:
|
||||
pull_tree(cfg, host, f"{DATA}/Output", cfg.local_output_dir, log)
|
||||
if swarm:
|
||||
try:
|
||||
if seed_extensions(cfg, host, log, update=update):
|
||||
restart = True
|
||||
except GpuRentError as exc:
|
||||
log(f"extensions: {exc}")
|
||||
raise
|
||||
try:
|
||||
if seed_autocomplete(cfg, host, log):
|
||||
restart = True
|
||||
except GpuRentError as exc:
|
||||
log(f"autocomplete: {exc}")
|
||||
seed_civitai(cfg, host, log)
|
||||
push_tree(cfg, host, cfg.local_models_dir, f"{DATA}/Models", log, models=True)
|
||||
push_tree(
|
||||
cfg, host, cfg.local_wildcards_dir, f"{DATA}/Data/Wildcards", log, models=False
|
||||
)
|
||||
push_tree(
|
||||
cfg,
|
||||
host,
|
||||
cfg.local_workflows_dir,
|
||||
f"{DATA}/CustomWorkflows",
|
||||
log,
|
||||
models=False,
|
||||
)
|
||||
if cfg.pull_output:
|
||||
pull_tree(cfg, host, f"{DATA}/Output", cfg.local_output_dir, log)
|
||||
else:
|
||||
log("SwarmUI: skip (llm-only)")
|
||||
run_ssh(
|
||||
cfg,
|
||||
host,
|
||||
"sudo -n systemctl stop swarmui 2>/dev/null; "
|
||||
"sudo -n systemctl disable swarmui 2>/dev/null || true; "
|
||||
"echo llm-only | sudo -n tee /mnt/swarm_data/.gpu-rent-llm-only >/dev/null",
|
||||
check=False,
|
||||
)
|
||||
|
||||
try:
|
||||
probe_gpu(cfg, host, log)
|
||||
except Exception as exc:
|
||||
log(f"GPU probe: {exc}")
|
||||
|
||||
ensure_swarmui_running(cfg, host, log, restart=restart)
|
||||
|
||||
from gpu_rent.state import load_state, save_state
|
||||
if swarm:
|
||||
ensure_swarmui_running(cfg, host, log, restart=restart)
|
||||
run_ssh(
|
||||
cfg,
|
||||
host,
|
||||
"sudo -n rm -f /mnt/swarm_data/.gpu-rent-llm-only",
|
||||
check=False,
|
||||
)
|
||||
|
||||
try:
|
||||
provision_llm(cfg, host, log)
|
||||
@@ -474,7 +509,6 @@ def provision_vm(
|
||||
st = load_state()
|
||||
st.notes = dict(st.notes or {})
|
||||
st.notes["llm_error"] = str(exc)[:500]
|
||||
# Do not claim success — leave previous notes.llm_runtime or clear to none.
|
||||
st.notes["llm_runtime"] = "none"
|
||||
save_state(st)
|
||||
raise CloudError(f"LLM runtime: {exc}") from exc
|
||||
@@ -498,10 +532,8 @@ def provision_vm(
|
||||
"⚠ idle-killer НЕ вооружён — GPU может тарифицироваться без авто-stop. "
|
||||
"См. status / docs/setup.md"
|
||||
)
|
||||
log("SwarmUI слушает 127.0.0.1:7801 — gpu-rent tunnel")
|
||||
from gpu_rent.llm_runtime import normalize_runtime
|
||||
|
||||
rt = normalize_runtime(cfg.llm_runtime)
|
||||
if swarm:
|
||||
log("SwarmUI слушает 127.0.0.1:7801 — gpu-rent tunnel")
|
||||
if rt == "ollama":
|
||||
log(f"Ollama API → localhost:{cfg.ollama_local_port} (туннель)")
|
||||
elif rt == "llamacpp":
|
||||
|
||||
Reference in New Issue
Block a user