Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn schema(&self) -> ToolSchema;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        context: &'life1 ExecutionContext,
        arguments: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn validate(&self, _arguments: &Value) -> Result<(), ToolError> { ... }
}
Expand description

Tool/function trait

Required Methods§

Source

fn schema(&self) -> ToolSchema

Get tool schema

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, context: &'life1 ExecutionContext, arguments: Value, ) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute the tool

Provided Methods§

Source

fn validate(&self, _arguments: &Value) -> Result<(), ToolError>

Validate arguments before execution

Implementors§