Skip to content

Commit 30f0df7

Browse files
committed
📦 NEW: Batch upload git memory files
1 parent 317b4f1 commit 30f0df7

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

‎packages/baseai/src/deploy/index.ts

+25-7
Original file line numberDiff line numberDiff line change
@@ -1164,14 +1164,32 @@ export async function handleGitSyncMemoryDeploy({
11641164
documents: MemoryDocumentI[];
11651165
overwrite: boolean;
11661166
}) {
1167-
for (const doc in documents) {
1168-
await new Promise(resolve => setTimeout(resolve, 800)); // To avoid rate limiting
1169-
await handleSingleDocDeploy({
1170-
memory,
1171-
account,
1172-
document: documents[doc],
1173-
overwrite: true // TODO: Implement overwrite for git-sync memories
1167+
const BATCH_SIZE = 5;
1168+
const RATE_LIMIT_DELAY = 1000;
1169+
1170+
// Fetch existing documents once
1171+
const prodDocs = await listMemoryDocuments({
1172+
account,
1173+
memoryName: memory.name
1174+
});
1175+
1176+
// Process in batches
1177+
for (let i = 0; i < documents.length; i += BATCH_SIZE) {
1178+
const batch = documents.slice(i, i + BATCH_SIZE);
1179+
const batchPromises = batch.map(async (doc, index) => {
1180+
await new Promise(resolve =>
1181+
setTimeout(resolve, index * RATE_LIMIT_DELAY)
1182+
);
1183+
return handleSingleDocDeploy({
1184+
memory,
1185+
account,
1186+
document: doc,
1187+
overwrite: true,
1188+
prodDocs
1189+
});
11741190
});
1191+
1192+
await Promise.all(batchPromises);
11751193
}
11761194
}
11771195

0 commit comments

Comments
 (0)