Revert "Remove UUID Enforcement for ID Column in PGVectorStore"

This reverts commit bac507c62a.
This commit is contained in:
Ilayaperumal Gopinathan
2025-01-24 12:37:59 +00:00
parent bac507c62a
commit 224191aea7
3 changed files with 2 additions and 22 deletions

View File

@@ -136,10 +136,6 @@ public class Document {
this(new RandomIdGenerator().generateId(), text, null, metadata, null);
}
public Document(String id, String text) {
this(id, text, new HashMap<>());
}
public Document(String id, String text, Map<String, Object> metadata) {
this(id, text, null, metadata, null);
}

View File

@@ -152,7 +152,6 @@ import org.springframework.util.StringUtils;
* @author Thomas Vitale
* @author Soby Chacko
* @author Sebastien Deleuze
* @author Jihoon Kim
* @since 1.0.0
*/
public class PgVectorStore extends AbstractObservationVectorStore implements InitializingBean {
@@ -273,13 +272,13 @@ public class PgVectorStore extends AbstractObservationVectorStore implements Ini
public void setValues(PreparedStatement ps, int i) throws SQLException {
var document = batch.get(i);
var id = document.getId();
var content = document.getText();
var json = toJson(document.getMetadata());
var embedding = embeddings.get(documents.indexOf(document));
var pGvector = new PGvector(embedding);
StatementCreatorUtils.setParameterValue(ps, 1, SqlTypeValue.TYPE_UNKNOWN, id);
StatementCreatorUtils.setParameterValue(ps, 1, SqlTypeValue.TYPE_UNKNOWN,
UUID.fromString(document.getId()));
StatementCreatorUtils.setParameterValue(ps, 2, SqlTypeValue.TYPE_UNKNOWN, content);
StatementCreatorUtils.setParameterValue(ps, 3, SqlTypeValue.TYPE_UNKNOWN, json);
StatementCreatorUtils.setParameterValue(ps, 4, SqlTypeValue.TYPE_UNKNOWN, pGvector);

View File

@@ -29,7 +29,6 @@ import javax.sql.DataSource;
import com.zaxxer.hikari.HikariDataSource;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@@ -68,7 +67,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Muthukumaran Navaneethakrishnan
* @author Christian Tzolov
* @author Thomas Vitale
* @author Jihoon Kim
*/
@Testcontainers
@EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+")
@@ -168,19 +166,6 @@ public class PgVectorStoreIT {
});
}
@Test
public void shouldAllowNonUuidFormat() {
this.contextRunner.withPropertyValues("test.spring.ai.vectorstore.pgvector.distanceType=" + "COSINE_DISTANCE")
.run(context -> {
VectorStore vectorStore = context.getBean(VectorStore.class);
vectorStore.add(List.of(new Document("NOT_UUID", "TEXT")));
dropTable(context);
});
}
@ParameterizedTest(name = "Filter expression {0} should return {1} records ")
@MethodSource("provideFilters")
public void searchWithInFilter(String expression, Integer expectedRecords) {