Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn execute<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        arguments: &'life1 Value,
        state: &'life2 GraphState,
    ) -> Pin<Box<dyn Future<Output = Result<ToolResult, ToolError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn name(&self) -> &str;
    fn description(&self) -> &str;

    // Provided methods
    fn argument_schema(&self) -> Value { ... }
    fn validate_arguments(&self, _arguments: &Value) -> Result<(), ToolError> { ... }
    fn requires_auth(&self) -> bool { ... }
    fn metadata(&self) -> HashMap<String, Value> { ... }
}
Expand description

Core trait for all tools

Required Methods§

Source

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

Execute the tool with given arguments

Source

fn name(&self) -> &str

Get the tool name

Source

fn description(&self) -> &str

Get the tool description

Provided Methods§

Source

fn argument_schema(&self) -> Value

Get the tool’s argument schema (JSON Schema)

Source

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

Validate tool arguments

Source

fn requires_auth(&self) -> bool

Check if the tool requires authentication

Source

fn metadata(&self) -> HashMap<String, Value>

Get tool metadata

Implementors§