feat(recipes): add Unknown base-model filter bucket for undetermined recipes

Normalize undetermined recipe base_model to None in RecipeFormatParser
(previously ''). get_base_models now reports an "Unknown" bucket backed
by a dedicated __unknown__ marker, and the listing filter matches it
against recipes whose base model is falsy. Frontend renders the bucket
label as "Unknown" while filtering via the marker.

Tests: handler, scanner, parser, and frontend filtering.
This commit is contained in:
Will Miao
2026-08-31 09:09:53 +08:00
parent 8d46d26abe
commit 2a3c632dc5
8 changed files with 214 additions and 11 deletions
@@ -111,6 +111,36 @@ async def test_recipe_format_parser_populates_checkpoint(monkeypatch):
assert result["model"] == checkpoint
@pytest.mark.asyncio
async def test_recipe_format_parser_base_model_defaults_to_none_when_unknown(monkeypatch):
class _FakeScanner:
pass
# No checkpoint and empty base_model -> unknown renders as None (not "")
result = await _parse(
monkeypatch,
{"title": "T", "base_model": "", "loras": [], "gen_params": {}},
_FakeScanner(),
)
assert result["base_model"] is None
# Missing base_model key behaves the same
result = await _parse(
monkeypatch,
{"title": "T", "loras": [], "gen_params": {}},
_FakeScanner(),
)
assert result["base_model"] is None
# A real base_model in recipe metadata is kept
result = await _parse(
monkeypatch,
{"title": "T", "base_model": "Illustrious", "loras": [], "gen_params": {}},
_FakeScanner(),
)
assert result["base_model"] == "Illustrious"
@pytest.mark.asyncio
async def test_recipe_format_parser_marks_lora_in_library_by_version(monkeypatch):
async def fake_metadata_provider():