Class ToolService
java.lang.Object
dev.langchain4j.service.tool.ToolService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyToolHallucinationStrategy(ToolExecutionRequest toolRequest) voidcreateContext(InvocationContext invocationContext, UserMessage userMessage) executeInferenceAndToolsLoop(ChatResponse chatResponse, ChatRequestParameters parameters, List<ChatMessage> messages, ChatModel chatModel, ChatMemory chatMemory, InvocationContext invocationContext, Map<String, ToolExecutor> toolExecutors, boolean isReturnTypeResult, AiServiceListenerRegistrar aiServiceListenerRegistrar) voidvoidexecuteToolsConcurrently(Executor executor) static ToolExecutionResultexecuteWithErrorHandling(ToolExecutionRequest toolRequest, ToolExecutor toolExecutor, InvocationContext invocationContext, ToolArgumentsErrorHandler argumentsErrorHandler, ToolExecutionErrorHandler executionErrorHandler) voidexecutor()voidhallucinatedToolNameStrategy(Function<ToolExecutionRequest, ToolExecutionResultMessage> toolHallucinationStrategy) booleanisImmediateTool(String toolName) voidmaxSequentialToolsInvocations(int maxSequentialToolsInvocations) voidtoolProvider(ToolProvider toolProvider) voidtools(Collection<Object> objectsWithTools) voidtools(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
public ToolServiceContext createContext(InvocationContext invocationContext, UserMessage userMessage) -
executeInferenceAndToolsLoop
public ToolServiceResult executeInferenceAndToolsLoop(ChatResponse chatResponse, ChatRequestParameters parameters, List<ChatMessage> messages, ChatModel chatModel, ChatMemory chatMemory, InvocationContext invocationContext, Map<String, ToolExecutor> toolExecutors, boolean isReturnTypeResult, AiServiceListenerRegistrar aiServiceListenerRegistrar) -
executeWithErrorHandling
public static ToolExecutionResult executeWithErrorHandling(ToolExecutionRequest toolRequest, ToolExecutor toolExecutor, InvocationContext invocationContext, ToolArgumentsErrorHandler argumentsErrorHandler, ToolExecutionErrorHandler executionErrorHandler) -
applyToolHallucinationStrategy
-
toolSpecifications
-
toolExecutors
-
executor
- Since:
- 1.4.0
-
toolProvider
-
isImmediateTool
-