pub struct Tools { /* private fields */ }
Expand description
Tool registry for managing and calling tools by name.
§Example
use ai_types::llm::tool::Tools;
let mut tools = Tools::new();
// tools.register(Calculator);
let definitions = tools.definitions();
// let result = tools.call("calculator", r#"{"operation": "add", "a": 5, "b": 3}"#).await;
Implementations§
Source§impl Tools
impl Tools
Sourcepub fn definitions(&self) -> Vec<ToolDefinition>
pub fn definitions(&self) -> Vec<ToolDefinition>
Returns definitions of all registered tools.
Sourcepub fn register<T: Tool + 'static>(&mut self, tool: T)
pub fn register<T: Tool + 'static>(&mut self, tool: T)
Registers a new tool. Replaces existing tool with same name.
The tool must implement Tool
and be 'static
.
Sourcepub fn unregister(&mut self, name: &str)
pub fn unregister(&mut self, name: &str)
Removes a tool from the registry.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tools
impl !RefUnwindSafe for Tools
impl Send for Tools
impl !Sync for Tools
impl Unpin for Tools
impl !UnwindSafe for Tools
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