pub trait BaseChatModel: Send + Sync {
// Required methods
fn model(&self) -> &str;
fn provider(&self) -> &str;
fn invoke<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
tools: Option<Vec<ToolDefinition>>,
tool_choice: Option<ToolChoice>,
) -> Pin<Box<dyn Future<Output = Result<ChatCompletion, LlmError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn invoke_stream<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
tools: Option<Vec<ToolDefinition>>,
tool_choice: Option<ToolChoice>,
) -> Pin<Box<dyn Future<Output = Result<ChatStream, LlmError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn context_window(&self) -> Option<u64> { ... }
fn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
) -> Pin<Box<dyn Future<Output = u64> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn supports_tools(&self) -> bool { ... }
fn supports_streaming(&self) -> bool { ... }
fn supports_vision(&self) -> bool { ... }
}Expand description
Base trait for chat model implementations
Required Methods§
Sourcefn invoke<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
tools: Option<Vec<ToolDefinition>>,
tool_choice: Option<ToolChoice>,
) -> Pin<Box<dyn Future<Output = Result<ChatCompletion, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
tools: Option<Vec<ToolDefinition>>,
tool_choice: Option<ToolChoice>,
) -> Pin<Box<dyn Future<Output = Result<ChatCompletion, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Invoke the model with messages
Sourcefn invoke_stream<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
tools: Option<Vec<ToolDefinition>>,
tool_choice: Option<ToolChoice>,
) -> Pin<Box<dyn Future<Output = Result<ChatStream, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke_stream<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
tools: Option<Vec<ToolDefinition>>,
tool_choice: Option<ToolChoice>,
) -> Pin<Box<dyn Future<Output = Result<ChatStream, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Invoke the model with streaming response
Provided Methods§
Sourcefn context_window(&self) -> Option<u64>
fn context_window(&self) -> Option<u64>
Get the context window size (max input tokens)
Sourcefn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
) -> Pin<Box<dyn Future<Output = u64> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
) -> Pin<Box<dyn Future<Output = u64> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Count tokens in messages (approximate)
Sourcefn supports_tools(&self) -> bool
fn supports_tools(&self) -> bool
Check if the model supports tools
Sourcefn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
Check if the model supports streaming
Sourcefn supports_vision(&self) -> bool
fn supports_vision(&self) -> bool
Check if the model supports vision