Skip to main content

Module hf_cache

Module hf_cache 

Source
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.

  1. Call list_local_hf_models / list_supported_hf_models / delete_local_hf_model directly from your command handlers.
  2. Call download_model with an Arc<dyn Fn(ModelDownloadProgress)> that forwards progress to whatever event system your app uses.

Structs§

LocalHfModel
Information about a locally cached HuggingFace model.
LocalHfModelsResponse
Response returned by list_local_hf_models.
ModelDownloadProgress
Progress payload passed to the download_model callback on every poll tick and on completion.
SupportedHfModel
A supported model that may or may not be downloaded locally.
SupportedHfModelsResponse
Response returned by list_supported_hf_models.

Functions§

clean_stale_lock_files
Remove stale .lock and orphaned .part files from the HF cache blobs/ 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_id so 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.