Class ToolServiceContext.Builder
java.lang.Object
dev.langchain4j.service.tool.ToolServiceContext.Builder
- Enclosing class:
ToolServiceContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionavailableTools(List<ToolSpecification> availableTools) Sets all available tool specifications configured for AI service.build()dynamicToolProviders(List<ToolProvider> dynamicToolProviders) effectiveTools(List<ToolSpecification> effectiveTools) Sets effective tool specifications that should be included in the nextChatRequest.guardrailRequestParams(@Nullable GuardrailRequestParams guardrailRequestParams) Sets theGuardrailRequestParamsof the AI service invocation, which the tool guardrails receive in their requests, so they see the same context as the AI service guardrails and their events reach the listeners registered for the invocation.immediateReturnTools(Set<String> immediateReturnTools) Deprecated.returnBehaviors(Map<String, ReturnBehavior> returnBehaviorByName) toolExecutors(Map<String, ToolExecutor> toolExecutors) toolGuardrailKeys(Map<String, ToolGuardrailService.ToolKey> toolGuardrailKeys) Sets the key thatToolGuardrailService.bind(AiServiceTool)of the tool guardrail service returned for each tool, by tool name.toolGuardrailService(@Nullable ToolGuardrailService toolGuardrailService) Sets the service that executes the tool guardrails, and binds on demand the tools that have no key.toolSpecifications(List<ToolSpecification> toolSpecifications) Deprecated.useeffectiveTools(List)instead
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
effectiveTools
Sets effective tool specifications that should be included in the nextChatRequest.- See Also:
-
toolSpecifications
@Deprecated(since="1.12.0") public ToolServiceContext.Builder toolSpecifications(List<ToolSpecification> toolSpecifications) Deprecated.useeffectiveTools(List)insteadSets effective tool specifications that should be included in the nextChatRequest.- See Also:
-
availableTools
Sets all available tool specifications configured for AI service. These tool specifications can be discovered/found by the LLM (seeToolSearchStrategy) and included in the nextChatRequest.- Since:
- 1.12.0
- See Also:
-
toolExecutors
-
immediateReturnTools
@Deprecated(since="1.14.0") public ToolServiceContext.Builder immediateReturnTools(Set<String> immediateReturnTools) Deprecated.usereturnBehaviors(Map)instead -
returnBehaviors
- Since:
- 1.14.0
-
dynamicToolProviders
- Since:
- 1.13.0
-
toolGuardrailKeys
public ToolServiceContext.Builder toolGuardrailKeys(Map<String, ToolGuardrailService.ToolKey> toolGuardrailKeys) Sets the key thatToolGuardrailService.bind(AiServiceTool)of the tool guardrail service returned for each tool, by tool name. A tool without a key is bound on demand when it is called.- Parameters:
toolGuardrailKeys- the keys of the tools, by tool name- Returns:
- this builder
- Since:
- 1.25.0
-
toolGuardrailService
public ToolServiceContext.Builder toolGuardrailService(@Nullable ToolGuardrailService toolGuardrailService) Sets the service that executes the tool guardrails, and binds on demand the tools that have no key.- Parameters:
toolGuardrailService- the tool guardrail service, ornull(the default) for the one of theToolServicethat runs the tools of the context, if it has one; the keys are then not used- Returns:
- this builder
- Since:
- 1.25.0
-
guardrailRequestParams
public ToolServiceContext.Builder guardrailRequestParams(@Nullable GuardrailRequestParams guardrailRequestParams) Sets theGuardrailRequestParamsof the AI service invocation, which the tool guardrails receive in their requests, so they see the same context as the AI service guardrails and their events reach the listeners registered for the invocation.- Parameters:
guardrailRequestParams- the parameters, ornull(the default) when the context is not created by an AI service invocation: the tool guardrails then run with minimal parameters (an empty user message template and no variables)- Returns:
- this builder
- Since:
- 1.25.0
-
build
-
returnBehaviors(Map)instead