Skip to content

Commit 48de7b6

Browse files
committed
📦 NEW: Batch upload git memory files
1 parent 099b8b2 commit 48de7b6

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,14 +1122,32 @@ export async function handleGitSyncMemoryDeploy({
11221122
documents: MemoryDocumentI[];
11231123
overwrite: boolean;
11241124
}) {
1125-
for (const doc in documents) {
1126-
await new Promise(resolve => setTimeout(resolve, 800)); // To avoid rate limiting
1127-
await handleSingleDocDeploy({
1128-
memory,
1129-
account,
1130-
document: documents[doc],
1131-
overwrite: true // TODO: Implement overwrite for git-sync memories
1125+
const BATCH_SIZE = 5;
1126+
const RATE_LIMIT_DELAY = 1000;
1127+
1128+
// Fetch existing documents once
1129+
const prodDocs = await listMemoryDocuments({
1130+
account,
1131+
memoryName: memory.name
1132+
});
1133+
1134+
// Process in batches
1135+
for (let i = 0; i < documents.length; i += BATCH_SIZE) {
1136+
const batch = documents.slice(i, i + BATCH_SIZE);
1137+
const batchPromises = batch.map(async (doc, index) => {
1138+
await new Promise(resolve =>
1139+
setTimeout(resolve, index * RATE_LIMIT_DELAY)
1140+
);
1141+
return handleSingleDocDeploy({
1142+
memory,
1143+
account,
1144+
document: doc,
1145+
overwrite: true,
1146+
prodDocs
1147+
});
11321148
});
1149+
1150+
await Promise.all(batchPromises);
11331151
}
11341152
}
11351153

0 commit comments

Comments
 (0)