pub struct FunctionTool { /* private fields */ }Expand description
A single-struct tool that carries metadata, JSON schema, and an async handler
Implementations§
Source§impl FunctionTool
impl FunctionTool
pub fn builder( name: impl Into<String>, description: impl Into<String>, ) -> FunctionToolBuilder
Sourcepub fn from_schema<F, Fut>(
name: impl Into<String>,
description: impl Into<String>,
schema: Value,
f: F,
) -> ToolResult<FunctionTool>
pub fn from_schema<F, Fut>( name: impl Into<String>, description: impl Into<String>, schema: Value, f: F, ) -> ToolResult<FunctionTool>
Convenience: build a FunctionTool directly from a full JSON schema and a handler
Sourcepub fn from_function_spec<F, Fut>(spec: Value, f: F) -> ToolResult<FunctionTool>
pub fn from_function_spec<F, Fut>(spec: Value, f: F) -> ToolResult<FunctionTool>
Build a FunctionTool from a full JSON spec (supports two shapes):
- {“name”:…, “description”:…, “parameters”: {…}}
- {“type”:“function”, “function”: {“name”:…, “description”:…, “parameters”: {…}}}
Sourcepub fn from_function_spec_file<F, Fut>(
path: impl AsRef<Path>,
f: F,
) -> ToolResult<FunctionTool>
pub fn from_function_spec_file<F, Fut>( path: impl AsRef<Path>, f: F, ) -> ToolResult<FunctionTool>
Read a JSON function spec from a file and build a FunctionTool.
Trait Implementations§
Source§impl Clone for FunctionTool
impl Clone for FunctionTool
Source§impl DynTool for FunctionTool
impl DynTool for FunctionTool
Source§fn metadata(&self) -> &ToolMetadata
fn metadata(&self) -> &ToolMetadata
Get the tool’s metadata
Source§fn execute_json<'life0, 'async_trait>(
&'life0 self,
input: Value,
) -> Pin<Box<dyn Future<Output = ToolResult<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute_json<'life0, 'async_trait>(
&'life0 self,
input: Value,
) -> Pin<Box<dyn Future<Output = ToolResult<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute with JSON input/output
Source§fn input_schema(&self) -> Value
fn input_schema(&self) -> Value
Get input schema
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