Skip to main content

Provider

Trait Provider 

Source
pub trait Provider: Send + Sync {
    // Required method
    fn complete<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        req: &'life1 ChatRequest,
        on_delta: &'life2 (dyn for<'a> Fn(&'a str) + Send + Sync),
    ) -> Pin<Box<dyn Future<Output = Result<(ChatMessage, Usage)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

The transport abstraction. Implement this to back the agent with something other than an OpenAI-compatible HTTP endpoint (a local model, a mock, etc.).

Required Methods§

Source

fn complete<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, req: &'life1 ChatRequest, on_delta: &'life2 (dyn for<'a> Fn(&'a str) + Send + Sync), ) -> Pin<Box<dyn Future<Output = Result<(ChatMessage, Usage)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run one completion. on_delta is called with each text chunk as it streams in. Returns the fully assembled assistant message and usage.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§