Skip to main content

Provider

Trait Provider 

Source
pub trait Provider: Send + Sync {
    // Required methods
    fn chat<'life0, 'async_trait>(
        &'life0 self,
        request: ChatRequest,
    ) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn clone_box(&self) -> Box<dyn Provider>;

    // Provided methods
    fn context_size(&self) -> Option<u32> { ... }
    fn chat_stream<'life0, 'async_trait>(
        &'life0 self,
        request: ChatRequest,
    ) -> Pin<Box<dyn Future<Output = Result<Receiver<StreamEvent>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}

Required Methods§

Source

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

Source

fn clone_box(&self) -> Box<dyn Provider>

Clone the provider into a boxed type.

Provided Methods§

Source

fn context_size(&self) -> Option<u32>

Best-effort context window size (in tokens) for the configured model. None if the provider cannot infer it; callers should treat that as “don’t render a fullness bar”.

Source

fn chat_stream<'life0, 'async_trait>( &'life0 self, request: ChatRequest, ) -> Pin<Box<dyn Future<Output = Result<Receiver<StreamEvent>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stream a chat turn. Default impl wraps chat and emits one Done event, so providers without native streaming still work (no incremental thinking).

Trait Implementations§

Source§

impl Clone for Box<dyn Provider>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§