Set embeddings on added Document objects for Milvus and PgVector stores.

This commit is contained in:
Francisco Javier Torres
2024-07-03 12:41:02 +02:00
committed by Mark Pollack
parent 6931148377
commit 867bd173e5
2 changed files with 4 additions and 2 deletions

View File

@@ -272,7 +272,7 @@ public class MilvusVectorStore implements VectorStore, InitializingBean {
for (Document document : documents) {
List<Double> embedding = this.embeddingModel.embed(document);
document.setEmbedding(embedding);
docIdArray.add(document.getId());
// Use a (future) DocumentTextLayoutFormatter instance to extract
// the content used to compute the embeddings

View File

@@ -166,7 +166,9 @@ public class PgVectorStore implements VectorStore, InitializingBean {
var document = documents.get(i);
var content = document.getContent();
var json = toJson(document.getMetadata());
var pGvector = new PGvector(toFloatArray(embeddingModel.embed(document)));
var embedding = embeddingModel.embed(document);
document.setEmbedding(embedding);
var pGvector = new PGvector(toFloatArray(embedding));
StatementCreatorUtils.setParameterValue(ps, 1, SqlTypeValue.TYPE_UNKNOWN,
UUID.fromString(document.getId()));