Skip to main content

LLM

Trait LLM 

Source
pub trait LLM: Send + Sync {
    // Required methods
    fn generate<'life0, 'async_trait>(
        &'life0 self,
        messages: Vec<Message>,
        files: Option<Vec<File>>,
    ) -> Pin<Box<dyn Future<Output = Result<GenerationResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn model_name(&self) -> &str;

    // Provided method
    fn stream_generate<'life0, 'async_trait>(
        &'life0 self,
        _messages: Vec<Message>,
        _files: Option<Vec<File>>,
    ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<GenerationChunk>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

LLM model interface

Required Methods§

Source

fn generate<'life0, 'async_trait>( &'life0 self, messages: Vec<Message>, files: Option<Vec<File>>, ) -> Pin<Box<dyn Future<Output = Result<GenerationResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Generates a response from the model

Source

fn model_name(&self) -> &str

Returns the model name

Provided Methods§

Source

fn stream_generate<'life0, 'async_trait>( &'life0 self, _messages: Vec<Message>, _files: Option<Vec<File>>, ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<GenerationChunk>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Generates a streaming response from the model

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§