MCPcopy Index your code
hub / github.com/Xyntopia/taskyon / knnQuery

Function knnQuery

src/modules/localVectorStore.ts:325–339  ·  view source on GitHub ↗
(searchQuery: string, k = 3)

Source from the content-addressed store, hash-verified

323 }
324}
325async function knnQuery(searchQuery: string, k = 3) {
326 if (documentStore?.index) {
327 const vector = await models.vectorize(
328 searchQuery,
329 vecStoreUploaderConfigurationState.value.modelName
330 );
331 const res = documentStore.index.searchKnn(vector.tolist()[0], k, undefined);
332 // You can also search the index with a label filter
333 /*const labelFilter = (label: number) => {
334 return label >= 10 && label < 20;
335 };
336 const result2 = index.searchKnn(testVectorData.vectors[10], 10, labelFilter);*/
337 return res;
338 }
339}
340
341export interface SearchResult {
342 distance: number;

Callers 1

queryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected