Trait LanguageModel

Source
pub trait LanguageModel: Send + Sync {
    // Required methods
    fn generate<'life0, 'async_trait>(
        &'life0 self,
        messages: Vec<Message>,
        options: GenerateOptions,
    ) -> Pin<Box<dyn Future<Output = Result<GenerateResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stream<'life0, 'async_trait>(
        &'life0 self,
        messages: Vec<Message>,
        options: StreamOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<StreamChunk>> + Send + Unpin>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn supports_tools(&self) -> bool;
    fn supports_vision(&self) -> bool;
    fn supports_caching(&self) -> bool;
}
Expand description

Language model trait for interacting with LLM providers

Required Methods§

Source

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

Generate text from a list of messages

Source

fn stream<'life0, 'async_trait>( &'life0 self, messages: Vec<Message>, options: StreamOptions, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = Result<StreamChunk>> + Send + Unpin>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stream text generation

Source

fn supports_tools(&self) -> bool

Check if the model supports tool calling

Source

fn supports_vision(&self) -> bool

Check if the model supports vision/images

Source

fn supports_caching(&self) -> bool

Check if the model supports caching

Implementors§