Skip to content

Commit

Permalink
Merge pull request #518 from jmartisk/easy-rag-ingestion-strategies
Browse files Browse the repository at this point in the history
Ability to turn off ingestion with Easy RAG
  • Loading branch information
jmartisk committed Apr 26, 2024
2 parents cb4863d + 5e9ccc0 commit fb2bdd7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextSegment> embeddingStore = beanContainer.beanInstance(EmbeddingStore.class);
EmbeddingModel embeddingModel = beanContainer.beanInstance(EmbeddingModel.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -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

}

0 comments on commit fb2bdd7

Please sign in to comment.