- Added support for a new extension, `swarm-assistent`, in `extensions.example.yaml` with a requirement for `ollama`. - Enhanced the README.md to clarify the setup process and provide a quick start guide for using extensions. - Updated documentation in `llm.md` to reflect the opt-in nature of LLM support and provide clearer instructions for enabling it. - Improved the `autocomplete.md` to detail the automatic setup of word lists during the initial launch. - Revised `cli.md` to include new commands and options related to LLM runtime handling and extension management. - Enhanced the `spike-notes.md` to guide users through the first live run with a focus on LLM integration.
82 lines
2.7 KiB
Python
82 lines
2.7 KiB
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from gpu_rent.errors import ConfigError
|
|
from gpu_rent.manifests import parse_extensions, parse_models, repo_matches_runtime
|
|
|
|
|
|
def test_models_skips_version_zero(tmp_path: Path):
|
|
path = tmp_path / "models.yaml"
|
|
path.write_text(
|
|
"checkpoint:\n - version_id: 0\n - version_id: 123\n - url: https://civitai.red/models/1?modelVersionId=9\n",
|
|
encoding="utf-8",
|
|
)
|
|
entries = parse_models(path)
|
|
assert len(entries) == 2
|
|
assert entries[0].version_id == 123
|
|
assert entries[1].url.endswith("9")
|
|
|
|
|
|
def test_extensions_empty_file(tmp_path: Path):
|
|
path = tmp_path / "extensions.yaml"
|
|
path.write_text("swarmui: []\ncomfy: []\n", encoding="utf-8")
|
|
assert parse_extensions(path) == []
|
|
|
|
|
|
def test_extensions_repo(tmp_path: Path):
|
|
path = tmp_path / "extensions.yaml"
|
|
path.write_text(
|
|
"swarmui:\n - url: https://github.com/org/Ext.git\n ref: main\n dir: Ext\n",
|
|
encoding="utf-8",
|
|
)
|
|
repos = parse_extensions(path)
|
|
assert repos[0].kind == "swarmui"
|
|
assert repos[0].directory == "Ext"
|
|
assert repos[0].requires == "none"
|
|
|
|
|
|
def test_extensions_requires_ollama(tmp_path: Path):
|
|
path = tmp_path / "extensions.yaml"
|
|
path.write_text(
|
|
"swarmui:\n"
|
|
" - url: https://gitea.example/swarm-assistent.git\n"
|
|
" ref: main\n"
|
|
" dir: swarm-assistent\n"
|
|
" requires: ollama\n"
|
|
" - url: https://github.com/org/Always.git\n"
|
|
" ref: main\n",
|
|
encoding="utf-8",
|
|
)
|
|
repos = parse_extensions(path)
|
|
assert repos[0].requires == "ollama"
|
|
assert repos[1].requires == "none"
|
|
assert repo_matches_runtime(repos[0], "ollama")
|
|
assert not repo_matches_runtime(repos[0], "none")
|
|
assert not repo_matches_runtime(repos[0], "llamacpp")
|
|
assert repo_matches_runtime(repos[1], "none")
|
|
assert repo_matches_runtime(repos[1], "ollama")
|
|
|
|
|
|
def test_extensions_requires_any_llm(tmp_path: Path):
|
|
path = tmp_path / "extensions.yaml"
|
|
path.write_text(
|
|
"swarmui:\n - url: https://example/x.git\n requires: any-llm\n",
|
|
encoding="utf-8",
|
|
)
|
|
repo = parse_extensions(path)[0]
|
|
assert repo.requires == "any-llm"
|
|
assert repo_matches_runtime(repo, "ollama")
|
|
assert repo_matches_runtime(repo, "llamacpp")
|
|
assert not repo_matches_runtime(repo, "none")
|
|
|
|
|
|
def test_extensions_requires_invalid(tmp_path: Path):
|
|
path = tmp_path / "extensions.yaml"
|
|
path.write_text(
|
|
"swarmui:\n - url: https://example/x.git\n requires: docker\n",
|
|
encoding="utf-8",
|
|
)
|
|
with pytest.raises(ConfigError, match="requires"):
|
|
parse_extensions(path)
|