pub struct ToolDefinition { /* private fields */ }Expand description
Tool definition including schema for language models.
Used to provide language models with information about available Tools.
Implementations§
Source§impl ToolDefinition
impl ToolDefinition
Sourcepub fn new<T: Tool>(tool: &T) -> Self
pub fn new<T: Tool>(tool: &T) -> Self
Creates a tool definition for a given tool type.
The description comes from Tool::description, which by default reads
the rustdoc on the tool’s Arguments type.
Sourcepub fn from_parts(
name: Cow<'static, str>,
description: Cow<'static, str>,
schema: Value,
) -> Result<Self, InvalidSchema>
pub fn from_parts( name: Cow<'static, str>, description: Cow<'static, str>, schema: Value, ) -> Result<Self, InvalidSchema>
Creates a tool definition from raw parts.
This is useful for creating definitions from external sources like MCP servers.
§Errors
Returns InvalidSchema if the value is not a JSON schema — that is,
anything other than an object or a boolean. The schema often comes from
a remote server, so this is a rejection to report, not a bug to panic
on.
Sourcepub fn description(&self) -> &str
pub fn description(&self) -> &str
Returns the tool’s description.
Sourcepub fn arguments_openai_schema(&self) -> Value
pub fn arguments_openai_schema(&self) -> Value
Return an OpenAI-compatible JSON schema for the tool’s arguments.
This schema would have an object type at the root, as required by OpenAI.
Trait Implementations§
Source§impl Clone for ToolDefinition
impl Clone for ToolDefinition
Source§fn clone(&self) -> ToolDefinition
fn clone(&self) -> ToolDefinition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more