Class DecisionModelToolSearchStrategy.Builder
java.lang.Object
dev.langchain4j.service.tool.search.decision.DecisionModelToolSearchStrategy.Builder
- Enclosing class:
DecisionModelToolSearchStrategy
- Since:
- 1.21.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()decisionModel(DecisionModel decisionModel) Sets the decision model that decides which tools match the query.maxResults(Integer maxResults) Sets the maximum number of tools returned by a search.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 returned.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).throwToolArgumentsExceptions(Boolean throwToolArgumentsExceptions) Controls which exception type is thrown when the tool arguments are missing or cannot be parsed:ToolArgumentsExceptioniftrue,ToolExecutionExceptionotherwise.toolArgumentDescription(String toolArgumentDescription) Sets the description of the tool argument that contains the search query.toolArgumentName(String toolArgumentName) Sets the name of the tool argument that contains the search query.toolDescription(String toolDescription) Sets the description of the tool that performs the tool search.Sets the name of the tool that performs the tool search.toolResultMessageTextProvider(Function<List<String>, String> toolResultMessageTextProvider) Sets the function that creates the text of the tool result message from the names of the found tools.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
decisionModel
Sets the decision model that decides which tools match the query. 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
DecisionModelToolSearchStrategy.DEFAULT_QUESTION_TEMPLATE. -
maxResults
Sets the maximum number of tools returned by a search.Default value is 5.
-
minProbability
Sets the minimum probability of "yes" for a tool to be returned.Default value is 0.5.
-
maxToolsPerDecisionRequest
public DecisionModelToolSearchStrategy.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). -
toolName
Sets the name of the tool that performs the tool search.Default value is "tool_search_tool".
-
toolDescription
Sets the description of the tool that performs the tool search.Default value is "Finds available tools that can help with a task".
-
toolArgumentName
Sets the name of the tool argument that contains the search query.Default value is "query".
-
toolArgumentDescription
public DecisionModelToolSearchStrategy.Builder toolArgumentDescription(String toolArgumentDescription) Sets the description of the tool argument that contains the search query.Default value is "Natural language description of the task".
-
throwToolArgumentsExceptions
public DecisionModelToolSearchStrategy.Builder throwToolArgumentsExceptions(Boolean throwToolArgumentsExceptions) Controls which exception type is thrown when the tool arguments are missing or cannot be parsed:ToolArgumentsExceptioniftrue,ToolExecutionExceptionotherwise.Default value is
false. -
toolResultMessageTextProvider
public DecisionModelToolSearchStrategy.Builder toolResultMessageTextProvider(Function<List<String>, String> toolResultMessageTextProvider) Sets the function that creates the text of the tool result message from the names of the found tools.By default, the text lists the names of the found tools, or says that no matching tools were found.
-
build
-