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

Method getRecentEmbeddings

packages/memos-core/src/storage/sqlite.ts:1368–1392  ·  view source on GitHub ↗
(limit: number, ownerFilter?: string[])

Source from the content-addressed store, hash-verified

1366 }
1367
1368 getRecentEmbeddings(limit: number, ownerFilter?: string[]): Array<{ chunkId: string; vector: number[] }> {
1369 if (limit <= 0) return this.getAllEmbeddings(ownerFilter);
1370
1371 let sql = `SELECT e.chunk_id, e.vector, e.dimensions
1372 FROM chunks c
1373 JOIN embeddings e ON e.chunk_id = c.id
1374 WHERE c.dedup_status = 'active'`;
1375 const params: any[] = [];
1376
1377 if (ownerFilter && ownerFilter.length > 0) {
1378 const placeholders = ownerFilter.map(() => "?").join(",");
1379 sql += ` AND c.owner IN (${placeholders})`;
1380 params.push(...ownerFilter);
1381 }
1382
1383 sql += ` ORDER BY c.created_at DESC LIMIT ?`;
1384 params.push(limit);
1385
1386 const rows = this.db.prepare(sql).all(...params) as Array<{ chunk_id: string; vector: Buffer; dimensions: number }>;
1387
1388 return rows.map((r) => ({
1389 chunkId: r.chunk_id,
1390 vector: Array.from(new Float32Array(r.vector.buffer, r.vector.byteOffset, r.dimensions)),
1391 }));
1392 }
1393
1394 getEmbedding(chunkId: string): number[] | null {
1395 const row = this.db.prepare(

Callers 1

vectorSearchFunction · 0.45

Calls 5

getAllEmbeddingsMethod · 0.95
mapMethod · 0.80
allMethod · 0.80
prepareMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected