Class LC4jToolService

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

public final class LC4jToolService extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder for LC4jToolService
    static final record 
    Deprecated.
    use Map.Entry<dev.langchain4j.agent.tool.ToolSpecification,dev.langchain4j.service.tool.ToolExecutor> instead
  • Constructor Summary

    Constructors
    Constructor
    Description
    LC4jToolService(Map<dev.langchain4j.agent.tool.ToolSpecification,dev.langchain4j.service.tool.ToolExecutor> toolMap)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    Optional<dev.langchain4j.data.message.ToolExecutionResultMessage>
    execute(dev.langchain4j.agent.tool.ToolExecutionRequest request)
    Executes the first matching tool
    Optional<dev.langchain4j.data.message.ToolExecutionResultMessage>
    execute(dev.langchain4j.agent.tool.ToolExecutionRequest request, Object memoryId)
    Executes the first matching tool
    Optional<dev.langchain4j.data.message.ToolExecutionResultMessage>
    execute(Collection<dev.langchain4j.agent.tool.ToolExecutionRequest> requests)
    Executes the first matching tool
    Optional<dev.langchain4j.data.message.ToolExecutionResultMessage>
    execute(Collection<dev.langchain4j.agent.tool.ToolExecutionRequest> requests, Object memoryId)
    Executes the first matching tool
    List<dev.langchain4j.agent.tool.ToolSpecification>
    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
  • Constructor Details

    • LC4jToolService

      public LC4jToolService(Map<dev.langchain4j.agent.tool.ToolSpecification,dev.langchain4j.service.tool.ToolExecutor> toolMap)
  • Method Details

    • builder

      public static LC4jToolService.Builder builder()
    • toolSpecifications

      public List<dev.langchain4j.agent.tool.ToolSpecification> toolSpecifications()
      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)
      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)
      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)
      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)
      Executes the first matching tool
      Parameters:
      requests - the requests to execute
      Returns:
      the result of the tool