Skip to content

Commit af061d4

Browse files
committed
Add an option to change the path to source documents for chatbot example
1 parent 66bd02a commit af061d4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

samples/chatbot/src/main/java/io/quarkiverse/langchain4j/sample/chatbot/IngestorExample.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static dev.langchain4j.data.document.splitter.DocumentSplitters.recursive;
44

55
import java.io.File;
6+
import java.nio.file.Path;
67
import java.util.List;
78

89
import jakarta.enterprise.context.ApplicationScoped;
@@ -17,6 +18,7 @@
1718
import dev.langchain4j.store.embedding.EmbeddingStoreIngestor;
1819
import io.quarkus.logging.Log;
1920
import io.quarkus.runtime.StartupEvent;
21+
import org.eclipse.microprofile.config.inject.ConfigProperty;
2022

2123
@ApplicationScoped
2224
public class IngestorExample {
@@ -35,10 +37,9 @@ public class IngestorExample {
3537
@Inject
3638
EmbeddingModel embeddingModel;
3739

38-
public void ingest(@Observes StartupEvent event) {
39-
Log.infof("Ingesting documents...");
40-
List<Document> documents = FileSystemDocumentLoader.loadDocuments(new File("src/main/resources/catalog").toPath(),
41-
new TextDocumentParser());
40+
public void ingest(@Observes StartupEvent event, @ConfigProperty(name = "offerings.folder", defaultValue = "src/main/resources/catalog") Path source) {
41+
Log.infof("Ingesting documents from " + source.toAbsolutePath());
42+
List<Document> documents = FileSystemDocumentLoader.loadDocuments(source, new TextDocumentParser());
4243
var ingestor = EmbeddingStoreIngestor.builder()
4344
.embeddingStore(store)
4445
.embeddingModel(embeddingModel)

0 commit comments

Comments
 (0)