Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn definition(&self) -> Value;
    fn call<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        args: &'life1 Value,
        ctx: &'life2 ToolContext,
    ) -> Pin<Box<dyn Future<Output = AgentResult<ToolOutput>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn as_framework_tool(&self) -> Option<&dyn FrameworkTool> { ... }
}

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn definition(&self) -> Value

Source

fn call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, args: &'life1 Value, ctx: &'life2 ToolContext, ) -> Pin<Box<dyn Future<Output = AgentResult<ToolOutput>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Provided Methods§

Source

fn as_framework_tool(&self) -> Option<&dyn FrameworkTool>

Return Some(&dyn FrameworkTool) if this tool is a framework-internal tool that needs engine infrastructure injection (EventBus). Default returns None — user-defined tools need not override this.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§