Tool

Trait Tool 

Source
pub trait Tool:
    Sized
    + Send
    + Sync {
    const NAME: &'static str;

    // Required methods
    fn description(&self) -> String;
    fn needs_confirmation(&self, input: &Value) -> bool;
    fn may_perform_edits(&self) -> bool;
    fn ui_text(&self, input: &Value) -> String;
    fn run(
        &self,
        input: Value,
    ) -> impl Future<Output = Result<ToolResultContent>> + Send;

    // Provided methods
    fn name(&self) -> String { ... }
    fn source(&self) -> ToolSource { ... }
    fn input_schema(&self, _: LanguageModelToolSchemaFormat) -> Result<Value> { ... }
}
Expand description

A tool that can be used by a language model.

Required Associated Constants§

Source

const NAME: &'static str

Required Methods§

Source

fn description(&self) -> String

Returns the description of the tool.

Source

fn needs_confirmation(&self, input: &Value) -> bool

Returns true if the tool needs the users’s confirmation before having permission to run.

Source

fn may_perform_edits(&self) -> bool

Returns true if the tool may perform edits.

Source

fn ui_text(&self, input: &Value) -> String

Source

fn run( &self, input: Value, ) -> impl Future<Output = Result<ToolResultContent>> + Send

Runs the tool with the provided input.

Provided Methods§

Source

fn name(&self) -> String

Returns the name of the tool.

Source

fn source(&self) -> ToolSource

Returns the source of the tool.

Source

fn input_schema(&self, _: LanguageModelToolSchemaFormat) -> Result<Value>

Returns the JSON schema that describes the tool’s input.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§