Expand description
HuggingFace hub cache inspection, repair, and model download.
This module owns all on-disk state management for locally cached HuggingFace models and exposes a progress-callback-based download API that is completely decoupled from any application framework.
- Call
list_local_hf_models/list_supported_hf_models/delete_local_hf_modeldirectly from your command handlers. - Call
download_modelwith anArc<dyn Fn(ModelDownloadProgress)>that forwards progress to whatever event system your app uses.
Structs§
- Local
HfModel - Information about a locally cached HuggingFace model.
- Local
HfModels Response - Response returned by
list_local_hf_models. - Model
Download Progress - Progress payload passed to the
download_modelcallback on every poll tick and on completion. - Supported
HfModel - A supported model that may or may not be downloaded locally.
- Supported
HfModels Response - Response returned by
list_supported_hf_models.
Functions§
- clean_
stale_ lock_ files - Remove stale
.lockand orphaned.partfiles from the HF cacheblobs/directory for a model. - delete_
local_ hf_ model - Delete a locally cached HuggingFace model by removing its directory from the hub cache.
- diagnose_
hf_ cache - Log the complete HF cache structure for a model to aid debugging.
- download_
model - ensure_
model_ cache_ dir - Pre-create the HuggingFace cache directory tree for
model_idso that the progress-monitor thread can find a valid path immediately, even before hf-hub creates it during the first download. - ensure_
snapshot_ entries - Ensure snapshot entries exist for known GGUF files.
- list_
local_ hf_ models - Scan the local HuggingFace hub cache and return all downloaded models that the inference engine supports.
- list_
supported_ hf_ models - Return the full list of models the inference engine supports, together with flags indicating whether each one is fully downloaded, partially downloaded, or not present at all.
- model_
cache_ path - Return the cache sub-directory path for a given model ID.
- repair_
hf_ cache_ symlinks - Repair broken symlinks in the HF hub cache for a given model.