Skip to content

Commit 08b46ca

Browse files
committed
fix(memory): reset local init lock after failures
1 parent 2bbe896 commit 08b46ca

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/memory/embeddings.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,22 @@ async function createLocalEmbeddingProvider(
101101
return initPromise;
102102
}
103103
initPromise = (async () => {
104-
if (!llama) {
105-
llama = await getLlama({ logLevel: LlamaLogLevel.error });
106-
}
107-
if (!embeddingModel) {
108-
const resolved = await resolveModelFile(modelPath, modelCacheDir || undefined);
109-
embeddingModel = await llama.loadModel({ modelPath: resolved });
110-
}
111-
if (!embeddingContext) {
112-
embeddingContext = await embeddingModel.createEmbeddingContext();
104+
try {
105+
if (!llama) {
106+
llama = await getLlama({ logLevel: LlamaLogLevel.error });
107+
}
108+
if (!embeddingModel) {
109+
const resolved = await resolveModelFile(modelPath, modelCacheDir || undefined);
110+
embeddingModel = await llama.loadModel({ modelPath: resolved });
111+
}
112+
if (!embeddingContext) {
113+
embeddingContext = await embeddingModel.createEmbeddingContext();
114+
}
115+
return embeddingContext;
116+
} catch (err) {
117+
initPromise = null;
118+
throw err;
113119
}
114-
return embeddingContext;
115120
})();
116121
return initPromise;
117122
};

0 commit comments

Comments
 (0)