Skip to content

Commit

Permalink
Merge branch 'main' into adds-vector-store
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli authored May 27, 2024
2 parents 50fd3a1 + 8eb656d commit bbb8d13
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.learning.ai.llmragwithspringai.service;

import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.chat.prompt.transformer.TransformerContentType;
import org.springframework.ai.document.Document;
import org.springframework.ai.document.DocumentReader;
import org.springframework.ai.document.DocumentTransformer;
import org.springframework.ai.reader.ExtractedTextFormatter;
Expand Down Expand Up @@ -53,15 +51,12 @@ public void loadData(Resource documentResource) {
}
if (documentReader != null) {
LOGGER.info("Loading text document to redis vector database");
var metadataEnricher = new DocumentTransformer() {
@Override
public List<Document> apply(List<Document> documents) {
documents.forEach(d -> {
Map<String, Object> metadata = d.getMetadata();
metadata.put(TransformerContentType.EXTERNAL_KNOWLEDGE, "true");
});
return documents;
}
DocumentTransformer metadataEnricher = documents -> {
documents.forEach(d -> {
Map<String, Object> metadata = d.getMetadata();
metadata.put(TransformerContentType.EXTERNAL_KNOWLEDGE, "true");
});
return documents;
};
vectorStore.accept(metadataEnricher.apply(tokenTextSplitter.apply(documentReader.get())));
LOGGER.info("Loaded document to redis vector database.");
Expand Down

0 comments on commit bbb8d13

Please sign in to comment.