pub struct ToolRegistry { /* private fields */ }Implementations§
Source§impl ToolRegistry
impl ToolRegistry
pub fn new() -> Self
pub fn register(&mut self, tool: Box<dyn Tool>)
pub fn get(&self, name: &str) -> Option<&dyn Tool>
pub async fn execute(&self, name: &str, args: Value) -> Result<ToolResult>
pub fn get_definitions(&self) -> Vec<ToolDefinition>
Sourcepub fn list_tools(&self) -> Vec<String>
pub fn list_tools(&self) -> Vec<String>
Examples found in repository?
examples/agent_with_tools.rs (line 17)
4async fn main() -> helios_engine::Result<()> {
5 // Load configuration
6 let config = Config::from_file("config.toml")?;
7
8 // Create an agent with tools
9 let mut agent = Agent::builder("ToolAgent")
10 .config(config)
11 .system_prompt("You are a helpful assistant with access to tools. Use them when needed.")
12 .tool(Box::new(CalculatorTool))
13 .tool(Box::new(EchoTool))
14 .max_iterations(5)
15 .build()?;
16
17 println!("Available tools: {:?}\n", agent.tool_registry().list_tools());
18
19 // Test calculator tool
20 let response = agent.chat("What is 25 * 4 + 10?").await?;
21 println!("Agent: {}\n", response);
22
23 // Test echo tool
24 let response = agent.chat("Can you echo this message: 'Hello from Helios!'").await?;
25 println!("Agent: {}\n", response);
26
27 Ok(())
28}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 !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