Class VectorToolSearchStrategy.Builder
- Enclosing class:
VectorToolSearchStrategy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()cacheEmbeddings(Boolean cacheEmbeddings) Controls whether embeddings generated by the embedding model are cached.embeddingModel(EmbeddingModel embeddingModel) Sets theEmbeddingModelused to generate embeddings for the query and available tools.maxResults(Integer maxResults) Sets the maximum number of tools to return from the vector similarity search.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 natural language query.toolArgumentName(String toolArgumentName) Sets the name of the tool argument that contains the natural language 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 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
-
embeddingModel
Sets theEmbeddingModelused to generate embeddings for the query and available tools.This property is required and has no default value.
-
maxResults
Sets the maximum number of tools to return from the vector similarity search.Default value is 5.
-
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 using semantic vector search".
-
toolArgumentName
Sets the name of the tool argument that contains the natural language query.Default value is "query".
-
toolArgumentDescription
Sets the description of the tool argument that contains the natural language query.Default value is "Natural language query describing desired tool".
-
throwToolArgumentsExceptions
public VectorToolSearchStrategy.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
-
cacheEmbeddings
Controls whether embeddings generated by the embedding model are cached.Default value is
true. -
toolResultMessageTextProvider
public VectorToolSearchStrategy.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: tool_1, tool_2, ..."otherwise
-
build
-