Skip to main content

ToolExecutor

Trait ToolExecutor 

Source
pub trait ToolExecutor: Send + Sync {
    // Required methods
    fn execute_tool<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        args: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn available_tools<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn has_tool<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn execute_tool_ref<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        args: &'life2 Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn execute_shared<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        args: Arc<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<Arc<Value>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn execute_batch<'life0, 'async_trait>(
        &'life0 self,
        calls: Vec<(String, Value)>,
    ) -> Pin<Box<dyn Future<Output = Vec<Result<Value>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Main tool executor that coordinates all tools

Required Methods§

Source

fn execute_tool<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, args: Value, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute a tool by name

Source

fn available_tools<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List available tools

Source

fn has_tool<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a tool exists

Provided Methods§

Source

fn execute_tool_ref<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, args: &'life2 Value, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Execute a tool with a reference to arguments to avoid cloning when caller already holds a reference.

Source

fn execute_shared<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, args: Arc<Value>, ) -> Pin<Box<dyn Future<Output = Result<Arc<Value>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute a tool and return a shared result (Arc) to avoid cloning results for callers that want to keep a shared reference.

Source

fn execute_batch<'life0, 'async_trait>( &'life0 self, calls: Vec<(String, Value)>, ) -> Pin<Box<dyn Future<Output = Vec<Result<Value>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute multiple tools in batch.

The default implementation runs them sequentially. Implementors can override this to provide parallel execution.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§