Class BetaRunnableTool
-
- All Implemented Interfaces:
public final class BetaRunnableToolA tool that BetaToolRunner can run when the model calls it.
Holds both the tool definition (name, description, input schema) and the function that executes the tool. Pass to com.anthropic.models.beta.messages.MessageCreateParams.Builder.addTool to wire it into a request.
-
-
Method Summary
Modifier and Type Method Description final static <T extends Any> BetaRunnableToolof(Class<T> parametersType, Function<in T, out BetaToolResultBlockParam.Content> run, JsonSchemaLocalValidation localValidation)Creates a tool whose name, description and input schema are derived from parametersType. final static <T extends Any> BetaRunnableToolof(Class<T> parametersType, Function<in T, out BetaToolResultBlockParam.Content> run)Creates a tool whose name, description and input schema are derived from parametersType. final static BetaRunnableToolof(BetaTool definition, Function<in String, out BetaToolResultBlockParam.Content> run)Creates a tool from an existing tool definition. -
-
Method Detail
-
of
@JvmOverloads() final static <T extends Any> BetaRunnableTool of(Class<T> parametersType, Function<in T, out BetaToolResultBlockParam.Content> run, JsonSchemaLocalValidation localValidation)
Creates a tool whose name, description and input schema are derived from parametersType. When the model calls the tool, the tool input is parsed into an instance of parametersType and passed to run, which returns the tool result.
Local validation of the derived JSON schema can be performed to check if the schema is likely to pass remote validation by the AI model. By default, local validation is enabled; disable it by setting localValidation to JsonSchemaLocalValidation.NO.
-
of
@JvmOverloads() final static <T extends Any> BetaRunnableTool of(Class<T> parametersType, Function<in T, out BetaToolResultBlockParam.Content> run)
Creates a tool whose name, description and input schema are derived from parametersType. When the model calls the tool, the tool input is parsed into an instance of parametersType and passed to run, which returns the tool result.
Local validation of the derived JSON schema can be performed to check if the schema is likely to pass remote validation by the AI model. By default, local validation is enabled; disable it by setting localValidation to JsonSchemaLocalValidation.NO.
-
of
final static BetaRunnableTool of(BetaTool definition, Function<in String, out BetaToolResultBlockParam.Content> run)
Creates a tool from an existing tool definition. When the model calls the tool, run receives the tool input as its raw JSON string and returns the tool result. This differs from the overload that takes a Class, where run receives the input parsed into an instance of that class.
-
-
-
-