Skip to content

Commit f174c96

Browse files
committed
Reuse embeddings
Closes #663
1 parent 9895297 commit f174c96

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

rag/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/EasyRagRecorder.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ public void ingest(EasyRagConfig config, BeanContainer beanContainer) {
5959
ingestDocumentsFromFilesystem(config, embeddingStore, embeddingModel);
6060
LOGGER.infof("Writing embeddings to %s", embeddingsFile);
6161
((InMemoryEmbeddingStore<TextSegment>) embeddingStore).serializeToFile(embeddingsFile);
62+
} else {
63+
// This is here because in the case where the file exists, the EmbeddingStore will be
64+
// lazily initialized upon first use. We want it eagerly initialized.
65+
// We need to call a method on the bean instance to eagerly initialize it
66+
// https://github.com/quarkusio/quarkus/issues/41159 may make this less "hacky" in the future
67+
embeddingStore.toString();
6268
}
6369
} else {
6470
ingestDocumentsFromFilesystem(config, embeddingStore, embeddingModel);

0 commit comments

Comments
 (0)