Class SimpleToolSearchStrategy.Builder
- Enclosing class:
SimpleToolSearchStrategy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()maxResults(Integer maxResults) Sets the maximum number of tools to return after scoring and ranking.Sets the minimum score a tool must have to be included in the results.throwToolArgumentsExceptions(Boolean throwToolArgumentsExceptions) Controls which exception type is thrown when tool arguments are missing, invalid, or cannot be parsed.toolArgumentDescription(String toolArgumentDescription) Sets the description of the tool argument that contains the list of search terms.toolArgumentName(String toolArgumentName) Sets the name of the tool argument that contains the list of search terms.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 a function that produces a human-readable message describing the tool search result, based on the list of found tool names.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
maxResults
Sets the maximum number of tools to return after scoring and ranking.Default value is 5.
-
minScore
Sets the minimum score a tool must have to be included in the results.Tools with a score lower than this value are discarded.
Default value is 1.
-
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 whose name or description contains given search terms".
-
toolArgumentName
Sets the name of the tool argument that contains the list of search terms.Default value is "terms".
-
toolArgumentDescription
Sets the description of the tool argument that contains the list of search terms.Default value is "A list of search terms used to find relevant tools".
-
throwToolArgumentsExceptions
public SimpleToolSearchStrategy.Builder throwToolArgumentsExceptions(Boolean throwToolArgumentsExceptions) Controls which exception type is thrown when tool arguments are missing, invalid, or cannot be parsed.Although all errors produced by this tool are argument-related, this strategy throws
ToolExecutionExceptionby default instead ofToolArgumentsException.The reason is historical: by default, AI Services fail fast when a
ToolArgumentsExceptionis thrown, whereasToolExecutionExceptionallows the error message to be returned to the LLM. For this tool, returning the error message to the LLM is usually the desired behavior.If this flag is set to
true,ToolArgumentsExceptionwill be thrown instead.- Parameters:
throwToolArgumentsExceptions- whether to throwToolArgumentsException- Returns:
- this builder
-
toolResultMessageTextProvider
public SimpleToolSearchStrategy.Builder toolResultMessageTextProvider(Function<List<String>, String> toolResultMessageTextProvider) Sets a function that produces a human-readable message describing the tool search result, based on the list of found tool names.By default, returns:
"No matching tools found"when no tools are found"Tools found: <names>"otherwise
-
build
-