Class DecisionModelFilteringToolProvider.Builder
java.lang.Object
dev.langchain4j.service.tool.DecisionModelFilteringToolProvider.Builder
- Enclosing class:
DecisionModelFilteringToolProvider
- Since:
- 1.21.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionalwaysInclude(String... toolNames) Sets tools that are always passed on, without asking the decision model.alwaysInclude(Collection<String> toolNames) Sets tools that are always passed on, without asking the decision model.build()decisionModel(DecisionModel decisionModel) Sets the decision model that decides which tools are relevant.fallbackStrategy(DecisionModelFilteringToolProvider.FallbackStrategy fallbackStrategy) Sets what happens when the decision model fails.maxMessages(Integer maxMessages) Sets how many of the last messages of the conversation (user and assistant messages with text, the last one being the user message) the decision model receives.maxResults(Integer maxResults) Sets the maximum number of selected tools, in addition to the always included ones.maxToolsPerDecisionRequest(Integer maxToolsPerDecisionRequest) Sets the maximum number of tools evaluated in a single request to the decision model, for when the tools together exceed the input size accepted by the decision model.minProbability(Double minProbability) Sets the minimum probability of "yes" for a tool to be selected.questionTemplate(PromptTemplate questionTemplate) Sets the template of the yes/no question asked for each tool, which must contain the{{name}}variable (the name of the tool) and can contain{{description}}(its description, empty if it has none).toolProvider(ToolProvider toolProvider) Sets the tool provider whose tools are filtered.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
toolProvider
Sets the tool provider whose tools are filtered. Required. -
decisionModel
Sets the decision model that decides which tools are relevant. Required. -
questionTemplate
Sets the template of the yes/no question asked for each tool, which must contain the{{name}}variable (the name of the tool) and can contain{{description}}(its description, empty if it has none).Default value is
DecisionModelFilteringToolProvider.DEFAULT_QUESTION_TEMPLATE. -
maxResults
Sets the maximum number of selected tools, in addition to the always included ones. The tools with the highest probabilities are kept.By default, there is no limit: every tool whose probability reaches the minimum probability is passed on, since a tool that is not passed on cannot be used at all in this request.
-
minProbability
Sets the minimum probability of "yes" for a tool to be selected.Default value is 0.5.
-
maxToolsPerDecisionRequest
public DecisionModelFilteringToolProvider.Builder maxToolsPerDecisionRequest(Integer maxToolsPerDecisionRequest) Sets the maximum number of tools evaluated in a single request to the decision model, for when the tools together exceed the input size accepted by the decision model.By default, all tools are evaluated in a single request. This does not limit the number of tools passed on to the LLM, see
maxResults(Integer). -
alwaysInclude
Sets tools that are always passed on, without asking the decision model. Replaces the previously set tools. -
alwaysInclude
Sets tools that are always passed on, without asking the decision model. Replaces the previously set tools. -
maxMessages
Sets how many of the last messages of the conversation (user and assistant messages with text, the last one being the user message) the decision model receives. System messages, tool calls and tool results are never sent, and do not count.Default value is 3. More messages can make an older topic of the conversation outweigh the user message. Previous messages are only available if the AI Service passes them in
ToolProviderRequest.messages(). -
fallbackStrategy
public DecisionModelFilteringToolProvider.Builder fallbackStrategy(DecisionModelFilteringToolProvider.FallbackStrategy fallbackStrategy) Sets what happens when the decision model fails.Default value is
DecisionModelFilteringToolProvider.FallbackStrategy.ALL_TOOLS. -
build
-