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:
Leonid Pershin
2026-08-21 06:44:50 +03:00
parent f93ac5a66a
commit 7ed6a99df2
25 changed files with 455 additions and 177 deletions
+18 -7
View File
@@ -72,16 +72,18 @@ def decide_watch(status: str | None, tunnel_alive: bool) -> WatchDecision:
def tunnel_forwards(cfg: Config) -> list[tuple[int, int]]:
"""List of (local_port, remote_port). SwarmUI always; LLM if configured.
Prefer live config (`LLM_RUNTIME`) over stale state.notes.
"""
pairs = [(cfg.swarmui_local_port, 7801)]
"""List of (local_port, remote_port). SwarmUI if enabled; LLM if configured."""
pairs: list[tuple[int, int]] = []
if bool(getattr(cfg, "enable_swarmui", True)):
pairs.append((cfg.swarmui_local_port, 7801))
runtime = normalize_runtime(cfg.llm_runtime)
if runtime == "ollama":
pairs.append((cfg.ollama_local_port, 11434))
elif runtime == "llamacpp":
pairs.append((cfg.llamacpp_local_port, 8080))
if not pairs:
# Failsafe: at least SwarmUI port so tunnel isn't empty.
pairs.append((cfg.swarmui_local_port, 7801))
return pairs
@@ -181,14 +183,23 @@ def run_tunnel(
log("watchdog: EXPIRED → unshelve + reconnect")
server = _start_forwarder(cfg, current_host, forwards)
swarm_url = f"http://127.0.0.1:{cfg.swarmui_local_port}"
swarm_on = bool(getattr(cfg, "enable_swarmui", True))
runtime = normalize_runtime(cfg.llm_runtime)
if swarm_on:
open_url = f"http://127.0.0.1:{cfg.swarmui_local_port}"
elif runtime == "ollama":
open_url = f"http://127.0.0.1:{cfg.ollama_local_port}"
elif runtime == "llamacpp":
open_url = f"http://127.0.0.1:{cfg.llamacpp_local_port}"
else:
open_url = f"http://127.0.0.1:{cfg.swarmui_local_port}"
from gpu_rent.access_card import print_access_card
print_access_card(cfg, tunneled=True, host=current_host)
if open_browser:
webbrowser.open(swarm_url)
webbrowser.open(open_url)
state = load_state()
state.phase = "ready_tunneled"