Class VectorToolSearchStrategy

java.lang.Object
dev.langchain4j.service.tool.search.vector.VectorToolSearchStrategy
All Implemented Interfaces:
ToolSearchStrategy

@Experimental public class VectorToolSearchStrategy extends Object implements ToolSearchStrategy
A ToolSearchStrategy that uses vector similarity search to find relevant tools based on the semantic meaning of their names and descriptions.

NOTE: It is important that the tool description (ToolSpecification.description()) is present and comprehensive to ensure that vector search performs effectively.

NOTE: By default, embeddings of tool descriptions are cached (since they rarely change). You can disable this by setting VectorToolSearchStrategy.Builder.cacheEmbeddings(Boolean) to false. The embedding of a query is never cached. To simplify the implementation, the cache is not cleared automatically because the risk of a memory leak is minimal. The number of tools in an application is typically limited and does not increase over time. The cache can be cleared manually by calling clearEmbeddingsCache().