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

Function query

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

Source from the content-addressed store, hash-verified

344}
345
346async function query(searchQuery: string, k = 3): Promise<SearchResult[]> {
347 if (searchQuery && searchQuery.length > 0) {
348 const res = await knnQuery(searchQuery, k);
349 const docs: SearchResult[] = [];
350 if (res) {
351 for (let i = 0; i < (res?.neighbors.length || 0); i++) {
352 const docId = res.neighbors[i];
353 const distance = res.distances[i];
354 if (documentStore?.idb) {
355 const doc = await documentStore.idb.documents.get(docId);
356 if (doc) {
357 docs.push({
358 distance,
359 document: doc,
360 });
361 }
362 }
363 }
364 }
365 return docs;
366 } else {
367 return [];
368 }
369}
370
371// TODO: move this into the useVectorStore function
372console.log(`load ${statename}`);

Callers

nothing calls this directly

Calls 2

knnQueryFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected