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 045313a16..b615ac7c1 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 @@ -352,9 +352,20 @@ public static Map.Entry multi2vecCohere(String vectorName, * Create a vector index with an {@code multi2vec-google} vectorizer. * * @param location Geographic region the Google Cloud model runs in. + * @deprecated Use {@link #multi2vecGoogleVertex}. */ + @Deprecated(forRemoval = true) public static Map.Entry multi2vecGoogle(String projectId, String location) { - return multi2vecGoogle(VectorIndex.DEFAULT_VECTOR_NAME, projectId, location); + return multi2vecGoogleVertex(projectId, location); + } + + /** + * Create a vector index with an {@code multi2vec-google} vectorizer. + * + * @param location Geographic region the Google Cloud model runs in. + */ + public static Map.Entry multi2vecGoogleVertex(String projectId, String location) { + return multi2vecGoogleVertex(VectorIndex.DEFAULT_VECTOR_NAME, projectId, location); } /** @@ -362,12 +373,27 @@ public static Map.Entry multi2vecGoogle(String projectId, * * @param location Geographic region the Google Cloud model runs in. * @param fn Lambda expression for optional parameters. + * @deprecated Use {@link #multi2vecGoogleVertex}. */ + @Deprecated(forRemoval = true) public static Map.Entry multi2vecGoogle( String projectId, String location, - Function> fn) { - return multi2vecGoogle(VectorIndex.DEFAULT_VECTOR_NAME, projectId, location, fn); + Function> fn) { + return multi2vecGoogleVertex(projectId, location, fn); + } + + /** + * Create a vector index with an {@code multi2vec-google} vectorizer. + * + * @param location Geographic region the Google Cloud model runs in. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecGoogleVertex( + String projectId, + String location, + Function> fn) { + return multi2vecGoogleVertex(VectorIndex.DEFAULT_VECTOR_NAME, projectId, location, fn); } /** @@ -375,9 +401,22 @@ public static Map.Entry multi2vecGoogle( * * @param vectorName Vector name. * @param location Geographic region the Google Cloud model runs in. + * @deprecated Use {@link #multi2vecGoogleVertex}. */ + @Deprecated(forRemoval = true) public static Map.Entry multi2vecGoogle(String vectorName, String projectId, String location) { - return Map.entry(vectorName, Multi2VecGoogleVectorizer.of(projectId, location)); + return multi2vecGoogleVertex(vectorName, projectId, location); + } + + /** + * Create a named vector index with an {@code multi2vec-google} vectorizer. + * + * @param vectorName Vector name. + * @param location Geographic region the Google Cloud model runs in. + */ + public static Map.Entry multi2vecGoogleVertex(String vectorName, String projectId, + String location) { + return Map.entry(vectorName, Multi2VecGoogleVectorizer.vertex(projectId, location)); } /** @@ -386,11 +425,63 @@ public static Map.Entry multi2vecGoogle(String vectorName, * @param vectorName Vector name. * @param location Geographic region the Google Cloud model runs in. * @param fn Lambda expression for optional parameters. + * @deprecated Use {@link #multi2vecGoogleVertex}. */ + @Deprecated(forRemoval = true) public static Map.Entry multi2vecGoogle(String vectorName, String projectId, String location, - Function> fn) { - return Map.entry(vectorName, Multi2VecGoogleVectorizer.of(projectId, location, fn)); + Function> fn) { + return multi2vecGoogleVertex(vectorName, projectId, location, fn); + } + + /** + * Create a named vector index with an {@code multi2vec-google} vectorizer. + * + * @param vectorName Vector name. + * @param location Geographic region the Google Cloud model runs in. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecGoogleVertex(String vectorName, + String projectId, String location, + Function> fn) { + return Map.entry(vectorName, Multi2VecGoogleVectorizer.vertex(projectId, location, fn)); + } + + /** + * Create a vector index with an {@code multi2vec-google} vectorizer. + */ + public static Map.Entry multi2vecGoogleGemini() { + return multi2vecGoogleGemini(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code multi2vec-google} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecGoogleGemini( + Function> fn) { + return multi2vecGoogleGemini(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code multi2vec-google} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry multi2vecGoogleGemini(String vectorName) { + return Map.entry(vectorName, Multi2VecGoogleVectorizer.gemini()); + } + + /** + * Create a named vector index with an {@code multi2vec-google} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecGoogleGemini(String vectorName, + Function> fn) { + return Map.entry(vectorName, Multi2VecGoogleVectorizer.gemini(fn)); } /** Create a vector index with an {@code multi2vec-jinaai} vectorizer. */ 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 c22b7b4a3..240e6b4a7 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 @@ -15,6 +15,7 @@ public record Multi2VecGoogleVectorizer( @SerializedName("projectId") String projectId, @SerializedName("model") String model, + @SerializedName("apiEndpoint") String apiEndpoint, @SerializedName("dimensions") Integer dimensions, @SerializedName("location") String location, @SerializedName("videoIntervalSeconds") Integer videoIntervalSeconds, @@ -59,20 +60,42 @@ public Object _self() { return this; } + @Deprecated(forRemoval = true) public static Multi2VecGoogleVectorizer of(String projectId, String location) { return of(projectId, location, ObjectBuilder.identity()); } + @Deprecated(forRemoval = true) public static Multi2VecGoogleVectorizer of( String projectId, String location, Function> fn) { - return fn.apply(new Builder(projectId, location)).build(); + return fn.apply(new VertexBuilder(projectId, location)).build(); + } + + public static Multi2VecGoogleVectorizer vertex(String projectId, String location) { + return vertex(projectId, location, ObjectBuilder.identity()); + } + + public static Multi2VecGoogleVectorizer vertex( + String projectId, + String location, + Function> fn) { + return fn.apply(new VertexBuilder(projectId, location)).build(); + } + + public static Multi2VecGoogleVectorizer gemini() { + return gemini(ObjectBuilder.identity()); + } + + public static Multi2VecGoogleVectorizer gemini(Function> fn) { + return fn.apply(new GeminiBuilder()).build(); } public Multi2VecGoogleVectorizer( String projectId, String model, + String apiEndpoint, Integer dimensions, String location, Integer videoIntervalSeconds, @@ -84,6 +107,7 @@ public Multi2VecGoogleVectorizer( Quantization quantization) { this.projectId = projectId; + this.apiEndpoint = apiEndpoint; this.model = model; this.dimensions = dimensions; this.location = location; @@ -100,6 +124,7 @@ public Multi2VecGoogleVectorizer(Builder builder) { this( builder.projectId, builder.model, + builder.apiEndpoint, builder.dimensions, builder.location, builder.videoIntervalSeconds, @@ -122,22 +147,33 @@ public static class Builder implements ObjectBuilder private List textFields; private List textWeights; - private final String projectId; + private String projectId; + private String apiEndpoint; private String model; private String location; private Integer dimensions; private Integer videoIntervalSeconds; + @Deprecated(forRemoval = true) public Builder(String projectId, String location) { this.projectId = projectId; this.location = location; } + protected Builder(String apiEndpoint) { + this.apiEndpoint = apiEndpoint; + } + public Builder model(String model) { this.model = model; return this; } + protected Builder apiEndpoint(String apiEndpoint) { + this.apiEndpoint = apiEndpoint; + return this; + } + public Builder dimensions(int dimensions) { this.dimensions = dimensions; return this; @@ -264,4 +300,24 @@ public Multi2VecGoogleVectorizer build() { return new Multi2VecGoogleVectorizer(this); } } + + public static class GeminiBuilder extends Builder { + public static final String BASE_URL = "generativelanguage.googleapis.com"; + + public GeminiBuilder() { + super(BASE_URL); + } + } + + public static class VertexBuilder extends Builder { + + public VertexBuilder(String projectId, String location) { + super(projectId, location); + } + + public VertexBuilder apiEndpoint(String apiEndpoint) { + super.apiEndpoint(apiEndpoint); + 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 8a60831be..368760f8a 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 @@ -787,14 +787,19 @@ public static Object[][] testCases() { }, { VectorConfig.class, - Multi2VecGoogleVectorizer.of("project-id", "location", - v -> v.imageFields("a", "b").textFields("c").videoFields("d")), + Multi2VecGoogleVectorizer.vertex("project-id", "location", + m2v -> m2v + .apiEndpoint("example.com") + .imageFields("a", "b") + .textFields("c") + .videoFields("d")), """ { "vectorIndexType": "hnsw", "vectorIndexConfig": {}, "vectorizer": { "multi2vec-google": { + "apiEndpoint": "example.com", "projectId": "project-id", "location": "location", "imageFields": ["a", "b"], @@ -807,13 +812,17 @@ public static Object[][] testCases() { }, { VectorConfig.class, - Multi2VecGoogleVectorizer.of("project-id", "location", v -> v.imageFields("a")), + Multi2VecGoogleVectorizer.vertex("project-id", "location", + m2v -> m2v + .apiEndpoint("example.com") + .imageFields("a")), """ { "vectorIndexType": "hnsw", "vectorIndexConfig": {}, "vectorizer": { "multi2vec-google": { + "apiEndpoint": "example.com", "projectId": "project-id", "location": "location", "imageFields": ["a"] @@ -824,14 +833,20 @@ public static Object[][] testCases() { }, { 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)), + Multi2VecGoogleVectorizer.vertex("project-id", "location", + m2v -> m2v + .apiEndpoint("example.com") + .imageField("a", 0.1f) + .imageField("b", 0.1f) + .textField("c", 0.8f) + .videoField("d", 0.99f)), """ { "vectorIndexType": "hnsw", "vectorIndexConfig": {}, "vectorizer": { "multi2vec-google": { + "apiEndpoint": "example.com", "projectId": "project-id", "location": "location", "imageFields": ["a", "b"], @@ -847,6 +862,37 @@ public static Object[][] testCases() { } """, }, + { + VectorConfig.class, + Multi2VecGoogleVectorizer.gemini(), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-google": { + "apiEndpoint": "generativelanguage.googleapis.com" + } + } + } + """, + }, + { + VectorConfig.class, + Multi2VecGoogleVectorizer.gemini(m2v -> m2v.dimensions(768)), + """ + { + "vectorIndexType": "hnsw", + "vectorIndexConfig": {}, + "vectorizer": { + "multi2vec-google": { + "apiEndpoint": "generativelanguage.googleapis.com", + "dimensions": 768 + } + } + } + """, + }, { VectorConfig.class, Multi2VecJinaAiVectorizer.of(v -> v.imageFields("a", "b").textFields("c")),