MCPcopy Index your code
hub / github.com/CommandCodeAI/BaseAI / getDocumentsFromMemory

Function getDocumentsFromMemory

packages/baseai/src/utils/memory/db/lib.ts:181–213  ·  view source on GitHub ↗
(
	memoryNames: string[]
)

Source from the content-addressed store, hash-verified

179}
180
181export async function getDocumentsFromMemory(
182 memoryNames: string[]
183): Promise<MemoryChunk[]> {
184 const memoryChunks: MemoryChunk[] = [];
185
186 // Load each memory and get the documents
187 for (const memoryName of memoryNames) {
188 // Load the memory
189 const db: Low<Schema> = await loadDb(memoryName);
190
191 // Process the documents
192 for (const [docName, document] of Object.entries(db.data.documents)) {
193 // Get the chunks for the document
194 const chunks = document.chunkIds.map(id => {
195 const chunk = db.data.chunks[id];
196 return {
197 text: chunk.text,
198 embedding: chunk.embedding,
199 attributes: {
200 memoryName,
201 docName
202 }
203 };
204 });
205
206 // Add the processed document to the list
207 memoryChunks.push(...chunks);
208 }
209 }
210
211 // Return the processed documents
212 return memoryChunks;
213}
214
215export function cosineSimilaritySearch({
216 chunks,

Callers 2

addContextFromMemoryFunction · 0.90
retrieveMemoryFunction · 0.90

Calls 1

loadDbFunction · 0.85

Tested by

no test coverage detected