Trait llm_chain::tools::Tool

source ·
pub trait Tool {
    // Required methods
    fn description(&self) -> ToolDescription;
    fn invoke(&self, input: Value) -> Result<Value, ToolUseError>;

    // Provided method
    fn matches(&self, name: &str) -> bool { ... }
}
Expand description

The Tool trait defines an interface for tools that can be added to a ToolCollection.

A Tool is a function that takes a YAML-formatted input and returns a YAML-formatted output. It has a description that contains metadata about the tool, such as its name and usage.

Required Methods§

source

fn description(&self) -> ToolDescription

Returns the ToolDescription containing metadata about the tool.

source

fn invoke(&self, input: Value) -> Result<Value, ToolUseError>

Invokes the tool with the given YAML-formatted input.

Errors

Returns an ToolUseError if the input is not in the expected format or if the tool fails to produce a valid output.

Provided Methods§

source

fn matches(&self, name: &str) -> bool

Checks whether the tool matches the given name.

This function is used to find the appropriate tool in a ToolCollection based on its name.

Implementors§