Class AiServiceTool

java.lang.Object
dev.langchain4j.service.tool.AiServiceTool

public class AiServiceTool extends Object
Represents a tool managed by an AI Service, combining:
Since:
1.13.0
  • Method Details

    • name

      public String name()
    • toolSpecification

      public ToolSpecification toolSpecification()
    • toolExecutor

      public ToolExecutor toolExecutor()
    • returnBehavior

      public ReturnBehavior returnBehavior()
      Since:
      1.14.0
    • toolSource

      @Experimental public ToolSource toolSource()
      Returns where this tool comes from. It is trusted information, set by the framework or by the application, and exposed to tool guardrails. Without an explicit source, a tool backed by a DefaultToolExecutor is local (the original method of the executor), and any other tool is programmatic.
      Returns:
      where this tool comes from
      Since:
      1.25.0
    • toolInputGuardrails

      @Experimental public List<ToolInputGuardrail> toolInputGuardrails()
      Returns the ToolInputGuardrails of this tool. They run after the guardrails set on the AiServices builder, after the guardrails of the class annotation and after the ones of the method annotation, if any.
      Returns:
      the tool input guardrails of this tool, empty if it has none
      Since:
      1.25.0
    • toolOutputGuardrails

      @Experimental public List<ToolOutputGuardrail> toolOutputGuardrails()
      Returns the ToolOutputGuardrails of this tool. They run first, before the guardrails of the method annotation, the ones of the class annotation, if any, and the guardrails set on the AiServices builder, which run last.
      Returns:
      the tool output guardrails of this tool, empty if it has none
      Since:
      1.25.0
    • immediateReturn

      @Deprecated(since="1.14.0") public boolean immediateReturn()
      Deprecated.
      use returnBehavior() instead
    • equals

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

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

      public String toString()
      The guardrails are shown by their class names, not by their own toString, which may print what they hold (a token, an API key).
      Overrides:
      toString in class Object
    • toBuilder

      public AiServiceTool.Builder toBuilder()
    • builder

      public static AiServiceTool.Builder builder()