pub struct SimpleTool<F>where
F: Fn(Value, RequestHandlerExtra) -> Pin<Box<dyn Future<Output = Result<Value>> + Send>> + Send + Sync,{ /* private fields */ }Available on non-WebAssembly only.
Expand description
A simple tool implementation with schema support.
Implementations§
Source§impl<F> SimpleTool<F>
impl<F> SimpleTool<F>
Sourcepub fn new(name: impl Into<String>, handler: F) -> Self
pub fn new(name: impl Into<String>, handler: F) -> Self
Create a new tool with a name and handler.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set the description for this tool.
Sourcepub fn with_schema(self, schema: Value) -> Self
pub fn with_schema(self, schema: Value) -> Self
Set the input schema for this tool.
Trait Implementations§
Source§impl<F> Debug for SimpleTool<F>
impl<F> Debug for SimpleTool<F>
Source§impl<F> SimpleToolExt for SimpleTool<F>
impl<F> SimpleToolExt for SimpleTool<F>
Source§fn with_schema_from<T: JsonSchema>(self) -> Self
fn with_schema_from<T: JsonSchema>(self) -> Self
Available on crate feature
schema-generation only.Create a
SimpleTool with schema generated from a type.Source§impl<F> ToolHandler for SimpleTool<F>
impl<F> ToolHandler for SimpleTool<F>
Source§fn handle<'life0, 'async_trait>(
&'life0 self,
args: Value,
extra: RequestHandlerExtra,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
args: Value,
extra: RequestHandlerExtra,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a tool call with the given arguments.
Source§fn metadata(&self) -> Option<ToolInfo>
fn metadata(&self) -> Option<ToolInfo>
Get tool metadata including description and schema.
Returns None to use default empty metadata.
Source§fn handle_output<'life0, 'async_trait>(
&'life0 self,
args: Value,
extra: RequestHandlerExtra,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle_output<'life0, 'async_trait>(
&'life0 self,
args: Value,
extra: RequestHandlerExtra,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Produce the tool’s
ToolOutput for a call. Read moreAuto Trait Implementations§
impl<F> Freeze for SimpleTool<F>where
F: Freeze,
impl<F> RefUnwindSafe for SimpleTool<F>where
F: RefUnwindSafe,
impl<F> Send for SimpleTool<F>
impl<F> Sync for SimpleTool<F>
impl<F> Unpin for SimpleTool<F>where
F: Unpin,
impl<F> UnsafeUnpin for SimpleTool<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for SimpleTool<F>where
F: UnwindSafe,
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