Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
"""Ollama rows keep source ollama on the compat models route, even from a registered custom folder."""
from __future__ import annotations
import json
from pathlib import Path
import pytest
from models.models import LocalModelInfo
def _write_ollama_store(root: Path) -> None:
digest_value = "b" * 64
blob = root / "blobs" / f"sha256-{digest_value}"
blob.parent.mkdir(parents = True)
blob.write_bytes(b"GGUF-not-really")
tag_file = root / "manifests" / "registry.ollama.ai" / "library" / "llama3" / "latest"
tag_file.parent.mkdir(parents = True)
tag_file.write_text(
json.dumps(
{
"config": {},
"layers": [
{
"mediaType": "application/vnd.ollama.image.model",
"digest": f"sha256:{digest_value}",
}
],
}
),
encoding = "utf-8",
)
def test_legacy_schema_admits_the_ollama_source():
row = LocalModelInfo(
id = "/links/llama3.gguf",
display_name = "llama3:latest",
path = "/links/llama3.gguf",
source = "ollama",
)
assert row.source == "ollama"
def test_legacy_scanner_tags_rows_ollama(tmp_path):
from routes import models as models_route
root = tmp_path / "ollama"
_write_ollama_store(root)
found = models_route._scan_ollama_dir(root)
assert len(found) == 1
assert found[0].source == "ollama"
assert found[0].model_id == "ollama/llama3:latest"
@pytest.mark.parametrize("source", ["hf_cache", "ollama", "hermes"])
def test_custom_folder_merge_keeps_real_sources(source):
src = (Path(__file__).resolve().parent.parent / "routes" / "models.py").read_text(
encoding = "utf-8"
)
assert 'if m.source in ("hf_cache", "ollama", "hermes")' in src
row = LocalModelInfo(
id = "/x",
display_name = "x",
path = "/x",
source = source,
)
kept = (
row
if row.source in ("hf_cache", "ollama", "hermes")
else row.model_copy(update = {"source": "custom"})
)
assert kept.source == source