Package dev.langchain4j.agent.tool
Class ToolSpecification.Builder
java.lang.Object
dev.langchain4j.agent.tool.ToolSpecification.Builder
- Enclosing class:
ToolSpecification
ToolSpecification
builder static inner class.-
Method Summary
Modifier and TypeMethodDescriptionaddOptionalParameter
(String name, JsonSchemaProperty... jsonSchemaProperties) Deprecated, for removal: This API element is subject to removal in a future version.addOptionalParameter
(String name, Iterable<JsonSchemaProperty> jsonSchemaProperties) Deprecated, for removal: This API element is subject to removal in a future version.please useparameters(JsonObjectSchema)
instead.addParameter
(String name, JsonSchemaProperty... jsonSchemaProperties) Deprecated, for removal: This API element is subject to removal in a future version.please useparameters(JsonObjectSchema)
instead.addParameter
(String name, Iterable<JsonSchemaProperty> jsonSchemaProperties) Deprecated, for removal: This API element is subject to removal in a future version.please useparameters(JsonObjectSchema)
instead.build()
Returns aToolSpecification
built from the parameters previously set.description
(String description) Sets thedescription
.Sets thename
.parameters
(ToolParameters parameters) Deprecated, for removal: This API element is subject to removal in a future version.please useparameters(JsonObjectSchema)
instead.parameters
(JsonObjectSchema parameters) Sets theparameters
.
-
Method Details
-
name
Sets thename
.- Parameters:
name
- thename
- Returns:
this
-
description
Sets thedescription
.- Parameters:
description
- thedescription
- Returns:
this
-
parameters
Sets theparameters
.- Parameters:
parameters
- theparameters
- Returns:
this
-
parameters
Deprecated, for removal: This API element is subject to removal in a future version.please useparameters(JsonObjectSchema)
instead. Example:ToolSpecification.builder() .name("weather") .description("Returns the current weather in the specified city") .parameters(JsonObjectSchema.builder() .addStringProperty("city", "The name of the city, e.g., Munich") .addEnumProperty("units", List.of("CELSIUS", "FAHRENHEIT")) .required("city") // please specify mandatory properties explicitly .build()) .build();
Sets theparameters
.- Parameters:
parameters
- theparameters
- Returns:
this
-
addParameter
@Deprecated(forRemoval=true) public ToolSpecification.Builder addParameter(String name, JsonSchemaProperty... jsonSchemaProperties) Deprecated, for removal: This API element is subject to removal in a future version.please useparameters(JsonObjectSchema)
instead. Example:ToolSpecification.builder() .name("weather") .description("Returns the current weather in the specified city") .parameters(JsonObjectSchema.builder() .addStringProperty("city", "The name of the city, e.g., Munich") .addEnumProperty("units", List.of("CELSIUS", "FAHRENHEIT")) .required("city") // please specify mandatory properties explicitly .build()) .build();
Adds a parameter to the tool.- Parameters:
name
- the name of the parameter.jsonSchemaProperties
- the properties of the parameter.- Returns:
this
-
addParameter
@Deprecated(forRemoval=true) public ToolSpecification.Builder addParameter(String name, Iterable<JsonSchemaProperty> jsonSchemaProperties) Deprecated, for removal: This API element is subject to removal in a future version.please useparameters(JsonObjectSchema)
instead. Example:ToolSpecification.builder() .name("weather") .description("Returns the current weather in the specified city") .parameters(JsonObjectSchema.builder() .addStringProperty("city", "The name of the city, e.g., Munich") .addEnumProperty("units", List.of("CELSIUS", "FAHRENHEIT")) .required("city") // please specify mandatory properties explicitly .build()) .build();
Adds a parameter to the tool.- Parameters:
name
- the name of the parameter.jsonSchemaProperties
- the properties of the parameter.- Returns:
this
-
addOptionalParameter
@Deprecated(forRemoval=true) public ToolSpecification.Builder addOptionalParameter(String name, JsonSchemaProperty... jsonSchemaProperties) Deprecated, for removal: This API element is subject to removal in a future version.please useparameters(JsonObjectSchema)
instead. Example:ToolSpecification.builder() .name("weather") .description("Returns the current weather in the specified city") .parameters(JsonObjectSchema.builder() .addStringProperty("city", "The name of the city, e.g., Munich") .addEnumProperty("units", List.of("CELSIUS", "FAHRENHEIT")) .required("city") // please specify mandatory properties explicitly .build()) .build();
Adds an optional parameter to the tool.- Parameters:
name
- the name of the parameter.jsonSchemaProperties
- the properties of the parameter.- Returns:
this
-
addOptionalParameter
@Deprecated(forRemoval=true) public ToolSpecification.Builder addOptionalParameter(String name, Iterable<JsonSchemaProperty> jsonSchemaProperties) Deprecated, for removal: This API element is subject to removal in a future version.please useparameters(JsonObjectSchema)
instead. Example:ToolSpecification.builder() .name("weather") .description("Returns the current weather in the specified city") .parameters(JsonObjectSchema.builder() .addStringProperty("city", "The name of the city, e.g., Munich") .addEnumProperty("units", List.of("CELSIUS", "FAHRENHEIT")) .required("city") // please specify mandatory properties explicitly .build()) .build();
Adds an optional parameter to the tool.- Parameters:
name
- the name of the parameter.jsonSchemaProperties
- the properties of the parameter.- Returns:
this
-
build
Returns aToolSpecification
built from the parameters previously set.- Returns:
- a
ToolSpecification
built with parameters of thisToolSpecification.Builder
-
parameters(JsonObjectSchema)
instead.