Skip to main content

ModelClient

Trait ModelClient 

Source
pub trait ModelClient: Send + Sync {
    // Required method
    fn complete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        req: &'life1 ModelRequest,
    ) -> Pin<Box<dyn Future<Output = Result<ModelResponse, CoreError>> + 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 ModelRequest,
    ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'static, Result<String, CoreError>>, CoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

LLM access seam. Implement this to plug in any backend.

Required Methods§

Source

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

Produce a complete reply in one shot.

Provided Methods§

Source

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

Stream the reply as a sequence of tokens. The default implementation yields the full ModelResponse::text as a single chunk, so backends that only support non-streaming calls work unchanged.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§