Trait ModelBuilder

Source
pub trait ModelBuilder {
    type Model;
    type Error: Send + Sync + 'static;

    // Required method
    fn start_with_loading_handler(
        self,
        handler: impl FnMut(ModelLoadingProgress) + Send + Sync + 'static,
    ) -> impl Future<Output = Result<Self::Model, Self::Error>>
       where Self: Sized;

    // Provided methods
    fn start(self) -> impl Future<Output = Result<Self::Model, Self::Error>>
       where Self: Sized { ... }
    fn requires_download(&self) -> bool { ... }
}
Expand description

A builder that can create a model asynchronously.

§Example

use kalosm::language::*;

#[tokio::main]
async fn main() {
    let model = Llama::builder().start().await.unwrap();
}

Required Associated Types§

Source

type Model

The model that this trait creates.

Source

type Error: Send + Sync + 'static

An error that can occur when creating the model.

Required Methods§

Source

fn start_with_loading_handler( self, handler: impl FnMut(ModelLoadingProgress) + Send + Sync + 'static, ) -> impl Future<Output = Result<Self::Model, Self::Error>>
where Self: Sized,

Start the model with a loading handler.

Provided Methods§

Source

fn start(self) -> impl Future<Output = Result<Self::Model, Self::Error>>
where Self: Sized,

Start the model.

Source

fn requires_download(&self) -> bool

Check if the model will need to be downloaded before use (default: false)

Implementors§