Model

Trait Model 

Source
pub trait Model: Send + Sync {
    // Required methods
    fn chat<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 mut self,
        messages: &'life1 [ChatMessage],
        context: &'life2 ProjectContext,
        config: &'life3 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,
             'life3: 'async_trait;
    fn name(&self) -> &str;
    fn is_local(&self) -> bool;

    // Provided method
    fn validate_connection<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Core trait that all model implementations must provide

This is the public API. Internal backends implement this via UnifiedModel wrapper.

Required Methods§

Source

fn chat<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, messages: &'life1 [ChatMessage], context: &'life2 ProjectContext, config: &'life3 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, 'life3: 'async_trait,

Send a chat conversation to the model and get a response

Source

fn name(&self) -> &str

Get the name of the model

Source

fn is_local(&self) -> bool

Check if this is a local model (no external API calls)

Provided Methods§

Source

fn validate_connection<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Validate that the model is accessible

Implementors§