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:
@@ -0,0 +1,59 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from gpu_rent.llm_runtime import (
|
||||
decide_runtime,
|
||||
normalize_runtime,
|
||||
parse_ollama_models,
|
||||
write_ollama_models_preset,
|
||||
)
|
||||
|
||||
|
||||
def test_normalize_runtime():
|
||||
assert normalize_runtime(None) == "none"
|
||||
assert normalize_runtime("OLLAMA") == "ollama"
|
||||
assert normalize_runtime("llama-cpp") == "llamacpp"
|
||||
with pytest.raises(ValueError):
|
||||
normalize_runtime("foo")
|
||||
|
||||
|
||||
def test_decide_runtime_flags_win():
|
||||
assert (
|
||||
decide_runtime(flag=None, ollama_flag=True, llamacpp_flag=False, from_config="none")
|
||||
== "ollama"
|
||||
)
|
||||
assert (
|
||||
decide_runtime(flag="llamacpp", ollama_flag=False, llamacpp_flag=False, from_config="ollama")
|
||||
== "llamacpp"
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
decide_runtime(flag=None, ollama_flag=True, llamacpp_flag=True, from_config="none")
|
||||
|
||||
|
||||
def test_parse_ollama_models(tmp_path: Path):
|
||||
path = tmp_path / "m.yaml"
|
||||
path.write_text(
|
||||
"models:\n - name: huihui_ai/qwen2.5-abliterate:7b\n default: true\n - qwen2.5:3b\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
entries = parse_ollama_models(path)
|
||||
assert [e.name for e in entries] == [
|
||||
"huihui_ai/qwen2.5-abliterate:7b",
|
||||
"qwen2.5:3b",
|
||||
]
|
||||
assert entries[0].default is True
|
||||
|
||||
|
||||
def test_parse_empty_manifest(tmp_path: Path):
|
||||
path = tmp_path / "empty.yaml"
|
||||
path.write_text("models: []\n", encoding="utf-8")
|
||||
assert parse_ollama_models(path) == []
|
||||
assert parse_ollama_models(tmp_path / "missing.yaml") == []
|
||||
|
||||
|
||||
def test_write_preset(tmp_path: Path):
|
||||
path = tmp_path / "out.yaml"
|
||||
write_ollama_models_preset(path, "recommended")
|
||||
entries = parse_ollama_models(path)
|
||||
assert entries[0].name == "huihui_ai/qwen2.5-abliterate:7b"
|
||||
Reference in New Issue
Block a user