MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / addChunksBulk

Function addChunksBulk

packages/baseai/src/utils/memory/db/lib.ts:160–179  ·  view source on GitHub ↗
(
	{
		db,
		docName,
		chunks
	}: { db: Low<Schema>; docName: string; chunks: Omit<Chunk, 'id'>[] } // Array of chunks, each omitting the id field
)

Source from the content-addressed store, hash-verified

158}
159
160export async function addChunksBulk(
161 {
162 db,
163 docName,
164 chunks
165 }: { db: Low<Schema>; docName: string; chunks: Omit<Chunk, 'id'>[] } // Array of chunks, each omitting the id field
166): Promise<void> {
167 if (!db.data.documents[docName]) {
168 throw new Error(`Document with name "${docName}" does not exist`);
169 }
170
171 for (const chunk of chunks) {
172 const id = crypto.randomUUID();
173 const newChunk = ChunkSchema.parse({ ...chunk, id });
174 db.data.chunks[id] = newChunk;
175 db.data.documents[docName].chunkIds.push(id);
176 }
177
178 await db.write();
179}
180
181export async function getDocumentsFromMemory(
182 memoryNames: string[]

Callers 1

generateEmbeddingsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected