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§
Sourcefn 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 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
Sourcefn 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 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
Sourcefn supports_tools(&self) -> bool
fn supports_tools(&self) -> bool
Check if the model supports tool calling
Sourcefn supports_vision(&self) -> bool
fn supports_vision(&self) -> bool
Check if the model supports vision/images
Sourcefn supports_caching(&self) -> bool
fn supports_caching(&self) -> bool
Check if the model supports caching