Skip to content

Commit

Permalink
fix: the duplicated data bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
LGDoor committed Aug 11, 2023
1 parent a9e22ba commit 726c801
Show file tree
Hide file tree
Showing 2 changed files with 291,818 additions and 2,637 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.azure.acme.assist.openai.RecordEntry;
import com.azure.acme.assist.openai.SimpleMemoryVectorStore;
import com.azure.acme.assist.openai.TextSplitter;
import com.azure.acme.assist.openai.VectorStore;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

Expand All @@ -32,9 +31,6 @@ public class VectorStoreService {
@Autowired
private AcmeAzureOpenAIClient client;

@Autowired
private VectorStore vectorStore;

public void buildFromJson(List<String> files, String saveToPath, List<String> pages, String format)
throws IOException {
if (CollectionUtils.isEmpty(files)) {
Expand All @@ -46,6 +42,7 @@ public void buildFromJson(List<String> files, String saveToPath, List<String> pa

var objectMapper = new ObjectMapper();
var splitter = new TextSplitter();
var vectorStore = new SimpleMemoryVectorStore();
for (var file : files) {
List<Product> products = null;
if (format == null || "json".equals(format)) {
Expand Down Expand Up @@ -90,7 +87,7 @@ public void buildFromJson(List<String> files, String saveToPath, List<String> pa
}
}
}
((SimpleMemoryVectorStore) vectorStore).saveToJsonFile(new File(saveToPath));
vectorStore.saveToJsonFile(new File(saveToPath));

log.info("All documents are loaded to the local vector store. The index file saved to: {}", saveToPath);
}
Expand Down
Loading

0 comments on commit 726c801

Please sign in to comment.