pub struct ToolRegistry { /* private fields */ }Expand description
Maps tool names to factory functions for instantiation from config.
§Example
use phi_core::tools::ToolRegistry;
let registry = ToolRegistry::new().with_defaults();
let tools = registry.resolve(&["bash".to_string(), "read_file".to_string()]);
assert_eq!(tools.len(), 2);Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn with_defaults(self) -> Self
pub fn with_defaults(self) -> Self
Register all 6 built-in tools.
Sourcepub fn register(
&mut self,
name: &str,
factory: impl Fn() -> Arc<dyn AgentTool> + Send + Sync + 'static,
)
pub fn register( &mut self, name: &str, factory: impl Fn() -> Arc<dyn AgentTool> + Send + Sync + 'static, )
Register a tool factory under the given name.
If a factory with the same name already exists, it is replaced.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ToolRegistry
impl !RefUnwindSafe for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl UnsafeUnpin for ToolRegistry
impl !UnwindSafe 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