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§
Sourcefn 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 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.
Sourcefn context_window(&self) -> usize
fn context_window(&self) -> usize
Maximum context window in tokens.
Sourcefn privacy_tier(&self) -> PrivacyTier
fn privacy_tier(&self) -> PrivacyTier
Privacy tier this driver operates at.
Provided Methods§
Sourcefn 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 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.
Sourcefn estimate_cost(&self, _usage: &TokenUsage) -> f64
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.