- Revised model descriptions in `ollama-models.example.yaml` to emphasize uncensored and abliterated requirements, enhancing user understanding. - Updated documentation in `llm.md` to reflect changes in model tags and their meanings, ensuring accurate guidance for users. - Modified CLI help messages to clarify the nature of presets, reinforcing that all options are abliterate models with Russian support. - Enhanced the `llm_runtime.py` file to align preset labels with the updated model descriptions, improving consistency across the codebase.
62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
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"
|
|
with pytest.raises(ValueError):
|
|
normalize_runtime("llamacpp")
|
|
with pytest.raises(ValueError):
|
|
normalize_runtime("foo")
|
|
|
|
|
|
def test_decide_runtime_flags_win():
|
|
assert (
|
|
decide_runtime(flag=None, ollama_flag=True, from_config="none") == "ollama"
|
|
)
|
|
assert (
|
|
decide_runtime(flag="ollama", ollama_flag=False, from_config="none") == "ollama"
|
|
)
|
|
assert decide_runtime(flag=None, ollama_flag=False, from_config="ollama") == "ollama"
|
|
|
|
|
|
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-vl-abliterated:7b"
|
|
write_ollama_models_preset(path, "big")
|
|
assert parse_ollama_models(path)[0].name == "huihui_ai/qwen2.5-vl-abliterated:32b"
|
|
write_ollama_models_preset(path, "text")
|
|
assert parse_ollama_models(path)[0].name == "huihui_ai/qwen2.5-abliterate:7b"
|