pub struct Toolbox<T: Tool> { /* private fields */ }Expand description
A collection of tools available to an agent.
Generic over the tool type T to avoid dyn Trait.
All tools in a toolbox must be the same concrete type.
For heterogeneous tools, use an enum that implements Tool.
ⓘ
enum MyTools {
Calculator(Calculator),
WebSearch(WebSearch),
}
impl Tool for MyTools {
fn definition(&self) -> ToolDefinition {
match self {
Self::Calculator(t) => t.definition(),
Self::WebSearch(t) => t.definition(),
}
}
fn call(&self, args: Value) -> Io<Error, Value> {
match self {
Self::Calculator(t) => t.call(args),
Self::WebSearch(t) => t.call(args),
}
}
}Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Toolbox<T>
impl<T> RefUnwindSafe for Toolbox<T>where
T: RefUnwindSafe,
impl<T> Send for Toolbox<T>where
T: Send,
impl<T> Sync for Toolbox<T>where
T: Sync,
impl<T> Unpin for Toolbox<T>where
T: Unpin,
impl<T> UnsafeUnpin for Toolbox<T>
impl<T> UnwindSafe for Toolbox<T>where
T: 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