Skip to main content

Provider

Trait Provider 

Source
pub trait Provider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn config(&self) -> &ProviderConfig;
    fn complete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        req: &'life1 ChatRequest,
    ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, ProviderError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn stream<'life0, 'life1, 'async_trait>(
        &'life0 self,
        req: &'life1 ChatRequest,
    ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<StreamChunk, ProviderError>>, ProviderError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}

Required Methods§

Source

fn name(&self) -> &str

Source

fn config(&self) -> &ProviderConfig

Source

fn complete<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 ChatRequest, ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Provided Methods§

Source

fn stream<'life0, 'life1, 'async_trait>( &'life0 self, req: &'life1 ChatRequest, ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<StreamChunk, ProviderError>>, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Streaming variant. The default falls back to complete() and emits the whole response as one SSE chunk; natively streaming providers override this.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§