pub struct ToolRegistry { /* private fields */ }Expand description
Registry that manages all available tools.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
pub fn new() -> Self
Sourcepub fn register(&mut self, tool: impl Tool + 'static)
pub fn register(&mut self, tool: impl Tool + 'static)
Register a tool. Overwrites any existing tool with the same name.
Sourcepub fn tool_names(&self) -> Vec<&str>
pub fn tool_names(&self) -> Vec<&str>
Get a list of all registered tool names.
Sourcepub fn tool_schemas(&self) -> Vec<ChatCompletionTools>
pub fn tool_schemas(&self) -> Vec<ChatCompletionTools>
Generate OpenAI function calling schemas for all registered tools.
Sourcepub async fn execute(
&self,
name: &str,
args: Value,
ctx: &ToolContext,
) -> ToolResult
pub async fn execute( &self, name: &str, args: Value, ctx: &ToolContext, ) -> ToolResult
Execute a tool by name. Returns an error ToolResult if the tool doesn’t exist.
Sourcepub fn requires_confirmation(&self, name: &str) -> bool
pub fn requires_confirmation(&self, name: &str) -> bool
Check if a tool requires confirmation.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ToolRegistry
impl !UnwindSafe for ToolRegistry
impl Freeze for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl UnsafeUnpin for ToolRegistry
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