Skip to main content

ModelProviderTrait

Trait ModelProviderTrait 

Source
pub trait ModelProviderTrait: Send + Sync {
    // Required methods
    fn download_model<'life0, 'life1, 'async_trait>(
        &'life0 self,
        model_name: &'life1 str,
        cache_path: Option<PathBuf>,
        ignore_weights: bool,
    ) -> Pin<Box<dyn Future<Output = Result<PathBuf>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_model<'life0, 'life1, 'async_trait>(
        &'life0 self,
        model_name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_model_path<'life0, 'life1, 'async_trait>(
        &'life0 self,
        model_name: &'life1 str,
        cache_dir: PathBuf,
    ) -> Pin<Box<dyn Future<Output = Result<PathBuf>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn provider_name(&self) -> &'static str;

    // Provided methods
    fn is_ignored(filename: &str) -> bool
       where Self: Sized { ... }
    fn is_image(path: &Path) -> bool
       where Self: Sized { ... }
    fn is_weight_file(filename: &str) -> bool
       where Self: Sized { ... }
}
Expand description

Trait for model providers This trait provides the framework for supporting multiple model providers.

Required Methods§

Source

fn download_model<'life0, 'life1, 'async_trait>( &'life0 self, model_name: &'life1 str, cache_path: Option<PathBuf>, ignore_weights: bool, ) -> Pin<Box<dyn Future<Output = Result<PathBuf>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Download a model and return the path where it was downloaded

Source

fn delete_model<'life0, 'life1, 'async_trait>( &'life0 self, model_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a model from the provider’s cache Returns Ok(()) if the model was successfully deleted or didn’t exist

Source

fn get_model_path<'life0, 'life1, 'async_trait>( &'life0 self, model_name: &'life1 str, cache_dir: PathBuf, ) -> Pin<Box<dyn Future<Output = Result<PathBuf>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the full path to the latest model snapshot if it exists Returns the path if found, or an error if not found

Source

fn provider_name(&self) -> &'static str

Get the provider name for logging

Provided Methods§

Source

fn is_ignored(filename: &str) -> bool
where Self: Sized,

Check if a file should be ignored during download This allows each provider to specify which files to skip Default implementation ignores common repository metadata files

Source

fn is_image(path: &Path) -> bool
where Self: Sized,

Check if a file is an image file that should be ignored This allows each provider to customize image file detection Default implementation recognizes common image file extensions

Source

fn is_weight_file(filename: &str) -> bool
where Self: Sized,

Checks if a file is a model weight file

Implementors§