Class ToolNode

java.lang.Object
org.bsc.langgraph4j.langchain4j.tool.ToolNode

@Deprecated(forRemoval=true) public final class ToolNode extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
A node in the graph that executes a tool

This class is just a simple wrapper around a list of ToolNode.Specification that can be used to build a node in a graph that can execute a tool with the given id.

The node will execute the first tool that has the given id.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Deprecated.
    static final record 
    Deprecated.
  • Method Summary

    Modifier and Type
    Method
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Optional<dev.langchain4j.data.message.ToolExecutionResultMessage>
    execute(dev.langchain4j.agent.tool.ToolExecutionRequest request)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Executes the first matching tool
    Optional<dev.langchain4j.data.message.ToolExecutionResultMessage>
    execute(dev.langchain4j.agent.tool.ToolExecutionRequest request, Object memoryId)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Executes the first matching tool
    Optional<dev.langchain4j.data.message.ToolExecutionResultMessage>
    execute(Collection<dev.langchain4j.agent.tool.ToolExecutionRequest> requests)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Executes the first matching tool
    Optional<dev.langchain4j.data.message.ToolExecutionResultMessage>
    execute(Collection<dev.langchain4j.agent.tool.ToolExecutionRequest> requests, Object memoryId)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Executes the first matching tool
    static ToolNode
    of(Object... objectsWithToolsOrSpecification)
    Deprecated.
    static ToolNode
    of(Collection<Object> objectsWithToolsOrSpecification)
    Deprecated.
    List<dev.langchain4j.agent.tool.ToolSpecification>
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns a list of ToolSpecifications that can be executed by this node

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • builder

      public static ToolNode.Builder builder()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • of

      @Deprecated public static ToolNode of(Collection<Object> objectsWithToolsOrSpecification)
      Deprecated.
      Builds a ToolNode out of a collection of objects that have tools attached or a tool specification
      Parameters:
      objectsWithToolsOrSpecification - a list of objects with tools
      Returns:
      a ToolNode
    • of

      @Deprecated public static ToolNode of(Object... objectsWithToolsOrSpecification)
      Deprecated.
      Builds a ToolNode out of a array of objects that have tools attached or a tool specification
      Parameters:
      objectsWithToolsOrSpecification - a list of objects with tools
      Returns:
      a ToolNode
    • toolSpecifications

      public List<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns a list of ToolSpecifications that can be executed by this node
      Returns:
      a list of tool specifications
    • execute

      public Optional<dev.langchain4j.data.message.ToolExecutionResultMessage> execute(dev.langchain4j.agent.tool.ToolExecutionRequest request, Object memoryId)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Executes the first matching tool
      Parameters:
      request - the request to execute
      memoryId - the memory id to pass to the tool
      Returns:
      the result of the tool
    • execute

      public Optional<dev.langchain4j.data.message.ToolExecutionResultMessage> execute(Collection<dev.langchain4j.agent.tool.ToolExecutionRequest> requests, Object memoryId)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Executes the first matching tool
      Parameters:
      requests - the requests to execute
      memoryId - the memory id to pass to the tool
      Returns:
      the result of the tool
    • execute

      public Optional<dev.langchain4j.data.message.ToolExecutionResultMessage> execute(dev.langchain4j.agent.tool.ToolExecutionRequest request)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Executes the first matching tool
      Parameters:
      request - the request to execute
      Returns:
      the result of the tool
    • execute

      public Optional<dev.langchain4j.data.message.ToolExecutionResultMessage> execute(Collection<dev.langchain4j.agent.tool.ToolExecutionRequest> requests)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Executes the first matching tool
      Parameters:
      requests - the requests to execute
      Returns:
      the result of the tool