BaseLlm

Trait BaseLlm 

pub trait BaseLlm: Send + Sync {
    // Required methods
    fn model_id(&self) -> &str;
    fn generate<'life0, 'async_trait>(
        &'life0 self,
        request: LlmRequest,
    ) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided method
    fn warm_up<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), LlmError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Trait for LLM providers — decouples agents from specific models.

Implementations must be Send + Sync for use across async tasks.

Required Methods§

fn model_id(&self) -> &str

The model identifier (e.g., “gemini-2.5-flash”).

fn generate<'life0, 'async_trait>( &'life0 self, request: LlmRequest, ) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Generate content from the LLM.

Provided Methods§

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

Pre-warm the HTTP connection pool to avoid cold-start latency.

The default implementation is a no-op. GeminiLlm overrides this to establish the TCP+TLS connection so the first real generate() call doesn’t pay the ~100-300ms handshake penalty.

Implementors§