Skip to main content

Tool

Trait Tool 

Source
pub trait Tool<R> {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn parameter_schema(&self) -> Value;
    fn invoke<'lt>(
        &'lt mut self,
        data: &str,
    ) -> Box<dyn Future<Output = ControlFlow<R, String>> + 'lt>;
}

Required Methods§

Source

fn name(&self) -> &str

Returns the name of the tool. May not change between calls.

Source

fn description(&self) -> &str

The description of the tool, provided to the LLM.

Source

fn parameter_schema(&self) -> Value

The JSON schema of the tool parameters.

Source

fn invoke<'lt>( &'lt mut self, data: &str, ) -> Box<dyn Future<Output = ControlFlow<R, String>> + 'lt>

Invokes the tool with data as the provided parameters. It is assumed that the LLM ensures that the parameters match the JSON schema.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§