ToolBuilder

Struct ToolBuilder 

Source
pub struct ToolBuilder { /* private fields */ }
Expand description

Builder for creating tools at runtime

Implementations§

Source§

impl ToolBuilder

Source

pub fn new(name: impl Into<String>) -> ToolBuilder

Create a new tool builder with the given name

Source

pub fn title(self, title: impl Into<String>) -> ToolBuilder

Set the tool title (display name)

Source

pub fn description(self, description: impl Into<String>) -> ToolBuilder

Set the tool description

Source

pub fn param<T>(self, name: T, schema: JsonSchema) -> ToolBuilder
where T: Into<String>,

Add a parameter to the input schema

Source

pub fn required_param<T>(self, name: T, schema: JsonSchema) -> ToolBuilder
where T: Into<String>,

Add a required parameter

Source

pub fn string_param( self, name: impl Into<String>, description: impl Into<String>, ) -> ToolBuilder

Add a string parameter

Source

pub fn number_param( self, name: impl Into<String>, description: impl Into<String>, ) -> ToolBuilder

Add a number parameter

Source

pub fn integer_param( self, name: impl Into<String>, description: impl Into<String>, ) -> ToolBuilder

Add an integer parameter

Source

pub fn boolean_param( self, name: impl Into<String>, description: impl Into<String>, ) -> ToolBuilder

Add a boolean parameter

Source

pub fn output_schema(self, schema: ToolSchema) -> ToolBuilder

Set the output schema

Source

pub fn number_output(self) -> ToolBuilder

Set the output schema to expect a number result

Source

pub fn string_output(self) -> ToolBuilder

Set the output schema to expect a string result

Source

pub fn annotations(self, annotations: ToolAnnotations) -> ToolBuilder

Set annotations

Source

pub fn meta(self, meta: HashMap<String, Value>) -> ToolBuilder

Set meta information

Source

pub fn execute<F, Fut>(self, f: F) -> ToolBuilder
where F: Fn(Value) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Value, String>> + Send + 'static,

Set the execution function

Source

pub fn build(self) -> Result<DynamicTool, String>

Build the dynamic tool

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.