Interface ToolIndex
- All Known Implementing Classes:
LuceneToolIndex,RegexToolIndex,VectorToolIndex
public interface ToolIndex
Interface for searching and discovering tools on-demand.
Implementations provide different search strategies — such as embedding-based semantic search, full-text keyword search, or regex pattern matching — to find relevant tools from a registered catalog based on search queries. This aligns with the Tool Search Tool concept for dynamic tool discovery.
- Since:
- 2.0.0
- Author:
- Christian Tzolov
-
Method Summary
Modifier and TypeMethodDescriptionvoidclearIndex(String sessionId) Clears all indexed tools for the specified session.voidindexTool(String sessionId, ToolReference toolReference) Registers a tool in the search index for the specified session.default voidindexTools(String sessionId, List<ToolReference> toolReferences) Registers multiple tools in the search index for the specified session in a single batch operation.search(ToolSearchRequest toolSearchRequest) Searches for tools matching the given request criteria.
-
Method Details
-
indexTool
Registers a tool in the search index for the specified session.- Parameters:
sessionId- the session identifier for tool isolationtoolReference- the reference to the tool being indexed
-
indexTools
Registers multiple tools in the search index for the specified session in a single batch operation.Implementations should override this method when a batch operation is more efficient than repeated
indexTool(java.lang.String, org.springframework.ai.tool.toolsearch.ToolReference)calls (e.g. a single embedding API call or a single write transaction). The default implementation simply iterates and delegates toindexTool(java.lang.String, org.springframework.ai.tool.toolsearch.ToolReference).- Parameters:
sessionId- the session identifier for tool isolationtoolReferences- the tools to register
-
search
Searches for tools matching the given request criteria.- Parameters:
toolSearchRequest- the search request containing query and parameters- Returns:
- a response containing matching tool references
-
clearIndex
Clears all indexed tools for the specified session.- Parameters:
sessionId- the session identifier
-