Refactor CLI and LLM runtime handling for improved user experience

- Removed deprecated console usage in favor of structured logging functions for error handling and user prompts.
- Enhanced CLI prompts for LLM runtime and preset selection, utilizing menu helpers for better user interaction.
- Updated GPU pool scanning output with improved formatting and error indication for clarity.
- Refactored setup wizard to streamline LLM runtime and preset configuration, ensuring a more intuitive setup process.
- Improved documentation and user feedback in CLI outputs to enhance overall usability.
This commit is contained in:
Leonid Pershin
2026-08-21 06:31:15 +03:00
parent 64f93b4bf6
commit e7784473a2
9 changed files with 420 additions and 133 deletions
+24 -12
View File
@@ -7,12 +7,13 @@ from collections.abc import Callable
from pathlib import Path
from gpu_rent.llm_runtime import (
LLAMACPP_PRESET_HELP,
PRESET_HELP,
append_vars_llm_runtime,
ensure_llamacpp_manifest_from_example,
ensure_ollama_manifest_from_example,
llamacpp_preset_menu,
llm_runtime_menu,
normalize_runtime,
ollama_preset_menu,
write_llamacpp_models_preset,
write_ollama_models_preset,
)
@@ -28,6 +29,7 @@ from gpu_rent.paths import (
vars_example_path,
vars_path,
)
from gpu_rent.prompts import prompt_menu
Log = Callable[[str], None]
@@ -74,9 +76,12 @@ def run_setup(
runtime = llm
if runtime is None:
if ask:
runtime = ask(
"LLM runtime [none/ollama/llamacpp]",
"none",
runtime = prompt_menu(
"LLM runtime",
llm_runtime_menu(),
default="none",
ask=ask,
show=log,
)
else:
runtime = "none"
@@ -87,8 +92,13 @@ def run_setup(
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")
preset = prompt_menu(
"Ollama preset",
ollama_preset_menu(include_keep=False),
default="recommended",
ask=ask,
show=log,
)
if preset is None:
preset = "recommended"
if preset.strip().lower() in {"keep", "example", ""}:
@@ -98,12 +108,14 @@ def run_setup(
write_ollama_models_preset(ollama_models_manifest_path(), preset)
log(f"ollama-models.yaml пресет={preset}")
elif runtime == "llamacpp":
preset = ollama_preset # reuse --ollama-preset flag as generic LLM preset in setup
preset = ollama_preset
if preset is None and ask:
log(LLAMACPP_PRESET_HELP)
preset = ask(
"llama.cpp GGUF preset [recommended/light/stock/empty]",
"recommended",
preset = prompt_menu(
"llama.cpp GGUF",
llamacpp_preset_menu(include_keep=False),
default="recommended",
ask=ask,
show=log,
)
if preset is None:
preset = "recommended"