Class ToolSpecification

java.lang.Object
dev.langchain4j.agent.tool.ToolSpecification

public class ToolSpecification extends Object
Describes a tool that language model can execute.

Can be generated automatically from methods annotated with Tool using ToolSpecifications helper.

  • Method Details

    • name

      public String name()
      Returns the name of the tool.
      Returns:
      the name of the tool.
    • description

      public String description()
      Returns the description of the tool.
      Returns:
      the description of the tool.
    • parameters

      public JsonObjectSchema parameters()
      Returns the parameters of the tool.
    • metadata

      public Map<String,Object> metadata()
      Returns the metadata relevant to the tool.

      NOTE: this metadata is not sent to the LLM provider API by default, you must explicitly specify which metadata keys should be sent when creating a ChatModel.

      NOTE: Currently, tool metadata is supported only by the langchain4j-anthropic module.

    • equals

      public boolean equals(Object another)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toBuilder

      public ToolSpecification.Builder toBuilder()
    • builder

      public static ToolSpecification.Builder builder()
      Creates builder to build ToolSpecification.
      Returns:
      created builder