Trait Model

Source
pub trait Model: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn name(&self) -> &str;
    fn provider_id(&self) -> &str;
    fn capabilities(&self) -> &ModelCapabilities;
    fn config(&self) -> &ModelConfig;
    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: GenerateOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamChunk>> + Send>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn count_tokens<'life0, 'life1, 'async_trait>(
        &'life0 self,
        messages: &'life1 [Message],
    ) -> Pin<Box<dyn Future<Output = Result<u32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn estimate_cost<'life0, 'async_trait>(
        &'life0 self,
        input_tokens: u32,
        output_tokens: u32,
    ) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn metadata(&self) -> &ModelMetadata;
}
Expand description

Model trait for individual language models

Required Methods§

Source

fn id(&self) -> &str

Unique identifier for this model

Source

fn name(&self) -> &str

Human-readable name of the model

Source

fn provider_id(&self) -> &str

Provider that owns this model

Source

fn capabilities(&self) -> &ModelCapabilities

Model capabilities

Source

fn config(&self) -> &ModelConfig

Model configuration

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 a response from messages

Source

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

Stream response generation

Source

fn count_tokens<'life0, 'life1, 'async_trait>( &'life0 self, messages: &'life1 [Message], ) -> Pin<Box<dyn Future<Output = Result<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Count tokens in messages

Source

fn estimate_cost<'life0, 'async_trait>( &'life0 self, input_tokens: u32, output_tokens: u32, ) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Estimate cost for a request

Source

fn metadata(&self) -> &ModelMetadata

Get model-specific metadata

Implementors§