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§
Required Methods§
Sourcefn description(&self) -> String
fn description(&self) -> String
Returns the description of the tool.
Sourcefn needs_confirmation(&self, input: &Value) -> bool
fn needs_confirmation(&self, input: &Value) -> bool
Returns true if the tool needs the users’s confirmation before having permission to run.
Sourcefn may_perform_edits(&self) -> bool
fn may_perform_edits(&self) -> bool
Returns true if the tool may perform edits.
fn ui_text(&self, input: &Value) -> String
Provided Methods§
Sourcefn source(&self) -> ToolSource
fn source(&self) -> ToolSource
Returns the source of the tool.
Sourcefn input_schema(&self, _: LanguageModelToolSchemaFormat) -> Result<Value>
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.