Class ToolSpecification.Builder

java.lang.Object
dev.langchain4j.agent.tool.ToolSpecification.Builder
Enclosing class:
ToolSpecification

public static final class ToolSpecification.Builder extends Object
ToolSpecification builder static inner class.
  • Method Details

    • name

      public ToolSpecification.Builder name(String name)
      Sets the name.
      Parameters:
      name - the name
      Returns:
      this
    • description

      public ToolSpecification.Builder description(String description)
      Sets the description.
      Parameters:
      description - the description
      Returns:
      this
    • parameters

      public ToolSpecification.Builder parameters(JsonObjectSchema parameters)
      Sets the parameters.
      Parameters:
      parameters - the parameters
      Returns:
      this
    • parameters

      @Deprecated(forRemoval=true) public ToolSpecification.Builder parameters(ToolParameters parameters)
      Deprecated, for removal: This API element is subject to removal in a future version.
      please use parameters(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 the parameters.
      Parameters:
      parameters - the parameters
      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 use parameters(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 use parameters(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 use parameters(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 use parameters(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

      public ToolSpecification build()
      Returns a ToolSpecification built from the parameters previously set.
      Returns:
      a ToolSpecification built with parameters of this ToolSpecification.Builder