pub struct Tool {
pub name: String,
pub description: Option<String>,
pub schema: Option<Value>,
}Expand description
Represents a tool definition that can be exposed to an agent.
This structure is used by ToolBox implementations in their tools_definitions
function to describe the available tools to the language model.
Note: While this struct defines a tool, actual tool invocation is handled
by a ToolBox implementing the ToolBox trait. You must use a ToolBox
to call any defined tool.
The name field is required, while description and schema are optional
but highly recommended for effective tool use by the agent.
Fields§
§name: StringThe tool name, which is typically the function name
e.g., get_weather
description: Option<String>The description of the tool that will be used by the LLM to understand the context/usage of this tool
schema: Option<Value>The JSON schema for the parameters e.g.,
json!({
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The city name"
},
"country": {
"type": "string",
"description": "The most likely country of this city name"
},
"unit": {
"type": "string",
"enum": ["C", "F"],
"description": "The temperature unit for the country. C for Celsius, and F for Fahrenheit"
}
},
"required": ["city", "country", "unit"],
})Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tool
impl<'de> Deserialize<'de> for Tool
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Tool, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Tool, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Tool
impl Serialize for Tool
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for Tool
impl RefUnwindSafe for Tool
impl Send for Tool
impl Sync for Tool
impl Unpin for Tool
impl UnwindSafe for Tool
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