Skip to main content

LlmDriver

Trait LlmDriver 

Source
pub trait LlmDriver: Send + Sync {
    // Required methods
    fn complete<'life0, 'async_trait>(
        &'life0 self,
        request: CompletionRequest,
    ) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, AgentError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn context_window(&self) -> usize;
    fn privacy_tier(&self) -> PrivacyTier;

    // Provided methods
    fn stream<'life0, 'async_trait>(
        &'life0 self,
        request: CompletionRequest,
        tx: Sender<StreamEvent>,
    ) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, AgentError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn estimate_cost(&self, _usage: &TokenUsage) -> f64 { ... }
}
Expand description

Abstraction over LLM inference backends.

Default implementation: RealizarDriver (sovereign, local).

Required Methods§

Source

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

Non-streaming completion.

Source

fn context_window(&self) -> usize

Maximum context window in tokens.

Source

fn privacy_tier(&self) -> PrivacyTier

Privacy tier this driver operates at.

Provided Methods§

Source

fn stream<'life0, 'async_trait>( &'life0 self, request: CompletionRequest, tx: Sender<StreamEvent>, ) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, AgentError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Streaming completion with channel-based events.

Default wraps complete() for drivers that don’t support native streaming. Override for token-by-token output.

Source

fn estimate_cost(&self, _usage: &TokenUsage) -> f64

Estimate cost in USD for a single completion’s token usage.

Default: 0.0 (sovereign/local inference is free). Remote drivers override with their pricing model.

Implementors§