Skip to content

Commit 317b4f1

Browse files
committed
👌 IMPROVE: Optimize latency by fetching common data once
1 parent 1729032 commit 317b4f1

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,18 @@ async function deployDocument({
115115
process.exit(1);
116116
}
117117

118+
// Fetch the existing documents
119+
const prodDocs = await listMemoryDocuments({
120+
account,
121+
memoryName
122+
});
123+
118124
await handleSingleDocDeploy({
119125
memory: memoryObject,
120126
account,
121127
document,
122-
overwrite
128+
overwrite,
129+
prodDocs
123130
});
124131

125132
spinner.stop(
@@ -140,23 +147,19 @@ export async function handleSingleDocDeploy({
140147
memory,
141148
account,
142149
document,
143-
overwrite
150+
overwrite,
151+
prodDocs
144152
}: {
145153
memory: MemoryI;
146154
account: Account;
147155
document: MemoryDocumentI;
148156
overwrite: boolean;
157+
prodDocs: string[];
149158
}) {
150159
p.log.info(
151160
`Checking "${memory.name}" memory for document "${document.name}".`
152161
);
153162

154-
// Fetch the existing documents
155-
const prodDocs = await listMemoryDocuments({
156-
account,
157-
memoryName: memory.name
158-
});
159-
160163
// If overwrite is present, deploy.
161164
if (overwrite) {
162165
await uploadDocumentsToMemory({

0 commit comments

Comments
 (0)