Package dev.langchain4j.service.tool
Class ToolService
java.lang.Object
dev.langchain4j.service.tool.ToolService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyToolHallucinationStrategy
(ToolExecutionRequest toolExecutionRequest) void
createContext
(Object memoryId, UserMessage userMessage) executeInferenceAndToolsLoop
(ChatResponse chatResponse, ChatRequestParameters parameters, List<ChatMessage> messages, ChatModel chatModel, ChatMemory chatMemory, Object memoryId, Map<String, ToolExecutor> toolExecutors, boolean isReturnTypeResult) void
void
executeToolsConcurrently
(Executor executor) static ToolExecutionResultMessage
executeWithErrorHandling
(ToolExecutionRequest toolRequest, ToolExecutor executor, Object memoryId, ToolArgumentsErrorHandler argumentsErrorHandler, ToolExecutionErrorHandler executionErrorHandler) void
executor()
void
hallucinatedToolNameStrategy
(Function<ToolExecutionRequest, ToolExecutionResultMessage> toolHallucinationStrategy) boolean
isImmediateTool
(String toolName) void
maxSequentialToolsInvocations
(int maxSequentialToolsInvocations) void
toolProvider
(ToolProvider toolProvider) void
tools
(Collection<Object> objectsWithTools) void
tools
(Map<ToolSpecification, ToolExecutor> tools)
-
Constructor Details
-
ToolService
public ToolService()
-
-
Method Details
-
hallucinatedToolNameStrategy
public void hallucinatedToolNameStrategy(Function<ToolExecutionRequest, ToolExecutionResultMessage> toolHallucinationStrategy) -
toolProvider
-
tools
-
tools
-
executeToolsConcurrently
public void executeToolsConcurrently()- Since:
- 1.4.0
-
executeToolsConcurrently
- Since:
- 1.4.0
-
maxSequentialToolsInvocations
public void maxSequentialToolsInvocations(int maxSequentialToolsInvocations) -
argumentsErrorHandler
- Since:
- 1.4.0
-
argumentsErrorHandler
- Since:
- 1.4.0
-
executionErrorHandler
- Since:
- 1.4.0
-
executionErrorHandler
- Since:
- 1.4.0
-
createContext
-
executeInferenceAndToolsLoop
public ToolServiceResult executeInferenceAndToolsLoop(ChatResponse chatResponse, ChatRequestParameters parameters, List<ChatMessage> messages, ChatModel chatModel, ChatMemory chatMemory, Object memoryId, Map<String, ToolExecutor> toolExecutors, boolean isReturnTypeResult) -
executeWithErrorHandling
public static ToolExecutionResultMessage executeWithErrorHandling(ToolExecutionRequest toolRequest, ToolExecutor executor, Object memoryId, ToolArgumentsErrorHandler argumentsErrorHandler, ToolExecutionErrorHandler executionErrorHandler) -
applyToolHallucinationStrategy
public ToolExecutionResultMessage applyToolHallucinationStrategy(ToolExecutionRequest toolExecutionRequest) -
toolSpecifications
-
toolExecutors
-
executor
- Since:
- 1.4.0
-
toolProvider
-
isImmediateTool
-