MCPcopy Create free account
hub / github.com/MemTensor/MemOS / getAllEmbeddings

Method getAllEmbeddings

packages/memos-core/src/storage/sqlite.ts:1348–1366  ·  view source on GitHub ↗
(ownerFilter?: string[])

Source from the content-addressed store, hash-verified

1346 // ─── Vector Search ───
1347
1348 getAllEmbeddings(ownerFilter?: string[]): Array<{ chunkId: string; vector: number[] }> {
1349 let sql = `SELECT e.chunk_id, e.vector, e.dimensions FROM embeddings e
1350 JOIN chunks c ON c.id = e.chunk_id
1351 WHERE c.dedup_status = 'active'`;
1352 const params: any[] = [];
1353
1354 if (ownerFilter && ownerFilter.length > 0) {
1355 const placeholders = ownerFilter.map(() => "?").join(",");
1356 sql += ` AND c.owner IN (${placeholders})`;
1357 params.push(...ownerFilter);
1358 }
1359
1360 const rows = this.db.prepare(sql).all(...params) as Array<{ chunk_id: string; vector: Buffer; dimensions: number }>;
1361
1362 return rows.map((r) => ({
1363 chunkId: r.chunk_id,
1364 vector: Array.from(new Float32Array(r.vector.buffer, r.vector.byteOffset, r.dimensions)),
1365 }));
1366 }
1367
1368 getRecentEmbeddings(limit: number, ownerFilter?: string[]): Array<{ chunkId: string; vector: number[] }> {
1369 if (limit <= 0) return this.getAllEmbeddings(ownerFilter);

Callers 4

getRecentEmbeddingsMethod · 0.95
findDuplicateFunction · 0.45
findTopSimilarFunction · 0.45
vectorSearchFunction · 0.45

Calls 4

mapMethod · 0.80
allMethod · 0.80
prepareMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected