pub struct DynamicTool { /* private fields */ }Expand description
A runtime-defined tool backed by one closure.
This is the only public dynamic execution surface; users never implement Rig’s object-safe dispatch mirror.
Implementations§
Source§impl DynamicTool
impl DynamicTool
Sourcepub fn new<F>(
name: impl Into<String>,
description: impl Into<String>,
parameters: Value,
callback: F,
) -> Selfwhere
F: for<'a> Fn(&'a mut ToolContext, Value) -> WasmBoxedFuture<'a, Result<ToolOutput, ToolExecutionError>> + WasmCompatSend + WasmCompatSync + 'static,
pub fn new<F>(
name: impl Into<String>,
description: impl Into<String>,
parameters: Value,
callback: F,
) -> Selfwhere
F: for<'a> Fn(&'a mut ToolContext, Value) -> WasmBoxedFuture<'a, Result<ToolOutput, ToolExecutionError>> + WasmCompatSend + WasmCompatSync + 'static,
Create a runtime-defined tool.
Sourcepub fn from_portable(tool: PortableDynamicTool) -> Self
pub fn from_portable(tool: PortableDynamicTool) -> Self
Adapt a context-free dynamic tool for the classic contextual registry.
The portable callback receives the same parsed JSON value and its
ToolOutput or ToolExecutionError is forwarded unchanged.
Sourcepub fn definition(&self) -> ToolDefinition
pub fn definition(&self) -> ToolDefinition
Provider-facing definition.
Trait Implementations§
Source§impl Clone for DynamicTool
impl Clone for DynamicTool
Source§fn clone(&self) -> DynamicTool
fn clone(&self) -> DynamicTool
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<M: CompletionModel + 'static> From<Agent<M>> for DynamicTool
impl<M: CompletionModel + 'static> From<Agent<M>> for DynamicTool
Source§impl From<PortableDynamicTool> for DynamicTool
impl From<PortableDynamicTool> for DynamicTool
Source§fn from(tool: PortableDynamicTool) -> Self
fn from(tool: PortableDynamicTool) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for DynamicTool
impl !UnwindSafe for DynamicTool
impl Freeze for DynamicTool
impl Send for DynamicTool
impl Sync for DynamicTool
impl Unpin for DynamicTool
impl UnsafeUnpin for DynamicTool
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