llm_chain

Module tools

Source
Expand description

§Tool Access Module

This crate provides a collection of tools that can be used to grant the LLM (Large Language Model) access to various utilities, such as running Bash commands on your computer or performing web searches.

The main components of this module are:

  • Tool: A struct that represents an individual tool that the LLM can use.
  • ToolCollection: A collection of Tool instances.
  • create_tool_prompt_segment: A function to create a prompt that indicates the model should use the provided tools.

§Example

use llm_chain::tools::{ToolCollection, tools::BashTool};
use llm_chain::prompt::StringTemplate;
use std::boxed::Box;

// Create a ToolCollection with a tool.
let mut tc = ToolCollection::new();
tc.add_tool(BashTool::new());

// Create a prompt indicating the LLM should use the provided tools.
let prompt = StringTemplate::static_string("Find information about Rust programming language.");
let tool_prompt = StringTemplate::combine(vec![tc.to_prompt_template().unwrap(), prompt]);

§Modules

  • tools: A submodule that provides a variety of pre-defined tools.

Modules§

multitool
tools
Commonly used tools ready to import

Structs§

Format
Represents the format for a tool’s input or output.
FormatPart
Represents a single parameter for a tool.
ToolCollection
ToolDescription
Represents the description of a tool, including its name, usage, and input/output formats.
ToolInvocationInput

Enums§

ToolUseError

Traits§

Describe
A trait to provide a description format for a tool.
Tool
The Tool trait defines an interface for tools that can be added to a ToolCollection.
ToolError
Marker trait for Tool errors. It is needed so the concrete Errors can have a derived From<ToolError>