Skip to Content
SdkReactInternalFunctionsfindMatchingTools

findMatchingTools

findMatchingTools(promptEmbeddings: number[] | number[][], tools: ServerTool[], options?: ToolMatchOptions): ToolMatchResult[]

Defined in: src/lib/tools/serverTools.ts:597 

Find tools that semantically match prompt embedding(s).

Accepts either a single embedding or an array of embeddings (e.g., from chunked messages). When multiple embeddings are provided, uses max similarity across all chunks for each tool.

Parameters

ParameterTypeDescription

promptEmbeddings

number[] | number[][]

Single embedding vector or array of embeddings (for chunked messages)

tools

ServerTool[]

Array of server tools (with embeddings) to search through

options?

ToolMatchOptions

Optional matching configuration

Returns

ToolMatchResult[]

Array of matching tools with similarity scores, sorted by relevance

Example

// Single embedding const matches = findMatchingTools(embedding, tools, { limit: 5 }); // Multiple embeddings (chunked message) - uses max similarity const matches = findMatchingTools(chunkEmbeddings, tools, { limit: 5 });
Last updated on