llm_chain/tools/mod.rs
1//! # Tool Access Module
2//!
3//! 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.
4//!
5//! The main components of this module are:
6//!
7//! - `Tool`: A struct that represents an individual tool that the LLM can use.
8//! - `ToolCollection`: A collection of `Tool` instances.
9//! - `create_tool_prompt_segment`: A function to create a prompt that indicates the model should use the provided tools.
10//!
11//! ## Example
12//!
13//! ```rust
14//! use llm_chain::tools::{ToolCollection, tools::BashTool};
15//! use llm_chain::prompt::StringTemplate;
16//! use std::boxed::Box;
17//!
18//! // Create a ToolCollection with a tool.
19//! let mut tc = ToolCollection::new();
20//! tc.add_tool(BashTool::new());
21//!
22//! // Create a prompt indicating the LLM should use the provided tools.
23//! let prompt = StringTemplate::static_string("Find information about Rust programming language.");
24//! let tool_prompt = StringTemplate::combine(vec![tc.to_prompt_template().unwrap(), prompt]);
25//! ```
26//!
27//! ## Modules
28//!
29//! - `tools`: A submodule that provides a variety of pre-defined tools.
30
31mod collection;
32mod description;
33#[cfg(feature = "multitool_default")]
34pub mod multitool_default;
35pub use description::{Describe, Format, FormatPart, ToolDescription};
36pub mod multitool;
37mod tool;
38#[allow(clippy::module_inception)]
39pub mod tools;
40
41pub use collection::{ToolCollection, ToolInvocationInput, ToolUseError};
42pub use tool::{Tool, ToolError};