pub trait Model: Send + Sync {
// Required methods
fn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
config: &'life2 ModelConfig,
stream_callback: Option<StreamCallback>,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn name(&self) -> &str;
fn is_local(&self) -> bool;
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_models<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn has_model<'life0, 'life1, 'async_trait>(
&'life0 self,
model_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn capabilities(&self) -> ModelCapabilities { ... }
}Expand description
Core trait that all model adapters implement
This is the only abstraction layer between user code and model providers.
Required Methods§
Sourcefn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
config: &'life2 ModelConfig,
stream_callback: Option<StreamCallback>,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [ChatMessage],
config: &'life2 ModelConfig,
stream_callback: Option<StreamCallback>,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Send a chat conversation to the model and get a response
Provided Methods§
Sourcefn has_model<'life0, 'life1, 'async_trait>(
&'life0 self,
model_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has_model<'life0, 'life1, 'async_trait>(
&'life0 self,
model_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if a specific model is available
Sourcefn capabilities(&self) -> ModelCapabilities
fn capabilities(&self) -> ModelCapabilities
Get model capabilities