pub struct ToolBuilder<I> { /* private fields */ }Expand description
Builds a Tool. I is the input type handed to the execute closure.
Implementations§
Source§impl<I> ToolBuilder<I>
impl<I> ToolBuilder<I>
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Fixed description.
Sourcepub fn description_fn<F, Fut>(self, function: F) -> Self
pub fn description_fn<F, Fut>(self, function: F) -> Self
Description computed per call.
Sourcepub fn input_schema(self, schema: Schema<JsonValue>) -> Self
pub fn input_schema(self, schema: Schema<JsonValue>) -> Self
Replaces the input schema (keeps the closure input type).
Sourcepub fn output_schema(self, schema: Schema<JsonValue>) -> Self
pub fn output_schema(self, schema: Schema<JsonValue>) -> Self
Output schema.
Sourcepub fn context_schema(self, schema: Schema<JsonValue>) -> Self
pub fn context_schema(self, schema: Schema<JsonValue>) -> Self
Context schema.
Sourcepub fn needs_approval(self, needs_approval: NeedsApproval) -> Self
pub fn needs_approval(self, needs_approval: NeedsApproval) -> Self
Approval declaration.
Sourcepub fn needs_approval_if<F, Fut>(self, function: F) -> Self
pub fn needs_approval_if<F, Fut>(self, function: F) -> Self
Approval decided per call from the validated input.
Sourcepub fn input_example(self, example: JsonObject) -> Self
pub fn input_example(self, example: JsonObject) -> Self
Adds an example input.
Sourcepub fn input_examples(
self,
examples: impl IntoIterator<Item = JsonObject>,
) -> Self
pub fn input_examples( self, examples: impl IntoIterator<Item = JsonObject>, ) -> Self
Adds example inputs.
Sourcepub fn metadata(self, metadata: JsonObject) -> Self
pub fn metadata(self, metadata: JsonObject) -> Self
Metadata propagated to tool calls.
Sourcepub fn provider_options(self, options: ProviderOptions) -> Self
pub fn provider_options(self, options: ProviderOptions) -> Self
Provider options sent with the definition.
Sourcepub fn on_input_start<F, Fut>(self, function: F) -> Self
pub fn on_input_start<F, Fut>(self, function: F) -> Self
Hook called when the model starts producing input.
Sourcepub fn on_input_delta<F, Fut>(self, function: F) -> Self
pub fn on_input_delta<F, Fut>(self, function: F) -> Self
Hook called for each input delta.
Sourcepub fn on_input_available<F, Fut>(self, function: F) -> Self
pub fn on_input_available<F, Fut>(self, function: F) -> Self
Hook called once the input is complete and valid.
Sourcepub fn to_model_output<F>(self, function: F) -> Self
pub fn to_model_output<F>(self, function: F) -> Self
Custom conversion of the output into what the model receives.
Sourcepub fn caller(self, definition: ToolCallerDefinition) -> Self
pub fn caller(self, definition: ToolCallerDefinition) -> Self
Declares how this tool calls other tools.
Sourcepub fn supports_deferred_results(self, supported: bool) -> Self
pub fn supports_deferred_results(self, supported: bool) -> Self
Marks a provider-executed tool as supporting deferred results. Ignored for other kinds.
Sourcepub fn execute_with(self, executor: Arc<dyn ToolExecute>) -> Self
pub fn execute_with(self, executor: Arc<dyn ToolExecute>) -> Self
Uses a custom executor.
Source§impl<I: DeserializeOwned + Send + 'static> ToolBuilder<I>
impl<I: DeserializeOwned + Send + 'static> ToolBuilder<I>
Sourcepub fn execute<F, Fut, O>(self, function: F) -> Self
pub fn execute<F, Fut, O>(self, function: F) -> Self
Executes with an async closure returning a single result.
Sourcepub fn execute_stream<F, S, O>(self, function: F) -> Self
pub fn execute_stream<F, S, O>(self, function: F) -> Self
Executes with a closure returning a stream; every item becomes a preliminary output and the last one is repeated as the final output.