Trait LLMProvider

Source
pub trait LLMProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn provider_type(&self) -> Provider;
    fn supported_models(&self) -> Vec<String>;
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = RsllmResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn chat_completion<'life0, 'life1, 'async_trait>(
        &'life0 self,
        messages: Vec<ChatMessage>,
        model: Option<&'life1 str>,
        temperature: Option<f32>,
        max_tokens: Option<u32>,
    ) -> Pin<Box<dyn Future<Output = RsllmResult<ChatResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn chat_completion_stream<'life0, 'async_trait>(
        &'life0 self,
        messages: Vec<ChatMessage>,
        model: Option<String>,
        temperature: Option<f32>,
        max_tokens: Option<u32>,
    ) -> Pin<Box<dyn Future<Output = RsllmResult<Box<dyn Stream<Item = RsllmResult<StreamChunk>> + Send + Unpin>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Core provider trait for LLM interactions

Required Methods§

Source

fn name(&self) -> &str

Provider name/identifier

Source

fn provider_type(&self) -> Provider

Provider type

Source

fn supported_models(&self) -> Vec<String>

Supported models

Source

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

Health check

Source

fn chat_completion<'life0, 'life1, 'async_trait>( &'life0 self, messages: Vec<ChatMessage>, model: Option<&'life1 str>, temperature: Option<f32>, max_tokens: Option<u32>, ) -> Pin<Box<dyn Future<Output = RsllmResult<ChatResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Chat completion (non-streaming)

Source

fn chat_completion_stream<'life0, 'async_trait>( &'life0 self, messages: Vec<ChatMessage>, model: Option<String>, temperature: Option<f32>, max_tokens: Option<u32>, ) -> Pin<Box<dyn Future<Output = RsllmResult<Box<dyn Stream<Item = RsllmResult<StreamChunk>> + Send + Unpin>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Chat completion (streaming)

Implementors§