Class 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.maxMessageLength(Integer maxMessageLength) Sets the maximum length, in characters, of the text of each message the decision model receives, other than system messages, and of the arguments of each tool call.maxMessages(Integer maxMessages) Sets how many of the last messages of the conversation the decision model receives, plus the user message if it is older.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.messageFilter(Predicate<? super ChatMessage> messageFilter) Sets which messages of the conversation the decision model receives; it also applies to the last user message.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 the decision model receives, plus the user message if it is older. An AI message with tool calls and each tool result count as one message each. Tool results whose AI message does not fit are left out. With parallel tool calls, set it higher than the number of tool calls in one round. With 1, system messages are still sent; leave them out withmessageFilter(Predicate). System messages are sent in addition and do not count.Default value is 10. 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(). -
maxMessageLength
Sets the maximum length, in characters, of the text of each message the decision model receives, other than system messages, and of the arguments of each tool call. A longer text is shortened in the middle: its beginning and its end are kept, with a note of about 90 characters saying how many characters were left out. Long tool results and user messages with retrieved content are the usual cases. As a rough guide, 4 characters make one token in English text.Default value is 2000.
- Since:
- 1.23.0
-
messageFilter
public DecisionModelFilteringToolProvider.Builder messageFilter(Predicate<? super ChatMessage> messageFilter) Sets which messages of the conversation the decision model receives; it also applies to the last user message. For example,message -> !(message instanceof SystemMessage)leaves out the system message, andmessage -> !(message instanceof ToolExecutionResultMessage)leaves out tool results, which can be large.By default, all messages are sent: system messages, user messages, AI messages with their tool calls, and tool results.
- Since:
- 1.23.0
-
fallbackStrategy
public DecisionModelFilteringToolProvider.Builder fallbackStrategy(DecisionModelFilteringToolProvider.FallbackStrategy fallbackStrategy) Sets what happens when the decision model fails.Default value is
DecisionModelFilteringToolProvider.FallbackStrategy.ALL_TOOLS. -
build
-