pub trait BaseChatModel: BaseLanguageModel<Vec<Message>, LLMResult> {
// Required methods
fn chat<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn stream_chat<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<String, Self::Error>> + Send>>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn chat_with_system<'life0, 'async_trait>(
&'life0 self,
system: String,
messages: Vec<Message>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn bind_tools(
&self,
_tools: Vec<ToolDefinition>,
) -> Option<Box<dyn BaseChatModel<Error = Self::Error> + Send + Sync>> { ... }
}Expand description
Base trait for chat models.
Extends BaseLanguageModel for chat scenarios. Accepts message list as input, returns AI message.
Required Methods§
Sourcefn chat<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn stream_chat<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<String, Self::Error>> + Send>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream_chat<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
config: Option<RunnableConfig>,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<String, Self::Error>> + Send>>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Provided Methods§
Sourcefn chat_with_system<'life0, 'async_trait>(
&'life0 self,
system: String,
messages: Vec<Message>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn chat_with_system<'life0, 'async_trait>(
&'life0 self,
system: String,
messages: Vec<Message>,
) -> Pin<Box<dyn Future<Output = Result<LLMResult, Self::Error>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Sourcefn bind_tools(
&self,
_tools: Vec<ToolDefinition>,
) -> Option<Box<dyn BaseChatModel<Error = Self::Error> + Send + Sync>>
fn bind_tools( &self, _tools: Vec<ToolDefinition>, ) -> Option<Box<dyn BaseChatModel<Error = Self::Error> + Send + Sync>>
Bind tool definitions for function calling.
Returns None by default if the provider does not support tool binding.
Providers that support function calling (OpenAI, Ollama) override this
to return a boxed chat model with the tools attached.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".