pub struct ToolDefinition {
pub name: String,
pub description: String,
pub parameters_json_schema: Value,
pub strict: Option<bool>,
pub outer_typed_dict_key: Option<String>,
}Expand description
Complete tool definition sent to the model.
This contains all the information a language model needs to understand and call a tool, including its name, description, and parameter schema.
Fields§
§name: StringTool name (must be a valid identifier).
description: StringHuman-readable description of what the tool does.
parameters_json_schema: ValueJSON Schema for the tool’s parameters.
strict: Option<bool>Whether to use strict mode for schema validation (OpenAI feature).
outer_typed_dict_key: Option<String>Key for outer typed dict (pydantic-ai compatibility).
Implementations§
Source§impl ToolDefinition
impl ToolDefinition
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
) -> ToolDefinition
pub fn new( name: impl Into<String>, description: impl Into<String>, ) -> ToolDefinition
Create a new tool definition.
Sourcepub fn with_parameters(self, schema: impl Into<Value>) -> ToolDefinition
pub fn with_parameters(self, schema: impl Into<Value>) -> ToolDefinition
Set the parameters schema.
Sourcepub fn with_strict(self, strict: bool) -> ToolDefinition
pub fn with_strict(self, strict: bool) -> ToolDefinition
Set strict mode.
Sourcepub fn with_outer_typed_dict_key(self, key: impl Into<String>) -> ToolDefinition
pub fn with_outer_typed_dict_key(self, key: impl Into<String>) -> ToolDefinition
Set the outer typed dict key.
Sourcepub fn description(&self) -> &str
pub fn description(&self) -> &str
Get the tool description.
Sourcepub fn parameters(&self) -> &Value
pub fn parameters(&self) -> &Value
Get the parameters schema.
Sourcepub fn to_openai_function(&self) -> Value
pub fn to_openai_function(&self) -> Value
Convert to OpenAI function format.
Sourcepub fn to_anthropic_tool(&self) -> Value
pub fn to_anthropic_tool(&self) -> Value
Convert to Anthropic tool format.
Trait Implementations§
Source§impl Clone for ToolDefinition
impl Clone for ToolDefinition
Source§fn clone(&self) -> ToolDefinition
fn clone(&self) -> ToolDefinition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToolDefinition
impl Debug for ToolDefinition
Source§impl<'de> Deserialize<'de> for ToolDefinition
impl<'de> Deserialize<'de> for ToolDefinition
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolDefinition, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolDefinition, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ToolDefinition
impl PartialEq for ToolDefinition
Source§impl Serialize for ToolDefinition
impl Serialize for ToolDefinition
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
impl StructuralPartialEq for ToolDefinition
Auto Trait Implementations§
impl Freeze for ToolDefinition
impl RefUnwindSafe for ToolDefinition
impl Send for ToolDefinition
impl Sync for ToolDefinition
impl Unpin for ToolDefinition
impl UnwindSafe for ToolDefinition
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