1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! # 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
//!
//! ```rust
//! use llm_chain_tools::{ToolCollection, create_tool_prompt_segment};
//! use llm_chain_tools::tools::BashTool;
//! use std::boxed::Box;
//!
//! // Create a ToolCollection with some tools.
//! let mut tc = ToolCollection::new(vec![Box::new(BashTool::new())]);
//!
//! // Create a prompt indicating the LLM should use the provided tools.
//! let prompt = "Find information about Rust programming language.";
//! let tool_prompt = create_tool_prompt_segment(&tc, &prompt);
//! ```
//!
//! ## Modules
//!
//! - `tools`: A submodule that provides a variety of pre-defined tools.
use PromptTemplate;
pub use crateToolCollection;
pub use Tool;
/// Creates a prompt that indicates the model should use the tools provided.
///
/// This function takes a reference to a `ToolCollection` and a `&str` prompt, then generates a `PromptTemplate` that includes a prefix and a description of the tools in the collection. This formatted prompt can be passed to the LLM to request its use of the provided tools.
///
/// # Arguments
///
/// * `tc`: A reference to a `ToolCollection` containing the tools to be used by the LLM.
/// * `prompt`: The base prompt to be used in the request.
///
/// # Returns
///
/// A `PromptTemplate` formatted with the provided tools and prompt.