diff --git a/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/EasyRagConfig.java b/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/EasyRagConfig.java index eace14739..2e1018e19 100644 --- a/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/EasyRagConfig.java +++ b/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/EasyRagConfig.java @@ -48,4 +48,12 @@ public interface EasyRagConfig { @WithDefault("5") Integer maxResults(); + /** + * The strategy to decide whether document ingestion into the store should happen at startup or not. + * The default is ON. Changing to OFF generally only makes sense if running against a persistent embedding store + * that was already populated. + */ + @WithDefault("ON") + IngestionStrategy ingestionStrategy(); + } diff --git a/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/EasyRagRecorder.java b/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/EasyRagRecorder.java index 79d15f83c..70101c325 100644 --- a/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/EasyRagRecorder.java +++ b/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/EasyRagRecorder.java @@ -31,6 +31,10 @@ public class EasyRagRecorder { private static final Logger LOGGER = Logger.getLogger(EasyRagRecorder.class); public void ingest(EasyRagConfig config, BeanContainer beanContainer) { + if (config.ingestionStrategy() == IngestionStrategy.OFF) { + LOGGER.info("Skipping document ingestion as per configuration"); + return; + } EmbeddingStore embeddingStore = beanContainer.beanInstance(EmbeddingStore.class); EmbeddingModel embeddingModel = beanContainer.beanInstance(EmbeddingModel.class); diff --git a/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/IngestionStrategy.java b/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/IngestionStrategy.java new file mode 100644 index 000000000..c288e2c9c --- /dev/null +++ b/easy-rag/runtime/src/main/java/io/quarkiverse/langchain4j/easyrag/runtime/IngestionStrategy.java @@ -0,0 +1,11 @@ +package io.quarkiverse.langchain4j.easyrag.runtime; + +public enum IngestionStrategy { + + // TODO: we'd like to also have a "if-empty" and "overwrite" strategy + // but these require some enhancements to the EmbeddingStore API + + ON, + OFF + +}