Skip to main content

LlmProvider

Trait LlmProvider 

Source
pub trait LlmProvider:
    Send
    + Sync
    + 'static {
    // Required methods
    fn complete<'life0, 'async_trait>(
        &'life0 self,
        req: CompletionRequest,
    ) -> Pin<Box<dyn Future<Output = Result<CompletionResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stream<'life0, 'async_trait>(
        &'life0 self,
        req: CompletionRequest,
    ) -> Pin<Box<dyn Future<Output = Result<BoxStream<'_, Result<StreamChunk>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn name(&self) -> &str;
}
Expand description

Unified contract for chat-completion capable LLM providers.

Required Methods§

Source

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

Executes a single non-streaming completion request.

Source

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

Executes a streaming completion request.

Source

fn name(&self) -> &str

Returns the provider name.

Implementors§