pub struct ModelStore { /* private fields */ }Implementations§
Source§impl ModelStore
impl ModelStore
pub fn new(dir: impl Into<PathBuf>) -> Self
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
$WEIRDNET_MODELS_DIR, else <user data dir>/weirdnet/models; the Hub from
$WEIRDNET_HF_URL (a mirror) when set; this node’s Hugging Face token
(HfToken::from_env), which is sent only to the public Hub, never to a mirror.
Sourcepub fn with_token(self, token: Option<HfToken>) -> Self
pub fn with_token(self, token: Option<HfToken>) -> Self
Sends token to this store’s Hub, whichever it is (a mirror too).
Sourcepub fn hub_client(&self) -> Hub
pub fn hub_client(&self) -> Hub
A Hub client for this store’s Hub, with the token when it may go there.
Sourcepub fn with_hub(self, hub: impl Into<String>) -> Self
pub fn with_hub(self, hub: impl Into<String>) -> Self
Use another Hub (a mirror, or a local server in tests).
pub fn dir(&self) -> &Path
pub fn hub(&self) -> &str
Sourcepub fn installed(&self, spec: &ModelSpec) -> bool
pub fn installed(&self, spec: &ModelSpec) -> bool
Downloaded and complete: the size matches (the checksum was checked when it finished).
Sourcepub fn partial_bytes(&self, spec: &ModelSpec) -> u64
pub fn partial_bytes(&self, spec: &ModelSpec) -> u64
Bytes of a partial download, if any.
Sourcepub fn remove(&self, spec: &ModelSpec) -> bool
pub fn remove(&self, spec: &ModelSpec) -> bool
Deletes the file and any partial download. Returns whether a file was removed.
Sourcepub fn list(&self) -> Vec<StoredModel>
pub fn list(&self) -> Vec<StoredModel>
The GGUF models in the store (split parts grouped; projector, draft and .part files
left out), sorted by id. Adapters are not models: adapters/ is skipped, and so is a
GGUF whose name hints at an adapter (adapter_hint) when its header says it is one.
Sourcepub fn remove_local(&self, model: &StoredModel) -> Result<u64>
pub fn remove_local(&self, model: &StoredModel) -> Result<u64>
Deletes a listed model’s files (and their .part files) and the directories that leaves
empty. Returns the bytes freed. Paths outside the store are refused.
Source§impl ModelStore
impl ModelStore
Sourcepub fn adapter_dir(&self, id: &str) -> Result<PathBuf>
pub fn adapter_dir(&self, id: &str) -> Result<PathBuf>
Where adapter id goes: <store>/adapters/<id>. The id must be one plain path part.
Sourcepub fn adapters(&self) -> Vec<StoredAdapter>
pub fn adapters(&self) -> Vec<StoredAdapter>
The complete LoRA adapters under adapters/, sorted by id: from adapter.json when
download_adapter wrote one, else a LoRA GGUF (by
its header) or a PEFT directory (adapter_config.json and its weights) found there.
Sourcepub fn remove_adapter(&self, adapter: &StoredAdapter) -> Result<u64>
pub fn remove_adapter(&self, adapter: &StoredAdapter) -> Result<u64>
Deletes a stored adapter’s directory. Returns the bytes freed. Ids that are not one plain path part are refused.