pub struct Tool {
pub name: String,
pub description: Option<String>,
pub input_schema: JsonSchema,
pub cache_control: Option<CacheControl>,
}Expand description
Tool definition for the Anthropic API
Fields§
§name: StringName of the tool
description: Option<String>Description of what the tool does
input_schema: JsonSchemaJSON schema for the tool’s input parameters
cache_control: Option<CacheControl>Cache control for prompt caching
Implementations§
Source§impl Tool
impl Tool
Sourcepub fn description<S: AsRef<str>>(&mut self, desc: S) -> &mut Self
pub fn description<S: AsRef<str>>(&mut self, desc: S) -> &mut Self
Set the tool description
Sourcepub fn add_string_property<S: AsRef<str>>(
&mut self,
name: S,
description: Option<S>,
required: bool,
) -> &mut Self
pub fn add_string_property<S: AsRef<str>>( &mut self, name: S, description: Option<S>, required: bool, ) -> &mut Self
Add a string property to the input schema
Sourcepub fn add_number_property<S: AsRef<str>>(
&mut self,
name: S,
description: Option<S>,
required: bool,
) -> &mut Self
pub fn add_number_property<S: AsRef<str>>( &mut self, name: S, description: Option<S>, required: bool, ) -> &mut Self
Add a number property to the input schema
Sourcepub fn add_boolean_property<S: AsRef<str>>(
&mut self,
name: S,
description: Option<S>,
required: bool,
) -> &mut Self
pub fn add_boolean_property<S: AsRef<str>>( &mut self, name: S, description: Option<S>, required: bool, ) -> &mut Self
Add a boolean property to the input schema
Sourcepub fn add_enum_property<S: AsRef<str>>(
&mut self,
name: S,
description: Option<S>,
values: Vec<S>,
required: bool,
) -> &mut Self
pub fn add_enum_property<S: AsRef<str>>( &mut self, name: S, description: Option<S>, values: Vec<S>, required: bool, ) -> &mut Self
Add an enum property to the input schema
Sourcepub fn add_array_property<S: AsRef<str>>(
&mut self,
name: S,
description: Option<S>,
items: PropertyDef,
required: bool,
) -> &mut Self
pub fn add_array_property<S: AsRef<str>>( &mut self, name: S, description: Option<S>, items: PropertyDef, required: bool, ) -> &mut Self
Add an array property to the input schema
Sourcepub fn with_cache(&mut self) -> &mut Self
pub fn with_cache(&mut self) -> &mut Self
Enable cache control for this tool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tool
impl<'de> Deserialize<'de> for Tool
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more