#[non_exhaustive]pub struct Tool {
pub name: Cow<'static, str>,
pub title: Option<String>,
pub description: Option<Cow<'static, str>>,
pub input_schema: Arc<Map<String, Value>>,
pub output_schema: Option<Arc<Map<String, Value>>>,
pub annotations: Option<ToolAnnotations>,
pub icons: Option<Vec<Icon>>,
pub meta: Option<MetaObject>,
}Expand description
A tool that can be used by a model.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: Cow<'static, str>The name of the tool
title: Option<String>A human-readable title for the tool
description: Option<Cow<'static, str>>A description of what the tool does
input_schema: Arc<Map<String, Value>>A JSON Schema object defining the expected parameters for the tool
output_schema: Option<Arc<Map<String, Value>>>An optional JSON Schema object defining the structure of the tool’s output
annotations: Option<ToolAnnotations>Optional additional tool information.
icons: Option<Vec<Icon>>Optional list of icons for the tool
meta: Option<MetaObject>Optional additional metadata for this tool
Implementations§
Source§impl Tool
impl Tool
Sourcepub fn new<N, D, S>(name: N, description: D, input_schema: S) -> Tool
pub fn new<N, D, S>(name: N, description: D, input_schema: S) -> Tool
Create a new tool with the given name and description
Sourcepub fn new_with_raw<N, S>(
name: N,
description: Option<Cow<'static, str>>,
input_schema: S,
) -> Tool
pub fn new_with_raw<N, S>( name: N, description: Option<Cow<'static, str>>, input_schema: S, ) -> Tool
Create a new tool with just a name and input schema (no description)
Sourcepub fn with_title(self, title: impl Into<String>) -> Tool
pub fn with_title(self, title: impl Into<String>) -> Tool
Set the human-readable title
Sourcepub fn with_raw_output_schema(
self,
output_schema: Arc<Map<String, Value>>,
) -> Tool
pub fn with_raw_output_schema( self, output_schema: Arc<Map<String, Value>>, ) -> Tool
Set the output schema from a raw value
Sourcepub fn with_annotations(self, annotations: ToolAnnotations) -> Tool
pub fn with_annotations(self, annotations: ToolAnnotations) -> Tool
Set the annotations
Sourcepub fn with_icons(self, icons: Vec<Icon>) -> Tool
pub fn with_icons(self, icons: Vec<Icon>) -> Tool
Set the icons
Sourcepub fn with_meta(self, meta: MetaObject) -> Tool
pub fn with_meta(self, meta: MetaObject) -> Tool
Set the metadata
pub fn annotate(self, annotations: ToolAnnotations) -> Tool
Sourcepub fn with_output_schema<T>(self) -> Toolwhere
T: JsonSchema + 'static,
pub fn with_output_schema<T>(self) -> Toolwhere
T: JsonSchema + 'static,
Set the output schema using a type that implements JsonSchema
Sourcepub fn with_input_schema<T>(self) -> Toolwhere
T: JsonSchema + 'static,
pub fn with_input_schema<T>(self) -> Toolwhere
T: JsonSchema + 'static,
Set the input schema using a type that implements JsonSchema
Sourcepub fn schema_as_json_value(&self) -> Value
pub fn schema_as_json_value(&self) -> Value
Get the schema as json value
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>,
Source§impl JsonSchema for Tool
impl JsonSchema for Tool
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§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,
impl StructuralPartialEq for Tool
Auto Trait Implementations§
impl Freeze for Tool
impl RefUnwindSafe for Tool
impl Send for Tool
impl Sync for Tool
impl Unpin for Tool
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
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> ⓘ
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