Struct llm_chain::tools::ToolCollection
source · pub struct ToolCollection<T> { /* private fields */ }
Implementations§
source§impl<T> ToolCollection<T>where
T: Tool + Send + Sync,
impl<T> ToolCollection<T>where T: Tool + Send + Sync,
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> 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