pub struct FunctionTool { /* private fields */ }Expand description
A function-based tool implementation
Implementations§
Source§impl FunctionTool
impl FunctionTool
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
json_schema: Value,
handler: impl Fn(&RunContext, Value) -> Result<String> + Send + Sync + 'static,
) -> Self
pub fn new( name: impl Into<String>, description: impl Into<String>, json_schema: Value, handler: impl Fn(&RunContext, Value) -> Result<String> + Send + Sync + 'static, ) -> Self
Create a new function tool
Sourcepub fn builder(name: impl Into<String>) -> FunctionToolBuilder
pub fn builder(name: impl Into<String>) -> FunctionToolBuilder
Builder for creating function tools
Trait Implementations§
Source§impl Tool for FunctionTool
impl Tool for FunctionTool
Source§fn description(&self) -> &str
fn description(&self) -> &str
A description of what the tool does
Source§fn json_schema(&self) -> Value
fn json_schema(&self) -> Value
JSON schema for the tool’s parameters
Source§fn invoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 RunContext,
args: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn invoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 RunContext,
args: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Invoke the tool with the given context and arguments Read more
Auto Trait Implementations§
impl !RefUnwindSafe for FunctionTool
impl !UnwindSafe for FunctionTool
impl Freeze for FunctionTool
impl Send for FunctionTool
impl Sync for FunctionTool
impl Unpin for FunctionTool
impl UnsafeUnpin for FunctionTool
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