Skip to content

Commit 099b8b2

Browse files
committed
👌 IMPROVE: Optimize latency by fetching common data once
1 parent ebd8857 commit 099b8b2

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
@@ -114,11 +114,18 @@ async function deployDocument({
114114
process.exit(1);
115115
}
116116

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

124131
spinner.stop(
@@ -139,23 +146,19 @@ export async function handleSingleDocDeploy({
139146
memory,
140147
account,
141148
document,
142-
overwrite
149+
overwrite,
150+
prodDocs
143151
}: {
144152
memory: MemoryI;
145153
account: Account;
146154
document: MemoryDocumentI;
147155
overwrite: boolean;
156+
prodDocs: string[];
148157
}) {
149158
p.log.info(
150159
`Checking "${memory.name}" memory for document "${document.name}".`
151160
);
152161

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

0 commit comments

Comments
 (0)