pub trait LlmProvider: Send + Sync {
// Required methods
fn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolDef],
) -> Pin<Box<dyn Future<Output = Result<LlmResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn name(&self) -> &str;
fn context_window(&self) -> u64;
fn default_model(&self) -> &str;
// Provided methods
fn chat_streaming<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolDef],
token_tx: &'life3 UnboundedSender<String>,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn supports_streaming(&self) -> bool { ... }
}Required Methods§
Sourcefn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolDef],
) -> Pin<Box<dyn Future<Output = Result<LlmResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolDef],
) -> Pin<Box<dyn Future<Output = Result<LlmResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Send messages + tool definitions, receive a response.
Sourcefn context_window(&self) -> u64
fn context_window(&self) -> u64
Context window size in tokens.
Sourcefn default_model(&self) -> &str
fn default_model(&self) -> &str
Default model name.
Provided Methods§
Sourcefn chat_streaming<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolDef],
token_tx: &'life3 UnboundedSender<String>,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn chat_streaming<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolDef],
token_tx: &'life3 UnboundedSender<String>,
) -> Pin<Box<dyn Future<Output = Result<LlmResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Stream text tokens via token_tx while accumulating the full response.
The default falls back to chat() and delivers the entire text as one chunk.
Sourcefn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
Whether this provider supports true token-by-token streaming.
Providers that override chat_streaming with SSE should return true.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".