diff --git a/pom.xml b/pom.xml index 57de3cef..43d0443e 100644 --- a/pom.xml +++ b/pom.xml @@ -56,8 +56,8 @@ 2.13.2 5.5.1 3.20.0 - 5.13.4 - 1.21.3 + 4.13.2 + 2.0.2 3.27.6 1.0.4 5.20.0 @@ -134,13 +134,13 @@ org.testcontainers - weaviate + testcontainers-weaviate ${testcontainers.version} test org.testcontainers - minio + testcontainers-minio ${testcontainers.version} test @@ -150,6 +150,12 @@ ${assertj-core.version} test + + junit + junit + ${junit.version} + test + com.jparams jparams-junit4 diff --git a/src/it/java/io/weaviate/integration/VectorizersITest.java b/src/it/java/io/weaviate/integration/VectorizersITest.java new file mode 100644 index 00000000..69c6e50a --- /dev/null +++ b/src/it/java/io/weaviate/integration/VectorizersITest.java @@ -0,0 +1,81 @@ +package io.weaviate.integration; + +import java.io.IOException; +import java.util.Map; + +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TestRule; + +import io.weaviate.ConcurrentTest; +import io.weaviate.client6.v1.api.WeaviateClient; +import io.weaviate.client6.v1.api.collections.Property; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.WeaviateObject; +import io.weaviate.client6.v1.api.collections.query.FetchObjectById; +import io.weaviate.containers.Container; +import io.weaviate.containers.Model2Vec; +import io.weaviate.containers.Weaviate; + +import static org.assertj.core.api.Assertions.assertThat; + +public class VectorizersITest extends ConcurrentTest { + private static final Container.ContainerGroup compose = Container.compose( + Weaviate.custom() + .withModel2VecUrl(Model2Vec.URL) + .build(), + Container.MODEL2VEC); + @ClassRule // Bind containers to the lifetime of the test + public static final TestRule _rule = compose.asTestRule(); + private static final WeaviateClient client = compose.getClient(); + + @Test + public void testVectorizerModel2VecPropeties() throws IOException { + var collectionName = ns("Model2Vec2NamedVectors"); + client.collections.create(collectionName, + col -> col + .properties(Property.text("name"), Property.text("author")) + .vectorConfig( + VectorConfig.text2vecModel2Vec("name", v -> v.sourceProperties("name")), + VectorConfig.text2vecModel2Vec("author", v -> v.sourceProperties("author")) + ) + ); + + var model2vec = client.collections.use(collectionName); + assertThat(model2vec).isNotNull(); + + String uuid1 = "00000000-0000-0000-0000-000000000001"; + WeaviateObject> obj1 = WeaviateObject.of(o -> + o.properties(Map.of("name", "Dune", "author", "Frank Herbert")).uuid(uuid1) + ); + String uuid2 = "00000000-0000-0000-0000-000000000002"; + WeaviateObject> obj2 = WeaviateObject.of(o -> + o.properties(Map.of("name", "same content", "author", "same content")).uuid(uuid2) + ); + + var resp = model2vec.data.insertMany(obj1, obj2); + assertThat(resp).isNotNull().satisfies(s -> { + assertThat(s.errors()).isEmpty(); + }); + + var o1 = model2vec.query.fetchObjectById(uuid1, FetchObjectById.Builder::includeVector); + // Assert that for object1 we have generated 2 different vectors + assertThat(o1).get() + .extracting(WeaviateObject::vectors) + .satisfies(v -> { + assertThat(v.getSingle("name")).isNotEmpty(); + assertThat(v.getSingle("author")).isNotEmpty(); + assertThat(v.getSingle("name")).isNotEqualTo(v.getSingle("author")); + }); + + var o2 = model2vec.query.fetchObjectById(uuid2, FetchObjectById.Builder::includeVector); + // Assert that for object2 we have generated same vectors + assertThat(o2).get() + .extracting(WeaviateObject::vectors) + .satisfies(v -> { + assertThat(v.getSingle("name")).isNotEmpty(); + assertThat(v.getSingle("author")).isNotEmpty(); + assertThat(v.getSingle("name")).isEqualTo(v.getSingle("author")); + }); + } +} diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/VectorConfig.java b/src/main/java/io/weaviate/client6/v1/api/collections/VectorConfig.java index 91054467..045313a1 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/VectorConfig.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/VectorConfig.java @@ -353,8 +353,8 @@ public static Map.Entry multi2vecCohere(String vectorName, * * @param location Geographic region the Google Cloud model runs in. */ - public static Map.Entry multi2vecGoogle(String location) { - return multi2vecGoogle(VectorIndex.DEFAULT_VECTOR_NAME, location); + public static Map.Entry multi2vecGoogle(String projectId, String location) { + return multi2vecGoogle(VectorIndex.DEFAULT_VECTOR_NAME, projectId, location); } /** @@ -364,9 +364,10 @@ public static Map.Entry multi2vecGoogle(String location) { * @param fn Lambda expression for optional parameters. */ public static Map.Entry multi2vecGoogle( + String projectId, String location, Function> fn) { - return multi2vecGoogle(VectorIndex.DEFAULT_VECTOR_NAME, location, fn); + return multi2vecGoogle(VectorIndex.DEFAULT_VECTOR_NAME, projectId, location, fn); } /** @@ -375,8 +376,8 @@ public static Map.Entry multi2vecGoogle( * @param vectorName Vector name. * @param location Geographic region the Google Cloud model runs in. */ - public static Map.Entry multi2vecGoogle(String vectorName, String location) { - return Map.entry(vectorName, Multi2VecGoogleVectorizer.of(location)); + public static Map.Entry multi2vecGoogle(String vectorName, String projectId, String location) { + return Map.entry(vectorName, Multi2VecGoogleVectorizer.of(projectId, location)); } /** @@ -387,9 +388,9 @@ public static Map.Entry multi2vecGoogle(String vectorName, * @param fn Lambda expression for optional parameters. */ public static Map.Entry multi2vecGoogle(String vectorName, - String location, + String projectId, String location, Function> fn) { - return Map.entry(vectorName, Multi2VecGoogleVectorizer.of(location, fn)); + return Map.entry(vectorName, Multi2VecGoogleVectorizer.of(projectId, location, fn)); } /** Create a vector index with an {@code multi2vec-jinaai} vectorizer. */ diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Img2VecNeuralVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Img2VecNeuralVectorizer.java index 12467d28..024f32cb 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Img2VecNeuralVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Img2VecNeuralVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -46,7 +45,7 @@ public static class Builder implements ObjectBuilder { private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private Quantization quantization; - private List imageFields = new ArrayList<>(); + private List imageFields; /** Add BLOB properties to include in the embedding. */ public Builder imageFields(List fields) { diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2MultiVecJinaAiVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2MultiVecJinaAiVectorizer.java index a4daa8a7..93ed9e81 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2MultiVecJinaAiVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2MultiVecJinaAiVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -52,12 +51,12 @@ public static class Builder implements ObjectBuilder imageFields = new ArrayList<>(); - private final List textFields = new ArrayList<>(); + private List imageFields; + private List textFields; /** Add BLOB properties to include in the embedding. */ public Builder imageFields(List fields) { - imageFields.addAll(fields); + imageFields = fields; return this; } @@ -68,7 +67,7 @@ public Builder imageFields(String... fields) { /** Add TEXT properties to include in the embedding. */ public Builder textFields(List fields) { - textFields.addAll(fields); + textFields = fields; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecAwsVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecAwsVectorizer.java index ea39fe33..c7d2b299 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecAwsVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecAwsVectorizer.java @@ -1,9 +1,8 @@ package io.weaviate.client6.v1.api.collections.vectorizers; +import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.function.Function; import com.google.gson.annotations.SerializedName; @@ -64,11 +63,9 @@ public Multi2VecAwsVectorizer(Builder builder) { builder.model, builder.dimensions, builder.region, - builder.imageFields.keySet().stream().toList(), - builder.textFields.keySet().stream().toList(), - new Weights( - builder.imageFields.values().stream().toList(), - builder.textFields.values().stream().toList()), + builder.imageFields, + builder.textFields, + builder.getWeights(), builder.vectorIndex, builder.quantization); } @@ -77,8 +74,10 @@ public static class Builder implements ObjectBuilder { private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private Quantization quantization; - private Map imageFields = new LinkedHashMap<>(); - private Map textFields = new LinkedHashMap<>(); + private List imageFields; + private List imageWeights; + private List textFields; + private List textWeights; private String model; private Integer dimensions; @@ -101,7 +100,7 @@ public Builder region(String region) { /** Add BLOB properties to include in the embedding. */ public Builder imageFields(List fields) { - fields.forEach(field -> imageFields.put(field, null)); + this.imageFields = fields; return this; } @@ -117,13 +116,20 @@ public Builder imageFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder imageField(String field, float weight) { - imageFields.put(field, weight); + if (this.imageFields == null) { + this.imageFields = new ArrayList<>(); + } + if (this.imageWeights == null) { + this.imageWeights = new ArrayList<>(); + } + this.imageFields.add(field); + this.imageWeights.add(weight); return this; } /** Add TEXT properties to include in the embedding. */ public Builder textFields(List fields) { - fields.forEach(field -> textFields.put(field, null)); + this.textFields = fields; return this; } @@ -139,10 +145,24 @@ public Builder textFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder textField(String field, float weight) { - textFields.put(field, weight); + if (this.textFields == null) { + this.textFields = new ArrayList<>(); + } + if (this.textWeights == null) { + this.textWeights = new ArrayList<>(); + } + this.textFields.add(field); + this.textWeights.add(weight); return this; } + protected Weights getWeights() { + if (this.textWeights != null || this.imageWeights != null) { + return new Weights(this.imageWeights, this.textWeights); + } + return null; + } + /** * Override default vector index configuration. * diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecClipVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecClipVectorizer.java index 40148ff8..2e79a323 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecClipVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecClipVectorizer.java @@ -1,9 +1,8 @@ package io.weaviate.client6.v1.api.collections.vectorizers; +import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.function.Function; import com.google.gson.annotations.SerializedName; @@ -61,11 +60,9 @@ public static Multi2VecClipVectorizer of(Function { private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private Quantization quantization; - private Map imageFields = new LinkedHashMap<>(); - private Map textFields = new LinkedHashMap<>(); + private List imageFields; + private List imageWeights; + private List textFields; + private List textWeights; private String inferenceUrl; @@ -87,7 +86,7 @@ public Builder inferenceUrl(String inferenceUrl) { /** Add BLOB properties to include in the embedding. */ public Builder imageFields(List fields) { - fields.forEach(field -> imageFields.put(field, null)); + this.imageFields = fields; return this; } @@ -103,13 +102,20 @@ public Builder imageFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder imageField(String field, float weight) { - imageFields.put(field, weight); + if (this.imageFields == null) { + this.imageFields = new ArrayList<>(); + } + if (this.imageWeights == null) { + this.imageWeights = new ArrayList<>(); + } + this.imageFields.add(field); + this.imageWeights.add(weight); return this; } /** Add TEXT properties to include in the embedding. */ public Builder textFields(List fields) { - fields.forEach(field -> textFields.put(field, null)); + this.textFields = fields; return this; } @@ -125,7 +131,14 @@ public Builder textFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder textField(String field, float weight) { - textFields.put(field, weight); + if (this.textFields == null) { + this.textFields = new ArrayList<>(); + } + if (this.textWeights == null) { + this.textWeights = new ArrayList<>(); + } + this.textFields.add(field); + this.textWeights.add(weight); return this; } @@ -146,6 +159,13 @@ public Builder quantization(Quantization quantization) { return this; } + protected Weights getWeights() { + if (this.textWeights != null || this.imageWeights != null) { + return new Weights(this.imageWeights, this.textWeights); + } + return null; + } + @Override public Multi2VecClipVectorizer build() { return new Multi2VecClipVectorizer(this); diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecCohereVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecCohereVectorizer.java index a70e7fa8..9a572ef0 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecCohereVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecCohereVectorizer.java @@ -1,9 +1,8 @@ package io.weaviate.client6.v1.api.collections.vectorizers; +import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.function.Function; import com.google.gson.annotations.SerializedName; @@ -28,12 +27,6 @@ public record Multi2VecCohereVectorizer( @SerializedName("textFields") List textFields, /** Weights of the included properties. */ @SerializedName("weights") Weights weights, - /** - * Weaviate defaults to {@code true} if the value is not provided. - * To avoid that we send "vectorizeClassName": false all the time - * and make it impossible to enable this feature, as it is deprecated. - */ - @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -78,10 +71,8 @@ public Multi2VecCohereVectorizer( List imageFields, List textFields, Weights weights, - boolean vectorizeCollectionName, VectorIndex vectorIndex, Quantization quantization) { - this.vectorizeCollectionName = false; this.baseUrl = baseUrl; this.model = model; this.dimensions = dimensions; @@ -99,12 +90,9 @@ public Multi2VecCohereVectorizer(Builder builder) { builder.model, builder.dimensions, builder.truncate, - builder.imageFields.keySet().stream().toList(), - builder.textFields.keySet().stream().toList(), - new Weights( - builder.imageFields.values().stream().toList(), - builder.textFields.values().stream().toList()), - builder.vectorizeCollectionName, + builder.imageFields, + builder.textFields, + builder.getWeights(), builder.vectorIndex, builder.quantization); } @@ -114,8 +102,10 @@ public static class Builder implements ObjectBuilder private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private Quantization quantization; - private Map imageFields = new LinkedHashMap<>(); - private Map textFields = new LinkedHashMap<>(); + private List imageFields; + private List imageWeights; + private List textFields; + private List textWeights; private String baseUrl; private String model; @@ -145,7 +135,7 @@ public Builder truncate(String truncate) { /** Add BLOB properties to include in the embedding. */ public Builder imageFields(List fields) { - fields.forEach(field -> imageFields.put(field, null)); + this.imageFields = fields; return this; } @@ -161,13 +151,20 @@ public Builder imageFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder imageField(String field, float weight) { - imageFields.put(field, weight); + if (this.imageFields == null) { + this.imageFields = new ArrayList<>(); + } + if (this.imageWeights == null) { + this.imageWeights = new ArrayList<>(); + } + this.imageFields.add(field); + this.imageWeights.add(weight); return this; } /** Add TEXT properties to include in the embedding. */ public Builder textFields(List fields) { - fields.forEach(field -> textFields.put(field, null)); + this.textFields = fields; return this; } @@ -183,10 +180,24 @@ public Builder textFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder textField(String field, float weight) { - textFields.put(field, weight); + if (this.textFields == null) { + this.textFields = new ArrayList<>(); + } + if (this.textWeights == null) { + this.textWeights = new ArrayList<>(); + } + this.textFields.add(field); + this.textWeights.add(weight); return this; } + protected Weights getWeights() { + if (this.textWeights != null || this.imageWeights != null) { + return new Weights(this.imageWeights, this.textWeights); + } + return null; + } + /** * Override default vector index configuration. * diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecGoogleVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecGoogleVectorizer.java index 449a7e75..c22b7b4a 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecGoogleVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecGoogleVectorizer.java @@ -1,9 +1,8 @@ package io.weaviate.client6.v1.api.collections.vectorizers; +import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.function.Function; import com.google.gson.annotations.SerializedName; @@ -27,12 +26,6 @@ public record Multi2VecGoogleVectorizer( @SerializedName("textFields") List textFields, /** Weights of the included properties. */ @SerializedName("weights") Weights weights, - /** - * Weaviate defaults to {@code true} if the value is not provided. - * To avoid that we send "vectorizeClassName": false all the time - * and make it impossible to enable this feature, as it is deprecated. - */ - @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -66,14 +59,15 @@ public Object _self() { return this; } - public static Multi2VecGoogleVectorizer of(String location) { - return of(location, ObjectBuilder.identity()); + public static Multi2VecGoogleVectorizer of(String projectId, String location) { + return of(projectId, location, ObjectBuilder.identity()); } public static Multi2VecGoogleVectorizer of( + String projectId, String location, Function> fn) { - return fn.apply(new Builder(location)).build(); + return fn.apply(new Builder(projectId, location)).build(); } public Multi2VecGoogleVectorizer( @@ -86,10 +80,8 @@ public Multi2VecGoogleVectorizer( List videoFields, List textFields, Weights weights, - boolean vectorizeCollectionName, VectorIndex vectorIndex, Quantization quantization) { - this.vectorizeCollectionName = false; this.projectId = projectId; this.model = model; @@ -111,26 +103,24 @@ public Multi2VecGoogleVectorizer(Builder builder) { builder.dimensions, builder.location, builder.videoIntervalSeconds, - builder.imageFields.keySet().stream().toList(), - builder.videoFields.keySet().stream().toList(), - builder.textFields.keySet().stream().toList(), - new Weights( - builder.imageFields.values().stream().toList(), - builder.videoFields.values().stream().toList(), - builder.textFields.values().stream().toList()), - builder.vectorizeCollectionName, + builder.imageFields, + builder.videoFields, + builder.textFields, + builder.getWeights(), builder.vectorIndex, builder.quantization); } public static class Builder implements ObjectBuilder { - private final boolean vectorizeCollectionName = false; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private Quantization quantization; - private Map imageFields = new LinkedHashMap<>(); - private Map videoFields = new LinkedHashMap<>(); - private Map textFields = new LinkedHashMap<>(); + private List imageFields; + private List imageWeights; + private List videoFields; + private List videoWeights; + private List textFields; + private List textWeights; private final String projectId; private String model; @@ -138,8 +128,9 @@ public static class Builder implements ObjectBuilder private Integer dimensions; private Integer videoIntervalSeconds; - public Builder(String projectId) { + public Builder(String projectId, String location) { this.projectId = projectId; + this.location = location; } public Builder model(String model) { @@ -147,11 +138,6 @@ public Builder model(String model) { return this; } - public Builder location(String location) { - this.location = location; - return this; - } - public Builder dimensions(int dimensions) { this.dimensions = dimensions; return this; @@ -164,7 +150,7 @@ public Builder videoIntervalSeconds(int videoIntervalSeconds) { /** Add BLOB image properties to include in the embedding. */ public Builder imageFields(List fields) { - fields.forEach(field -> imageFields.put(field, null)); + this.imageFields = fields; return this; } @@ -180,13 +166,20 @@ public Builder imageFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder imageField(String field, float weight) { - imageFields.put(field, weight); + if (this.imageFields == null) { + this.imageFields = new ArrayList<>(); + } + if (this.imageWeights == null) { + this.imageWeights = new ArrayList<>(); + } + this.imageFields.add(field); + this.imageWeights.add(weight); return this; } /** Add BLOB video properties to include in the embedding. */ public Builder videoFields(List fields) { - fields.forEach(field -> videoFields.put(field, null)); + this.videoFields = fields; return this; } @@ -202,13 +195,20 @@ public Builder videoFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder videoField(String field, float weight) { - videoFields.put(field, weight); + if (this.videoFields == null) { + this.videoFields = new ArrayList<>(); + } + if (this.videoWeights == null) { + this.videoWeights = new ArrayList<>(); + } + this.videoFields.add(field); + this.videoWeights.add(weight); return this; } /** Add TEXT properties to include in the embedding. */ public Builder textFields(List fields) { - fields.forEach(field -> textFields.put(field, null)); + this.textFields = fields; return this; } @@ -224,10 +224,24 @@ public Builder textFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder textField(String field, float weight) { - textFields.put(field, weight); + if (this.textFields == null) { + this.textFields = new ArrayList<>(); + } + if (this.textWeights == null) { + this.textWeights = new ArrayList<>(); + } + this.textFields.add(field); + this.textWeights.add(weight); return this; } + protected Weights getWeights() { + if (this.textWeights != null || this.imageWeights != null || this.videoWeights != null) { + return new Weights(this.imageWeights, this.videoWeights, this.textWeights); + } + return null; + } + /** * Override default vector index configuration. * diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecJinaAiVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecJinaAiVectorizer.java index 35bb3cc9..30f6d0df 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecJinaAiVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecJinaAiVectorizer.java @@ -1,9 +1,8 @@ package io.weaviate.client6.v1.api.collections.vectorizers; +import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.function.Function; import com.google.gson.annotations.SerializedName; @@ -25,12 +24,6 @@ public record Multi2VecJinaAiVectorizer( @SerializedName("textFields") List textFields, /** Weights of the included properties. */ @SerializedName("weights") Weights weights, - /** - * Weaviate defaults to {@code true} if the value is not provided. - * To avoid that we send "vectorizeClassName": false all the time - * and make it impossible to enable this feature, as it is deprecated. - */ - @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -74,10 +67,8 @@ public Multi2VecJinaAiVectorizer( List imageFields, List textFields, Weights weights, - boolean vectorizeCollectionName, VectorIndex vectorIndex, Quantization quantization) { - this.vectorizeCollectionName = false; this.baseUrl = baseUrl; this.model = model; this.dimensions = dimensions; @@ -93,23 +84,21 @@ public Multi2VecJinaAiVectorizer(Builder builder) { builder.baseUrl, builder.model, builder.dimensions, - builder.imageFields.keySet().stream().toList(), - builder.textFields.keySet().stream().toList(), - new Weights( - builder.imageFields.values().stream().toList(), - builder.textFields.values().stream().toList()), - builder.vectorizeCollectionName, + builder.imageFields, + builder.textFields, + builder.getWeights(), builder.vectorIndex, builder.quantization); } public static class Builder implements ObjectBuilder { - private final boolean vectorizeCollectionName = false; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private Quantization quantization; - private Map imageFields = new LinkedHashMap<>(); - private Map textFields = new LinkedHashMap<>(); + private List imageFields; + private List imageWeights; + private List textFields; + private List textWeights; private String baseUrl; private String model; @@ -133,7 +122,7 @@ public Builder dimensions(int dimensions) { /** Add BLOB properties to include in the embedding. */ public Builder imageFields(List fields) { - fields.forEach(field -> imageFields.put(field, null)); + this.imageFields = fields; return this; } @@ -149,13 +138,20 @@ public Builder imageFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder imageField(String field, float weight) { - imageFields.put(field, weight); + if (this.imageFields == null) { + this.imageFields = new ArrayList<>(); + } + if (this.imageWeights == null) { + this.imageWeights = new ArrayList<>(); + } + this.imageFields.add(field); + this.imageWeights.add(weight); return this; } /** Add TEXT properties to include in the embedding. */ public Builder textFields(List fields) { - fields.forEach(field -> textFields.put(field, null)); + this.textFields = fields; return this; } @@ -171,10 +167,24 @@ public Builder textFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder textField(String field, float weight) { - textFields.put(field, weight); + if (this.textFields == null) { + this.textFields = new ArrayList<>(); + } + if (this.textWeights == null) { + this.textWeights = new ArrayList<>(); + } + this.textFields.add(field); + this.textWeights.add(weight); return this; } + protected Weights getWeights() { + if (this.textWeights != null || this.imageWeights != null) { + return new Weights(this.imageWeights, this.textWeights); + } + return null; + } + /** * Override default vector index configuration. * diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecNvidiaVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecNvidiaVectorizer.java index 42502fc1..bf1f662b 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecNvidiaVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecNvidiaVectorizer.java @@ -1,9 +1,8 @@ package io.weaviate.client6.v1.api.collections.vectorizers; +import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.function.Function; import com.google.gson.annotations.SerializedName; @@ -67,11 +66,9 @@ public Multi2VecNvidiaVectorizer(Builder builder) { builder.baseUrl, builder.model, builder.truncate, - builder.imageFields.keySet().stream().toList(), - builder.textFields.keySet().stream().toList(), - new Weights( - builder.imageFields.values().stream().toList(), - builder.textFields.values().stream().toList()), + builder.imageFields, + builder.textFields, + builder.getWeights(), builder.vectorIndex, builder.quantization); } @@ -80,8 +77,10 @@ public static class Builder implements ObjectBuilder private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private Quantization quantization; - private Map imageFields = new LinkedHashMap<>(); - private Map textFields = new LinkedHashMap<>(); + private List imageFields; + private List imageWeights; + private List textFields; + private List textWeights; private String baseUrl; private String model; @@ -105,7 +104,7 @@ public Builder truncate(Boolean truncate) { /** Add BLOB properties to include in the embedding. */ public Builder imageFields(List fields) { - fields.forEach(field -> imageFields.put(field, null)); + this.imageFields = fields; return this; } @@ -121,13 +120,20 @@ public Builder imageFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder imageField(String field, float weight) { - imageFields.put(field, weight); + if (this.imageFields == null) { + this.imageFields = new ArrayList<>(); + } + if (this.imageWeights == null) { + this.imageWeights = new ArrayList<>(); + } + this.imageFields.add(field); + this.imageWeights.add(weight); return this; } /** Add TEXT properties to include in the embedding. */ public Builder textFields(List fields) { - fields.forEach(field -> textFields.put(field, null)); + this.textFields = fields; return this; } @@ -143,10 +149,24 @@ public Builder textFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder textField(String field, float weight) { - textFields.put(field, weight); + if (this.textFields == null) { + this.textFields = new ArrayList<>(); + } + if (this.textWeights == null) { + this.textWeights = new ArrayList<>(); + } + this.textFields.add(field); + this.textWeights.add(weight); return this; } + protected Weights getWeights() { + if (this.textWeights != null || this.imageWeights != null) { + return new Weights(this.imageWeights, this.textWeights); + } + return null; + } + /** * Override default vector index configuration. * diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecVoyageAiVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecVoyageAiVectorizer.java index e13075ce..2f3da32e 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecVoyageAiVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecVoyageAiVectorizer.java @@ -1,9 +1,8 @@ package io.weaviate.client6.v1.api.collections.vectorizers; +import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.function.Function; import com.google.gson.annotations.SerializedName; @@ -25,12 +24,6 @@ public record Multi2VecVoyageAiVectorizer( @SerializedName("textFields") List textFields, /** Weights of the included properties. */ @SerializedName("weights") Weights weights, - /** - * Weaviate defaults to {@code true} if the value is not provided. - * To avoid that we send "vectorizeClassName": false all the time - * and make it impossible to enable this feature, as it is deprecated. - */ - @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -74,10 +67,8 @@ public Multi2VecVoyageAiVectorizer( List imageFields, List textFields, Weights weights, - boolean vectorizeCollectionName, VectorIndex vectorIndex, Quantization quantization) { - this.vectorizeCollectionName = false; this.baseUrl = baseUrl; this.model = model; this.truncate = truncate; @@ -93,12 +84,9 @@ public Multi2VecVoyageAiVectorizer(Builder builder) { builder.baseUrl, builder.model, builder.truncate, - builder.imageFields.keySet().stream().toList(), - builder.textFields.keySet().stream().toList(), - new Weights( - builder.imageFields.values().stream().toList(), - builder.textFields.values().stream().toList()), - builder.vectorizeCollectionName, + builder.imageFields, + builder.textFields, + builder.getWeights(), builder.vectorIndex, builder.quantization); } @@ -108,8 +96,10 @@ public static class Builder implements ObjectBuilder imageFields = new LinkedHashMap<>(); - private Map textFields = new LinkedHashMap<>(); + private List imageFields; + private List imageWeights; + private List textFields; + private List textWeights; private String baseUrl; private String model; @@ -133,7 +123,7 @@ public Builder truncate(boolean truncate) { /** Add BLOB properties to include in the embedding. */ public Builder imageFields(List fields) { - fields.forEach(field -> imageFields.put(field, null)); + this.imageFields = fields; return this; } @@ -149,13 +139,20 @@ public Builder imageFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder imageField(String field, float weight) { - imageFields.put(field, weight); + if (this.imageFields == null) { + this.imageFields = new ArrayList<>(); + } + if (this.imageWeights == null) { + this.imageWeights = new ArrayList<>(); + } + this.imageFields.add(field); + this.imageWeights.add(weight); return this; } /** Add TEXT properties to include in the embedding. */ public Builder textFields(List fields) { - fields.forEach(field -> textFields.put(field, null)); + this.textFields = fields; return this; } @@ -171,10 +168,24 @@ public Builder textFields(String... fields) { * @param weight Custom weight between 0.0 and 1.0. */ public Builder textField(String field, float weight) { - textFields.put(field, weight); + if (this.textFields == null) { + this.textFields = new ArrayList<>(); + } + if (this.textWeights == null) { + this.textWeights = new ArrayList<>(); + } + this.textFields.add(field); + this.textWeights.add(weight); return this; } + protected Weights getWeights() { + if (this.textWeights != null || this.imageWeights != null) { + return new Weights(this.imageWeights, this.textWeights); + } + return null; + } + /** * Override default vector index configuration. * diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2MultiVecJinaAiVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2MultiVecJinaAiVectorizer.java index 33d9e1fa..4372a426 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2MultiVecJinaAiVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2MultiVecJinaAiVectorizer.java @@ -24,7 +24,7 @@ public record Text2MultiVecJinaAiVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecAwsVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecAwsVectorizer.java index 991b3049..f8cf2362 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecAwsVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecAwsVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -27,7 +26,7 @@ public record Text2VecAwsVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -120,7 +119,7 @@ public Text2VecAwsVectorizer(Builder builder) { public abstract static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private final Service service; @@ -168,7 +167,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecAzureOpenAiVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecAzureOpenAiVectorizer.java index 5b7fa72f..c0ef4a33 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecAzureOpenAiVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecAzureOpenAiVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -26,7 +25,7 @@ public record Text2VecAzureOpenAiVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -94,7 +93,7 @@ public Text2VecAzureOpenAiVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String baseUrl; @@ -137,7 +136,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecCohereVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecCohereVectorizer.java index aac725bc..9731a245 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecCohereVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecCohereVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -25,7 +24,7 @@ public record Text2VecCohereVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -102,7 +101,7 @@ public Text2VecCohereVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String model; @@ -137,7 +136,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecDatabricksVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecDatabricksVectorizer.java index a1e99d41..708eb7be 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecDatabricksVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecDatabricksVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -23,7 +22,7 @@ public record Text2VecDatabricksVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -82,7 +81,7 @@ public Text2VecDatabricksVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String endpoint; @@ -105,7 +104,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecGoogleVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecGoogleVectorizer.java index daa1c999..1791a090 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecGoogleVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecGoogleVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -15,7 +14,6 @@ public record Text2VecGoogleVectorizer( @SerializedName("apiEndpoint") String apiEndpoint, @SerializedName("model") String model, - @SerializedName("modelId") String modelId, @SerializedName("titleProperty") String titleProperty, @SerializedName("dimensions") Integer dimensions, @SerializedName("taskType") TaskType taskType, @@ -30,7 +28,7 @@ public record Text2VecGoogleVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -88,7 +86,6 @@ public static Text2VecGoogleVectorizer vertex( public Text2VecGoogleVectorizer( String apiEndpoint, String model, - String modelId, String titleProperty, Integer dimensions, TaskType taskType, @@ -100,7 +97,6 @@ public Text2VecGoogleVectorizer( Quantization quantization) { this.apiEndpoint = apiEndpoint; this.model = model; - this.modelId = modelId; this.titleProperty = titleProperty; this.dimensions = dimensions; this.projectId = projectId; @@ -116,7 +112,6 @@ public Text2VecGoogleVectorizer(Builder builder) { this( builder.apiEndpoint, builder.model, - builder.modelId, builder.titleProperty, builder.dimensions, builder.taskType, @@ -131,7 +126,7 @@ public Text2VecGoogleVectorizer(Builder builder) { public abstract static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; /** Embedding service base URL. */ @@ -140,7 +135,6 @@ public abstract static class Builder implements ObjectBuilder properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecHuggingFaceVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecHuggingFaceVectorizer.java index 7dc6ebd4..1d3a200d 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecHuggingFaceVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecHuggingFaceVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -28,7 +27,7 @@ public record Text2VecHuggingFaceVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -101,7 +100,7 @@ public Text2VecHuggingFaceVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String endpointUrl; @@ -156,7 +155,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecJinaAiVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecJinaAiVectorizer.java index 2d8fca69..a13fa628 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecJinaAiVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecJinaAiVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -24,7 +23,7 @@ public record Text2VecJinaAiVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -89,7 +88,7 @@ public Text2VecJinaAiVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String model; @@ -118,7 +117,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecMistralVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecMistralVectorizer.java index efabaff8..14bdd5b0 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecMistralVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecMistralVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -23,7 +22,7 @@ public record Text2VecMistralVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -84,7 +83,7 @@ public Text2VecMistralVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String baseUrl; @@ -107,7 +106,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecModel2VecVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecModel2VecVectorizer.java index c92e7b8e..fbda7a44 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecModel2VecVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecModel2VecVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -22,7 +21,7 @@ public record Text2VecModel2VecVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -77,7 +76,7 @@ public Text2VecModel2VecVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String inferenceUrl; @@ -94,7 +93,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecMorphVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecMorphVectorizer.java index f87b055c..7dfd31f8 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecMorphVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecMorphVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -17,7 +16,7 @@ public record Text2VecMorphVectorizer( @SerializedName("model") String model, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -53,7 +52,7 @@ public Text2VecMorphVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String baseUrl; @@ -76,7 +75,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecNvidiaVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecNvidiaVectorizer.java index e06016c8..f33e46a5 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecNvidiaVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecNvidiaVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -24,7 +23,7 @@ public record Text2VecNvidiaVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -86,7 +85,7 @@ public Text2VecNvidiaVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String baseUrl; @@ -115,7 +114,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecOllamaVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecOllamaVectorizer.java index 64a70875..10718769 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecOllamaVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecOllamaVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -23,7 +22,7 @@ public record Text2VecOllamaVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -82,7 +81,7 @@ public Text2VecOllamaVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String apiEndpoint; @@ -105,7 +104,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecOpenAiVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecOpenAiVectorizer.java index f2eed971..60667d0c 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecOpenAiVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecOpenAiVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -26,7 +25,7 @@ public record Text2VecOpenAiVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -105,7 +104,7 @@ public Text2VecOpenAiVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String baseUrl; @@ -146,7 +145,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecTransformersVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecTransformersVectorizer.java index 3f2a3c68..3ff04bae 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecTransformersVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecTransformersVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -20,7 +19,7 @@ public record Text2VecTransformersVectorizer( @SerializedName("dimensions") Integer dimensions, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -66,7 +65,7 @@ public Text2VecTransformersVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String inferenceUrl; @@ -107,7 +106,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecVoyageAiVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecVoyageAiVectorizer.java index c9ba25ad..94fda720 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecVoyageAiVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecVoyageAiVectorizer.java @@ -1,8 +1,6 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.function.Function; @@ -26,7 +24,7 @@ public record Text2VecVoyageAiVectorizer( */ @Deprecated @SerializedName("vectorizeClassName") boolean vectorizeCollectionName, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -42,6 +40,13 @@ public Object _self() { return this; } + public static String VOYAGE_3_LARGE = "voyage-3-large"; + public static String VOYAGE_3_5 = "voyage-3.5"; + public static String VOYAGE_3_5_lite = "voyage-3.5-lite"; + public static String VOYAGE_3 = "voyage-3"; + public static String VOYAGE_3_LITE = "voyage-3-lite"; + public static String VOYAGE_CONTEXT_3 = "voyage-context-3"; + public static Text2VecVoyageAiVectorizer of() { return of(ObjectBuilder.identity()); } @@ -70,7 +75,7 @@ public Text2VecVoyageAiVectorizer( this.dimensions = dimensions; this.vectorizeCollectionName = false; - this.sourceProperties = Collections.emptyList(); + this.sourceProperties = sourceProperties; this.vectorIndex = vectorIndex; this.quantization = quantization; } @@ -90,7 +95,7 @@ public Text2VecVoyageAiVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private String model; @@ -125,7 +130,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecWeaviateVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecWeaviateVectorizer.java index 05972637..c08d5347 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecWeaviateVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecWeaviateVectorizer.java @@ -1,6 +1,5 @@ package io.weaviate.client6.v1.api.collections.vectorizers; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; @@ -20,7 +19,7 @@ public record Text2VecWeaviateVectorizer( /** Embedding model. */ @SerializedName("model") String model, /** Properties included in the embedding. */ - @SerializedName("sourceProperties") List sourceProperties, + @SerializedName("properties") List sourceProperties, /** Vector index configuration. */ VectorIndex vectorIndex, /** Vector quantization method. */ @@ -63,7 +62,7 @@ public static class Builder implements ObjectBuilder private String baseUrl; private Integer dimensions; private String model; - private List sourceProperties = new ArrayList<>(); + private List sourceProperties; /** * Base URL for Weaviate Embeddings Service. This can be omitted when connecting @@ -99,7 +98,7 @@ public Builder sourceProperties(String... properties) { /** Add properties to include in the embedding. */ public Builder sourceProperties(List properties) { - this.sourceProperties.addAll(properties); + this.sourceProperties = properties; return this; } diff --git a/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java b/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java index f775dd36..7dee98b0 100644 --- a/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java +++ b/src/test/java/io/weaviate/client6/v1/internal/json/JSONTest.java @@ -1,5 +1,26 @@ package io.weaviate.client6.v1.internal.json; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2MultiVecJinaAiVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecAwsVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecCohereVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecGoogleVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecJinaAiVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecNvidiaVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecVoyageAiVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecAwsVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecAzureOpenAiVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecDatabricksVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecGoogleVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecHuggingFaceVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecJinaAiVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecMistralVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecModel2VecVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecMorphVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecNvidiaVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecOllamaVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecOpenAiVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecTransformersVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecVoyageAiVectorizer; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -122,13 +143,392 @@ public static Object[][] testCases() { "vectorIndexConfig": {}, "vectorizer": { "text2vec-cohere": { - "vectorizeClassName": false, - "sourceProperties": [] + "vectorizeClassName": false } } } """, }, + { + VectorConfig.class, + Text2VecCohereVectorizer.of( + v -> v.sourceProperties("a").model("embed-v4.0") + ), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-cohere": { + "model": "embed-v4.0", + "vectorizeClassName": false, + "properties": ["a"] + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecAwsVectorizer.bedrock("amazon.titan-embed-text-v2:0"), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-aws": { + "service": "bedrock", + "model": "amazon.titan-embed-text-v2:0", + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecDatabricksVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-databricks": { + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecDatabricksVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-databricks": { + "properties": ["a"], + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecGoogleVectorizer.vertex("projectId", v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-google": { + "apiEndpoint":"us-central1-aiplatform.googleapis.com", + "projectId": "projectId", + "properties": ["a"], + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecGoogleVectorizer.aiStudio(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-google": { + "apiEndpoint":"generativelanguage.googleapis.com", + "properties": ["a"], + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecHuggingFaceVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-huggingface": { + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecHuggingFaceVectorizer.of(v -> v.sourceProperties("a").model("model")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-huggingface": { + "model": "model", + "properties": ["a"], + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecJinaAiVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-jinaai": { + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecJinaAiVectorizer.of(v -> v.sourceProperties("a").model(Text2VecJinaAiVectorizer.JINA_EMBEDDINGS_V2_BASE_EN)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-jinaai": { + "model": "jina-embeddings-v2-base-en", + "properties": ["a"], + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecMistralVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-mistral": { + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecMistralVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-mistral": { + "properties": ["a"], + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecModel2VecVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-model2vec": { + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecModel2VecVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-model2vec": { + "properties": ["a"], + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecMorphVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-morph": {} + } + } + """, + }, + { + VectorConfig.class, + Text2VecMorphVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-morph": { + "properties": ["a"] + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecNvidiaVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-nvidia": { + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecNvidiaVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-nvidia": { + "properties": ["a"], + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecOllamaVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-ollama": { + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecOllamaVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-ollama": { + "properties": ["a"], + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecOpenAiVectorizer.of(v -> v.sourceProperties("a").model(Text2VecOpenAiVectorizer.TEXT_EMBEDDING_3_LARGE)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-openai": { + "model": "text-embedding-3-large", + "properties": ["a"], + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecTransformersVectorizer.of(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-transformers": {} + } + } + """, + }, + { + VectorConfig.class, + Text2VecVoyageAiVectorizer.of(v -> v.sourceProperties("a").model(Text2VecVoyageAiVectorizer.VOYAGE_3_LARGE)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-voyageai": { + "model": "voyage-3-large", + "properties": ["a"], + "vectorizeClassName":false + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecTransformersVectorizer.of(v -> v.sourceProperties("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-transformers": { + "properties": ["a"] + } + } + } + """, + }, { VectorConfig.class, Text2VecWeaviateVectorizer.of(t2v -> t2v @@ -143,14 +543,469 @@ public static Object[][] testCases() { "text2vec-weaviate": { "baseURL": "http://example.com", "dimensions": 4, - "model": "very-good-model", - "sourceProperties": [] - + "model": "very-good-model" } } } """, }, + { + VectorConfig.class, + Text2VecOpenAiVectorizer.of(v -> v.sourceProperties("a", "b")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-openai": { + "vectorizeClassName": false, + "properties": ["a", "b"] + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecVoyageAiVectorizer.of(v -> + v.sourceProperties(List.of("a", "b", "c")).model("voyage-3-large")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-voyageai": { + "model": "voyage-3-large", + "vectorizeClassName": false, + "properties": ["a", "b", "c"] + } + } + } + """, + }, + { + VectorConfig.class, + Text2VecVoyageAiVectorizer.of(v -> + v.dimensions(256).model("voyage-3-large")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "text2vec-voyageai": { + "model": "voyage-3-large", + "dimensions": 256, + "vectorizeClassName": false + } + } + } + """, + }, + { + VectorConfig.class, + Img2VecNeuralVectorizer.of(v -> v.imageFields("a", "b")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "img2vec-neural": { + "imageFields": ["a", "b"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2MultiVecJinaAiVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2multivec-jinaai": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecClipVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-clip": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecClipVectorizer.of(v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-clip": { + "imageFields": ["a"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecClipVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-clip": { + "imageFields": ["a", "b"], + "textFields": ["c"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8] + } + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecAwsVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-aws": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecAwsVectorizer.of(v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-aws": { + "imageFields": ["a"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecAwsVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-aws": { + "imageFields": ["a", "b"], + "textFields": ["c"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8] + } + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecCohereVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-cohere": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecCohereVectorizer.of(v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-cohere": { + "imageFields": ["a"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecCohereVectorizer.of(v -> v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-cohere": { + "imageFields": ["a", "b"], + "textFields": ["c"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8] + } + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecGoogleVectorizer.of("project-id", "location", v -> v.imageFields("a", "b").textFields("c").videoFields("d")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-google": { + "projectId": "project-id", + "location": "location", + "imageFields": ["a", "b"], + "textFields": ["c"], + "videoFields": ["d"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecGoogleVectorizer.of("project-id", "location", v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-google": { + "projectId": "project-id", + "location": "location", + "imageFields": ["a"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecGoogleVectorizer.of("project-id", "location",v -> + v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f).videoField("d", 0.99f) + ), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-google": { + "projectId": "project-id", + "location": "location", + "imageFields": ["a", "b"], + "textFields": ["c"], + "videoFields": ["d"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8], + "videoWeights":[0.99] + } + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecJinaAiVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-jinaai": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecJinaAiVectorizer.of(v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-jinaai": { + "imageFields": ["a"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecJinaAiVectorizer.of(v -> + v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f) + ), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-jinaai": { + "imageFields": ["a", "b"], + "textFields": ["c"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8] + } + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecNvidiaVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-nvidia": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecNvidiaVectorizer.of(v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-nvidia": { + "imageFields": ["a"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecNvidiaVectorizer.of(v -> + v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f) + ), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-nvidia": { + "imageFields": ["a", "b"], + "textFields": ["c"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8] + } + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecVoyageAiVectorizer.of(v -> v.imageFields("a", "b").textFields("c")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-voyageai": { + "imageFields": ["a", "b"], + "textFields": ["c"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecVoyageAiVectorizer.of(v -> v.imageFields("a")), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-voyageai": { + "imageFields": ["a"] + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecVoyageAiVectorizer.of(v -> + v.imageField("a", 0.1f).imageField("b", 0.1f).textField("c", 0.8f) + ), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-voyageai": { + "imageFields": ["a", "b"], + "textFields": ["c"], + "weights":{ + "imageWeights":[0.1,0.1], + "textWeights":[0.8] + } + } + } + } + """, + }, // VectorIndex.CustomTypeAdapterFactory {