| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| from typing import Any | |
| def registry_path() -> Path: | |
| return Path(__file__).with_name("loras.json") | |
| def load_registry(path: str | Path | None = None) -> dict[str, Any]: | |
| p = Path(path) if path else registry_path() | |
| return json.loads(p.read_text(encoding="utf-8")) | |
| def lora_choices(path: str | Path | None = None) -> list[tuple[str, str]]: | |
| registry = load_registry(path) | |
| choices = [] | |
| for lora in registry.get("loras", []): | |
| label = f"{lora['cultural_source']} · {lora['id']} ({lora.get('status', 'unknown')})" | |
| choices.append((label, lora["id"])) | |
| return choices | |