Skip to main content

Provider

Trait Provider 

Source
pub trait Provider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn list_models<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ModelInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn complete<'life0, 'async_trait>(
        &'life0 self,
        request: CompletionRequest,
    ) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn complete_stream<'life0, 'async_trait>(
        &'life0 self,
        request: CompletionRequest,
    ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, StreamChunk>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Provider trait that all AI providers must implement

Required Methods§

Source

fn name(&self) -> &str

Get the provider name

Source

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

List available models

Source

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

Generate a completion

Source

fn complete_stream<'life0, 'async_trait>( &'life0 self, request: CompletionRequest, ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, StreamChunk>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Generate a streaming completion

Implementors§