Coverage for src / lilbee / catalog / refs.py: 100%
7 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-05-15 20:55 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-05-15 20:55 +0000
1"""HuggingFace ref helpers: parse and format ``<org>/<repo>/<file>.gguf`` strings."""
3from __future__ import annotations
6def hf_repo_from_ref(ref: str) -> str:
7 """Return the ``<org>/<repo>`` portion of a native GGUF ref.
9 Native GGUF refs have the form ``<org>/<repo>/<filename>.gguf``; the
10 repo is the prefix before the final slash. Provider-prefixed refs
11 (``openai/gpt-4``, ``ollama/llama3:8b``) and bare repos lack the
12 ``.gguf`` suffix and are returned unchanged.
13 """
14 if ref.endswith(".gguf") and "/" in ref:
15 return ref.rsplit("/", 1)[0]
16 return ref
19def format_native_gguf_ref(hf_repo: str, gguf_filename: str) -> str:
20 """Render the canonical ``<hf_repo>/<gguf_filename>`` native GGUF ref."""
21 return f"{hf_repo}/{gguf_filename}"