Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn parameters(&self) -> Value;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        args: Value,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn validate_params(&self, params: &Value) -> Vec<String> { ... }
    fn to_schema(&self) -> Value { ... }
}
Expand description

Trait for tools.

Required Methods§

Source

fn name(&self) -> &str

Get the tool name.

Source

fn description(&self) -> &str

Get the tool description.

Source

fn parameters(&self) -> Value

Get the tool parameters schema (JSON Schema format).

Source

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

Execute the tool with arguments.

Provided Methods§

Source

fn validate_params(&self, params: &Value) -> Vec<String>

Validate parameters against the schema.

Source

fn to_schema(&self) -> Value

Convert tool to OpenAI function schema format.

Implementors§