pub struct ToolWrapper { /* private fields */ }Expand description
Wraps an agent (broker + tools + behaviour) as an LlmTool
This allows agents to be used as tools by other agents (delegation pattern). The tool’s descriptor has a single “input” parameter (string). When run, it creates initial messages from the agent’s behaviour, appends the input, and calls the agent’s broker.
Implementations§
Source§impl ToolWrapper
impl ToolWrapper
Sourcepub fn new(
broker: Arc<LlmBroker>,
tools: Vec<Box<dyn LlmTool>>,
behaviour: impl Into<String>,
name: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn new( broker: Arc<LlmBroker>, tools: Vec<Box<dyn LlmTool>>, behaviour: impl Into<String>, name: impl Into<String>, description: impl Into<String>, ) -> Self
Create a new ToolWrapper
§Arguments
broker- The LLM broker for this agenttools- The tools available to this agentbehaviour- The system message defining the agent’s behaviourname- The name of this tool (how other agents will call it)description- Description of what this agent/tool does
Trait Implementations§
Source§impl LlmTool for ToolWrapper
impl LlmTool for ToolWrapper
Source§fn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 HashMap<String, Value>,
_ctx: &'life2 ToolRunCtx,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 HashMap<String, Value>,
_ctx: &'life2 ToolRunCtx,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute the tool with given arguments.
Source§fn descriptor(&self) -> ToolDescriptor
fn descriptor(&self) -> ToolDescriptor
Get tool descriptor for LLM
Auto Trait Implementations§
impl !RefUnwindSafe for ToolWrapper
impl !UnwindSafe for ToolWrapper
impl Freeze for ToolWrapper
impl Send for ToolWrapper
impl Sync for ToolWrapper
impl Unpin for ToolWrapper
impl UnsafeUnpin for ToolWrapper
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