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§
Sourcefn 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 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
Sourcefn model_name(&self) -> &str
fn model_name(&self) -> &str
Returns the model name
Provided Methods§
Sourcefn 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,
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".