pub struct BoundChatModel<M: ChatModel> { /* private fields */ }Expand description
A chat model that has been bound with tools (generic version).
This wraps an underlying chat model and includes tool definitions that will be passed to the model on each invocation.
Implementations§
Source§impl<M: ChatModel> BoundChatModel<M>
impl<M: ChatModel> BoundChatModel<M>
Sourcepub fn new(model: M, tools: Vec<Arc<dyn Tool + Send + Sync>>) -> Self
pub fn new(model: M, tools: Vec<Arc<dyn Tool + Send + Sync>>) -> Self
Create a new bound chat model.
Sourcepub fn with_tool_choice(self, tool_choice: ToolChoice) -> Self
pub fn with_tool_choice(self, tool_choice: ToolChoice) -> Self
Set the tool choice.
Sourcepub fn tool_definitions(&self) -> Vec<ToolDefinition>
pub fn tool_definitions(&self) -> Vec<ToolDefinition>
Get the tool definitions.
Sourcepub fn tool_choice(&self) -> Option<&ToolChoice>
pub fn tool_choice(&self) -> Option<&ToolChoice>
Get the tool choice.
Sourcepub async fn invoke(&self, messages: Vec<BaseMessage>) -> BaseMessage
pub async fn invoke(&self, messages: Vec<BaseMessage>) -> BaseMessage
Invoke the model with messages.
This generates a response using the bound tools.
Trait Implementations§
Auto Trait Implementations§
impl<M> Freeze for BoundChatModel<M>where
M: Freeze,
impl<M> !RefUnwindSafe for BoundChatModel<M>
impl<M> Send for BoundChatModel<M>
impl<M> Sync for BoundChatModel<M>
impl<M> Unpin for BoundChatModel<M>where
M: Unpin,
impl<M> !UnwindSafe for BoundChatModel<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more