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 Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn capabilities(&self) -> ModelCapabilities { ... }
fn warm_up<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), LlmError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: '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§
Sourcefn generate<'life0, 'async_trait>(
&'life0 self,
request: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate<'life0, 'async_trait>(
&'life0 self,
request: LlmRequest,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Generate content from the LLM.
Provided Methods§
Sourcefn capabilities(&self) -> ModelCapabilities
fn capabilities(&self) -> ModelCapabilities
What this model supports — the ADK model-capability-declaration
pattern: the model states its capabilities instead of every caller
re-inferring them from the id string. The default derives a
conservative estimate from model_id; back-ends
with authoritative knowledge should override.
Sourcefn warm_up<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn warm_up<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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.