pub struct ToolCollection<T> { /* private fields */ }
Implementations§
Source§impl<T> ToolCollection<T>
impl<T> ToolCollection<T>
pub fn new() -> Self
pub fn add_tool(&mut self, tool: T)
pub async fn invoke( &self, name: &str, input: &Value, ) -> Result<Value, ToolUseError<<T as Tool>::Error>>
pub fn get_tool_invocation( &self, data: &str, ) -> Result<ToolInvocationInput, ToolUseError<<T as Tool>::Error>>
Sourcepub async fn process_chat_input(
&self,
data: &str,
) -> Result<String, ToolUseError<<T as Tool>::Error>>
pub async fn process_chat_input( &self, data: &str, ) -> Result<String, ToolUseError<<T as Tool>::Error>>
Process chat input and execute the appropriate tool.
The input string should contain a YAML block describing the tool invocation.
The YAML block should have a command
field and an input
field.
§Errors
Returns an OpaqueError
variant if the input is not a valid YAML or
if the specified tool is not found.
Sourcepub fn describe(&self) -> Result<String, ToolUseError<<T as Tool>::Error>>
pub fn describe(&self) -> Result<String, ToolUseError<<T as Tool>::Error>>
Generate a YAML-formatted string describing the available tools.
Sourcepub fn to_prompt_template(
&self,
) -> Result<StringTemplate, ToolUseError<<T as Tool>::Error>>
pub fn to_prompt_template( &self, ) -> Result<StringTemplate, ToolUseError<<T as Tool>::Error>>
Generate a prompt template for the tool collection. Combine it with a normal prompt template to perform your task.
Trait Implementations§
Source§impl<T: Default> Default for ToolCollection<T>
impl<T: Default> Default for ToolCollection<T>
Source§fn default() -> ToolCollection<T>
fn default() -> ToolCollection<T>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<T> Freeze for ToolCollection<T>
impl<T> RefUnwindSafe for ToolCollection<T>where
T: RefUnwindSafe,
impl<T> Send for ToolCollection<T>where
T: Send,
impl<T> Sync for ToolCollection<T>where
T: Sync,
impl<T> Unpin for ToolCollection<T>where
T: Unpin,
impl<T> UnwindSafe for ToolCollection<T>where
T: UnwindSafe,
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