All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkiverse.langchain4j.easyrag.EasyRagManualIngestion Maven / Gradle / Ivy

There is a newer version: 0.23.0.CR2
Show newest version
package io.quarkiverse.langchain4j.easyrag;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.spi.CDI;

import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.store.embedding.EmbeddingStore;
import io.quarkiverse.langchain4j.easyrag.runtime.EasyRagConfig;
import io.quarkiverse.langchain4j.easyrag.runtime.EasyRagIngestor;
import io.quarkiverse.langchain4j.easyrag.runtime.EasyRagRecorder;
import io.quarkiverse.langchain4j.easyrag.runtime.IngestionStrategy;

@ApplicationScoped
public class EasyRagManualIngestion {

    public void ingest() {
        EasyRagConfig config = EasyRagRecorder.easyRagConfig;
        if (config.ingestionStrategy() != IngestionStrategy.MANUAL) {
            throw new IllegalStateException("Manual ingestion trigger called when " +
                    "`quarkus.langchain4j.easy-rag.ingestion-strategy` is not MANUAL");
        }
        EmbeddingModel embeddingModel = CDI.current().select(EmbeddingModel.class).get();
        EmbeddingStore embeddingStore = CDI.current().select(EmbeddingStore.class).get();
        EasyRagIngestor ingestor = new EasyRagIngestor(embeddingModel, embeddingStore, config);
        ingestor.ingest();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy