Skip to main content

LLMClient

Trait LLMClient 

Source
pub trait LLMClient: Send + Sync {
    // Required methods
    fn complete<'life0, 'async_trait>(
        &'life0 self,
        request: LLMRequest,
    ) -> Pin<Box<dyn Future<Output = Result<LLMResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn model_name(&self) -> &str;
    fn stream_complete<'life0, 'async_trait>(
        &'life0 self,
        request: LLMRequest,
    ) -> Pin<Box<dyn Future<Output = Result<LLMStream>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Unified async interface for LLM chat completion and streaming.

Required Methods§

Source

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

Send a chat completion request and return the full response.

Source

fn model_name(&self) -> &str

Return the model name this client is configured to use.

Source

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

Stream a chat completion, yielding events as they arrive.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§