diff --git a/src/it/java/io/weaviate/containers/Container.java b/src/it/java/io/weaviate/containers/Container.java index 81b450389..d2713f3a1 100644 --- a/src/it/java/io/weaviate/containers/Container.java +++ b/src/it/java/io/weaviate/containers/Container.java @@ -14,7 +14,7 @@ public class Container { public static final Weaviate WEAVIATE = Weaviate.createDefault(); - public static final Contextionary CONTEXTIONARY = Contextionary.createDefault(); + public static final Transformers TRANSFORMERS = Transformers.createDefault(); public static final Img2VecNeural IMG2VEC_NEURAL = Img2VecNeural.createDefault(); public static final MinIo MINIO = MinIo.createDefault(); diff --git a/src/it/java/io/weaviate/containers/Contextionary.java b/src/it/java/io/weaviate/containers/Contextionary.java deleted file mode 100644 index 69abde7df..000000000 --- a/src/it/java/io/weaviate/containers/Contextionary.java +++ /dev/null @@ -1,46 +0,0 @@ -package io.weaviate.containers; - -import org.testcontainers.containers.GenericContainer; - -public class Contextionary extends GenericContainer { - public static final String VERSION = "en0.16.0-v1.2.1"; - public static final String DOCKER_IMAGE = "semitechnologies/contextionary"; - public static final String MODULE = "text2vec-contextionary"; - - public static final String HOST_NAME = "contextionary"; - public static final String URL = HOST_NAME + ":9999"; - - static Contextionary createDefault() { - return new Builder().build(); - } - - static Contextionary.Builder custom() { - return new Builder(); - } - - public static class Builder { - private String versionTag; - - public Builder() { - this.versionTag = VERSION; - } - - public Contextionary build() { - var container = new Contextionary(DOCKER_IMAGE + ":" + versionTag); - container - .withEnv("OCCURRENCE_WEIGHT_LINEAR_FACTOR", "true") - .withEnv("PERSISTENCE_DATA_PATH", "/var/lib/weaviate") - .withEnv("OCCURRENCE_WEIGHT_LINEAR_FACTOR", "0.75") - .withEnv("EXTENSIONS_STORAGE_MODE", "weaviate") - .withEnv("EXTENSIONS_STORAGE_ORIGIN", "http://weaviate:8080") - .withEnv("NEIGHBOR_OCCURRENCE_IGNORE_PERCENTILE", "5") - .withEnv("ENABLE_COMPOUND_SPLITTING", "'false'"); - container.withCreateContainerCmdModifier(cmd -> cmd.withHostName(HOST_NAME)); - return container; - } - } - - public Contextionary(String image) { - super(image); - } -} diff --git a/src/it/java/io/weaviate/containers/MinIo.java b/src/it/java/io/weaviate/containers/MinIo.java index 451d7ac9c..86d0d649a 100644 --- a/src/it/java/io/weaviate/containers/MinIo.java +++ b/src/it/java/io/weaviate/containers/MinIo.java @@ -7,6 +7,9 @@ public class MinIo extends MinIOContainer { public static final String ACCESS_KEY = "minioadmin"; public static final String SECRET_KEY = "minioadmin"; + public static final String HOST_NAME = "minio"; + public static final String URL = HOST_NAME + ":9000"; + static MinIo createDefault() { return new MinIo(); } diff --git a/src/it/java/io/weaviate/containers/Transformers.java b/src/it/java/io/weaviate/containers/Transformers.java new file mode 100644 index 000000000..ac6602fc2 --- /dev/null +++ b/src/it/java/io/weaviate/containers/Transformers.java @@ -0,0 +1,42 @@ +package io.weaviate.containers; + +import org.testcontainers.containers.GenericContainer; + +import io.weaviate.client6.v1.api.collections.VectorConfig; + +public class Transformers extends GenericContainer { + public static final String VERSION = "sentence-transformers-all-MiniLM-L6-v2"; + public static final String DOCKER_IMAGE = "cr.weaviate.io/semitechnologies/transformers-inference"; + public static final String MODULE = VectorConfig.Kind.TEXT2VEC_TRANSFORMERS.jsonValue(); + + public static final String HOST_NAME = "transformers"; + public static final String URL = HOST_NAME + ":8080"; + + static Transformers createDefault() { + return new Builder().build(); + } + + static Transformers.Builder custom() { + return new Builder(); + } + + public static class Builder { + private String versionTag; + + public Builder() { + this.versionTag = VERSION; + } + + public Transformers build() { + var container = new Transformers(DOCKER_IMAGE + ":" + versionTag); + container + .withEnv("ENABLE_CUDA", "0"); + container.withCreateContainerCmdModifier(cmd -> cmd.withHostName(HOST_NAME)); + return container; + } + } + + public Transformers(String image) { + super(image); + } +} diff --git a/src/it/java/io/weaviate/containers/Weaviate.java b/src/it/java/io/weaviate/containers/Weaviate.java index a89714bd6..1bbf69876 100644 --- a/src/it/java/io/weaviate/containers/Weaviate.java +++ b/src/it/java/io/weaviate/containers/Weaviate.java @@ -112,9 +112,9 @@ public Builder withDefaultVectorizer(String module) { return this; } - public Builder withContextionaryUrl(String url) { - addModules(Contextionary.MODULE); - environment.put("CONTEXTIONARY_URL", url); + public Builder withTransformersUrl(String url) { + addModules(Transformers.MODULE); + environment.put("TRANSFORMERS_INFERENCE_API", "http://" + url); return this; } @@ -126,7 +126,7 @@ public Builder withImageInference(String url, String module) { public Builder withOffloadS3(String accessKey, String secretKey) { addModules("offload-s3"); - environment.put("OFFLOAD_S3_ENDPOINT", "http://minio:9000"); + environment.put("OFFLOAD_S3_ENDPOINT", "http://" + MinIo.URL); environment.put("OFFLOAD_S3_BUCKET_AUTO_CREATE", "true"); environment.put("AWS_ACCESS_KEY_ID", accessKey); environment.put("AWS_SECRET_KEY", secretKey); @@ -138,6 +138,7 @@ public Builder withFilesystemBackup(String fsPath) { environment.put("BACKUP_FILESYSTEM_PATH", fsPath); return this; } + public Builder withAdminUsers(String... admins) { adminUsers.addAll(Arrays.asList(admins)); return this; diff --git a/src/it/java/io/weaviate/integration/SearchITest.java b/src/it/java/io/weaviate/integration/SearchITest.java index 46a2ded83..f319f1688 100644 --- a/src/it/java/io/weaviate/integration/SearchITest.java +++ b/src/it/java/io/weaviate/integration/SearchITest.java @@ -41,19 +41,19 @@ import io.weaviate.client6.v1.api.collections.vectorindex.MultiVector; import io.weaviate.containers.Container; import io.weaviate.containers.Container.ContainerGroup; -import io.weaviate.containers.Contextionary; import io.weaviate.containers.Img2VecNeural; +import io.weaviate.containers.Transformers; import io.weaviate.containers.Weaviate; public class SearchITest extends ConcurrentTest { private static final ContainerGroup compose = Container.compose( Weaviate.custom() - .withContextionaryUrl(Contextionary.URL) + .withTransformersUrl(Transformers.URL) .withImageInference(Img2VecNeural.URL, Img2VecNeural.MODULE) .addModules("generative-dummy") .build(), Container.IMG2VEC_NEURAL, - Container.CONTEXTIONARY); + Container.TRANSFORMERS); @ClassRule // Bind containers to the lifetime of the test public static final TestRule _rule = compose.asTestRule(); private static final WeaviateClient client = compose.getClient(); @@ -151,7 +151,7 @@ public void testNearText() throws IOException { client.collections.create(nsSongs, col -> col .properties(Property.text("title")) - .vectorConfig(VectorConfig.text2vecContextionary())); + .vectorConfig(VectorConfig.text2VecTransformers())); var songs = client.collections.use(nsSongs); var submarine = songs.data.insert(Map.of("title", "Yellow Submarine")); @@ -160,7 +160,7 @@ public void testNearText() throws IOException { var result = songs.query.nearText("forest", opt -> opt - .distance(0.5f) + .distance(0.9f) .moveTo(.98f, to -> to.concepts("tropical")) .moveAway(.4f, away -> away.uuids(submarine.metadata().uuid())) .returnProperties("title")); @@ -173,7 +173,7 @@ public void testNearText() throws IOException { @Test public void testNearText_groupBy() throws IOException { - var vectorizer = VectorConfig.text2vecContextionary(); + var vectorizer = VectorConfig.text2VecTransformers(); var nsArtists = ns("Artists"); client.collections.create(nsArtists, @@ -370,7 +370,7 @@ public void testNearObject() throws IOException { client.collections.create(nsAnimals, collection -> collection .properties(Property.text("kind")) - .vectorConfig(VectorConfig.text2vecContextionary())); + .vectorConfig(VectorConfig.text2VecTransformers())); var animals = client.collections.use(nsAnimals); @@ -399,7 +399,7 @@ public void testHybrid() throws IOException { client.collections.create(nsHobbies, collection -> collection .properties(Property.text("name"), Property.text("description")) - .vectorConfig(VectorConfig.text2vecContextionary())); + .vectorConfig(VectorConfig.text2VecTransformers())); var hobbies = client.collections.use(nsHobbies); @@ -432,7 +432,7 @@ public void testBadRequest() throws IOException { client.collections.create(nsThings, collection -> collection .properties(Property.text("name")) - .vectorConfig(VectorConfig.text2vecContextionary())); + .vectorConfig(VectorConfig.text2VecTransformers())); var things = client.collections.use(nsThings); var balloon = things.data.insert(Map.of("name", "balloon")); @@ -449,7 +449,7 @@ public void testBadRequest_async() throws Throwable { async.collections.create(nsThings, collection -> collection .properties(Property.text("name")) - .vectorConfig(VectorConfig.text2vecContextionary())) + .vectorConfig(VectorConfig.text2VecTransformers())) .join(); var things = async.collections.use(nsThings); @@ -470,7 +470,7 @@ public void testMetadataAll() throws IOException { client.collections.create(nsThings, c -> c .properties(Property.text("name")) - .vectorConfig(VectorConfig.text2vecContextionary( + .vectorConfig(VectorConfig.text2VecTransformers( t2v -> t2v.sourceProperties("name")))); var things = client.collections.use(nsThings); @@ -563,7 +563,7 @@ public void testGenerative_bm25() throws IOException { c -> c .properties(Property.text("title")) .generativeModule(new DummyGenerative()) - .vectorConfig(VectorConfig.text2vecContextionary( + .vectorConfig(VectorConfig.text2VecTransformers( t2v -> t2v.sourceProperties("title")))); var things = client.collections.use(nsThings); @@ -604,7 +604,7 @@ public void testGenerative_bm25_groupBy() throws IOException { c -> c .properties(Property.text("title")) .generativeModule(new DummyGenerative()) - .vectorConfig(VectorConfig.text2vecContextionary( + .vectorConfig(VectorConfig.text2VecTransformers( t2v -> t2v.sourceProperties("title")))); var things = client.collections.use(nsThings); diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/Generative.java b/src/main/java/io/weaviate/client6/v1/api/collections/Generative.java index da7818c75..ef8ccc930 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/Generative.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/Generative.java @@ -94,27 +94,47 @@ public static Generative anyscale(Function> fn) { + return AwsGenerative.bedrock(region, model, fn); + } + + /** + * Configure a default {@code generative-aws} module with Sagemaker integration. * * @param region AWS region. - * @param service AWS service to use, e.g. {@code "bedrock"} or - * {@code "sagemaker"}. + * @param baseUrl Base inference URL. */ - public static Generative aws(String region, String service) { - return AwsGenerative.of(region, service); + public static Generative awsSagemaker(String region, String baseUrl) { + return AwsGenerative.sagemaker(region, baseUrl); } /** - * Configure a {@code generative-aws} module. + * Configure a {@code generative-aws} module with Sagemaker integration. * * @param region AWS region. - * @param service AWS service to use, e.g. {@code "bedrock"} or - * {@code "sagemaker"}. + * @param baseUrl Base inference URL. * @param fn Lambda expression for optional parameters. */ - public static Generative aws(String region, String service, - Function> fn) { - return AwsGenerative.of(region, service, fn); + public static Generative awsSagemaker(String region, String baseUrl, + Function> fn) { + return AwsGenerative.sagemaker(region, baseUrl, fn); } /** Configure a default {@code generative-cohere} module. */ 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 ae13f70ce..b1cef96e5 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 @@ -16,188 +16,1192 @@ import com.google.gson.stream.JsonWriter; import io.weaviate.client6.v1.api.collections.vectorizers.Img2VecNeuralVectorizer; +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.Multi2VecBindVectorizer; import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecClipVectorizer; +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.Ref2VecCentroidVectorizer; import io.weaviate.client6.v1.api.collections.vectorizers.SelfProvidedVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecContextionaryVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2MultiVecJinaAiVectorizer; +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.Text2VecCohereVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecDatabricksVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecGoogleAiStudioVectorizer; +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 io.weaviate.client6.v1.api.collections.vectorizers.Text2VecWeaviateVectorizer; import io.weaviate.client6.v1.internal.ObjectBuilder; +import io.weaviate.client6.v1.internal.TaggedUnion; import io.weaviate.client6.v1.internal.json.JsonEnum; -public interface VectorConfig { +public interface VectorConfig extends TaggedUnion { public enum Kind implements JsonEnum { NONE("none"), - IMG2VEC_NEURAL("img2vec-neural"), - TEXT2VEC_CONTEXTIONARY("text2vec-contextionary"), + TEXT2VEC_AWS("text2vec-aws"), + TEXT2VEC_COHERE("text2vec-cohere"), + TEXT2VEC_DATABRICKS("text2vec-databricks"), + TEXT2VEC_GOOGLE("text2vec-google"), + TEXT2VEC_GOOGLEAISTUDIO("text2vec-google"), + TEXT2VEC_HUGGINGFACE("text2vec-huggingface"), + REF2VEC_CENTROID("text2vec-huggingface"), + TEXT2VEC_JINAAI("text2vec-jinaai"), + TEXT2VEC_MISTRAL("text2vec-mistral"), + TEXT2VEC_MORPH("text2vec-morph"), + TEXT2VEC_MODEL2VEC("text2vec-model2vec"), + TEXT2VEC_NVIDIA("text2vec-nvidia"), + TEXT2VEC_OPENAI("text2vec-openai"), + TEXT2VEC_AZURE_OPENAI("text2vec-openai"), + TEXT2VEC_OLLAMA("text2vec-ollama"), + TEXT2VEC_TRANSFORMERS("text2vec-transformers"), + TEXT2VEC_VOYAGEAI("text2vec-voyageai"), TEXT2VEC_WEAVIATE("text2vec-weaviate"), - MULTI2VEC_CLIP("multi2vec-clip"); + IMG2VEC_NEURAL("img2vec-neural"), + MULTI2VEC_AWS("multi2vec-aws"), + MULTI2VEC_BIND("multi2vec-bind"), + MULTI2VEC_CLIP("multi2vec-clip"), + MULTI2VEC_GOOGLE("multi2vec-google"), + MULTI2VEC_COHERE("multi2vec-cohere"), + MULTI2VEC_JINAAI("multi2vec-jinaai"), + MULTI2VEC_NVIDIA("multi2vec-nvidia"), + MULTI2VEC_VOYAGEAI("multi2vec-voyageai"), + TEXT2MULTIVEC_JINAAI("text2multivec-jinaai"), + MULTI2MULTIVEC_JINAAI("multi2multivec-jinaai"); + + private static final Map jsonValueMap = JsonEnum.collectNames(Kind.values()); + private final String jsonValue; + + private Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + @Override + public String jsonValue() { + return this.jsonValue; + } + + public static Kind valueOfJson(String jsonValue) { + return JsonEnum.valueOfJson(jsonValue, jsonValueMap, Kind.class); + } + } + + /** Get vector index configuration for this vector. */ + VectorIndex vectorIndex(); + + /** Get quantization configuration for this vector. */ + Quantization quantization(); + + /** Create a bring-your-own-vector vector index. */ + public static Map.Entry selfProvided() { + return selfProvided(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a bring-your-own-vector vector index. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry selfProvided( + Function> fn) { + return selfProvided(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named bring-your-own-vector vector index. + * + * @param vectorName Vector name. + */ + public static Map.Entry selfProvided(String vectorName) { + return Map.entry(vectorName, SelfProvidedVectorizer.of()); + } + + /** + * Create a named bring-your-own-vector vector index. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry selfProvided(String vectorName, + Function> fn) { + return Map.entry(vectorName, SelfProvidedVectorizer.of(fn)); + } + + /** Create a vector index with an {@code img2vec-neural} vectorizer. */ + public static Map.Entry img2vecNeural() { + return img2vecNeural(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code img2vec-neural} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry img2vecNeural( + Function> fn) { + return img2vecNeural(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code img2vec-neural} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry img2vecNeural(String vectorName) { + return Map.entry(vectorName, Img2VecNeuralVectorizer.of()); + } + + /** + * Create a vector index with an {@code img2vec-neural} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry img2vecNeural(String vectorName, + Function> fn) { + return Map.entry(vectorName, Img2VecNeuralVectorizer.of(fn)); + } + + /** Create a vector index with an {@code multi2multivec-jinaai} vectorizer. */ + public static Map.Entry multi2multivecJinaai() { + return multi2multivecJinaai(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code multi2multivec-jinaai} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2multivecJinaai( + Function> fn) { + return multi2multivecJinaai(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code multi2multivec-jinaai} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry multi2multivecJinaai(String vectorName) { + return Map.entry(vectorName, Multi2MultiVecJinaAiVectorizer.of()); + } + + /** + * Create a named vector index with an {@code multi2multivec-jinaai} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2multivecJinaai(String vectorName, + Function> fn) { + return Map.entry(vectorName, Multi2MultiVecJinaAiVectorizer.of(fn)); + } + + /** Create a vector index with an {@code multi2vec-aws} vectorizer. */ + public static Map.Entry multi2vecAws() { + return multi2vecAws(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code multi2vec-aws} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecAws( + Function> fn) { + return multi2vecAws(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code multi2vec-aws} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry multi2vecAws(String vectorName) { + return Map.entry(vectorName, Multi2VecAwsVectorizer.of()); + } + + /** + * Create a named vector index with an {@code multi2vec-aws} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecAws(String vectorName, + Function> fn) { + return Map.entry(vectorName, Multi2VecAwsVectorizer.of(fn)); + } + + /** Create a vector index with an {@code multi2vec-bind} vectorizer. */ + public static Map.Entry multi2vecBind() { + return multi2vecBind(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code multi2vec-bind} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecBind( + Function> fn) { + return multi2vecBind(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code multi2vec-bind} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry multi2vecBind(String vectorName) { + return Map.entry(vectorName, Multi2VecBindVectorizer.of()); + } + + /** + * Create a named vector index with an {@code multi2vec-bind} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecBind(String vectorName, + Function> fn) { + return Map.entry(vectorName, Multi2VecBindVectorizer.of(fn)); + } + + /** Create a vector index with an {@code multi2vec-clip} vectorizer. */ + public static Map.Entry multi2vecClip() { + return multi2vecClip(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code multi2vec-clip} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecClip( + Function> fn) { + return multi2vecClip(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code multi2vec-clip} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry multi2vecClip(String vectorName) { + return Map.entry(vectorName, Multi2VecClipVectorizer.of()); + } + + /** + * Create a named vector index with an {@code multi2vec-clip} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecClip(String vectorName, + Function> fn) { + return Map.entry(vectorName, Multi2VecClipVectorizer.of(fn)); + } + + /** Create a vector index with an {@code multi2vec-cohere} vectorizer. */ + public static Map.Entry multi2vecCohere() { + return multi2vecBind(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code multi2vec-cohere} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecCohere( + Function> fn) { + return multi2vecCohere(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code multi2vec-cohere} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry multi2vecCohere(String vectorName) { + return Map.entry(vectorName, Multi2VecCohereVectorizer.of()); + } + + /** + * Create a named vector index with an {@code multi2vec-cohere} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecCohere(String vectorName, + Function> fn) { + return Map.entry(vectorName, Multi2VecCohereVectorizer.of(fn)); + } + + /** + * Create a vector index with an {@code multi2vec-google} vectorizer. + * + * @param location Geographic region the Google Cloud model runs in. + */ + public static Map.Entry multi2vecGoogle(String location) { + return multi2vecGoogle(VectorIndex.DEFAULT_VECTOR_NAME, location); + } + + /** + * 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 multi2vecGoogle( + String location, + Function> fn) { + return multi2vecGoogle(VectorIndex.DEFAULT_VECTOR_NAME, 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. + */ + public static Map.Entry multi2vecGoogle(String vectorName, String location) { + return Map.entry(vectorName, Multi2VecGoogleVectorizer.of(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. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecGoogle(String vectorName, + String location, + Function> fn) { + return Map.entry(vectorName, Multi2VecGoogleVectorizer.of(location, fn)); + } + + /** Create a vector index with an {@code multi2vec-jinaai} vectorizer. */ + public static Map.Entry multi2vecJinaAi() { + return multi2vecJinaAi(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code multi2vec-jinaai} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecJinaAi( + Function> fn) { + return multi2vecJinaAi(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code multi2vec-jinaai} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry multi2vecJinaAi(String vectorName) { + return Map.entry(vectorName, Multi2VecJinaAiVectorizer.of()); + } + + /** + * Create a named vector index with an {@code multi2vec-jinaai} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecJinaAi(String vectorName, + Function> fn) { + return Map.entry(vectorName, Multi2VecJinaAiVectorizer.of(fn)); + } + + /** Create a vector index with an {@code multi2vec-nvidia} vectorizer. */ + public static Map.Entry multi2vecNvidia() { + return multi2vecNvidia(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code multi2vec-nvidia} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecNvidia( + Function> fn) { + return multi2vecNvidia(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code multi2vec-nvidia} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry multi2vecNvidia(String vectorName) { + return Map.entry(vectorName, Multi2VecNvidiaVectorizer.of()); + } + + /** + * Create a named vector index with an {@code multi2vec-nvidia} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecNvidia(String vectorName, + Function> fn) { + return Map.entry(vectorName, Multi2VecNvidiaVectorizer.of(fn)); + } + + /** Create a vector index with an {@code multi2vec-voyageai} vectorizer. */ + public static Map.Entry multi2vecVoyageAi() { + return multi2vecVoyageAi(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code multi2vec-voyageai} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecVoyageAi( + Function> fn) { + return multi2vecVoyageAi(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code multi2vec-voyageai} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry multi2vecVoyageAi(String vectorName) { + return Map.entry(vectorName, Multi2VecVoyageAiVectorizer.of()); + } + + /** + * Create a named vector index with an {@code multi2vec-voyageai} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry multi2vecVoyageAi(String vectorName, + Function> fn) { + return Map.entry(vectorName, Multi2VecVoyageAiVectorizer.of(fn)); + } + + /** Create a vector index with an {@code ref2vec-centroid} vectorizer. */ + public static Map.Entry ref2vecCentroid() { + return ref2vecCentroid(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code ref2vec-centroid} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry ref2vecCentroid( + Function> fn) { + return ref2vecCentroid(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code ref2vec-centroid} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry ref2vecCentroid(String vectorName) { + return Map.entry(vectorName, Ref2VecCentroidVectorizer.of()); + } + + /** + * Create a named vector index with an {@code ref2vec-centroid} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry ref2vecCentroid(String vectorName, + Function> fn) { + return Map.entry(vectorName, Ref2VecCentroidVectorizer.of(fn)); + } + + /** Create a vector index with an {@code text2multivec-jinaai} vectorizer. */ + public static Map.Entry text2multivecJinaAi() { + return text2multivecJinaAi(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code text2multivec-jinaai} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2multivecJinaAi( + Function> fn) { + return text2multivecJinaAi(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code text2multivec-jinaai} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2multivecJinaAi(String vectorName) { + return Map.entry(vectorName, Text2MultiVecJinaAiVectorizer.of()); + } + + /** + * Create a named vector index with an {@code text2multivec-jinaai} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2multivecJinaAi(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2MultiVecJinaAiVectorizer.of(fn)); + } + + /** + * Create a vector index with an {@code text2vec-aws} vectorizer with Bedrock + * integration. + * + * @param model Inference model. + */ + public static Map.Entry text2vecAwsBedrock(String model) { + return text2vecAwsBedrock(VectorIndex.DEFAULT_VECTOR_NAME, model); + } + + /** + * Create a vector index with an {@code text2vec-aws} vectorizer with Bedrock + * integration. + * + * @param model Inference model. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2vecAwsBedrock( + String model, + Function> fn) { + return text2vecAwsBedrock(VectorIndex.DEFAULT_VECTOR_NAME, model, fn); + } + + /** + * Create a named vector index with an {@code text2vec-aws} + * vectorizer with Bedrock integration. + * + * @param vectorName Vector name. + * @param model Inference model. + */ + public static Map.Entry text2vecAwsBedrock(String vectorName, String model) { + return Map.entry(vectorName, Text2VecAwsVectorizer.bedrock(model)); + } + + /** + * Create a named vector index with an {@code text2vec-aws} + * vectorizer with Bedrock integration. + * + * @param vectorName Vector name. + * @param model Inference model. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2vecAwsBedrock(String vectorName, + String model, + Function> fn) { + return Map.entry(vectorName, Text2VecAwsVectorizer.bedrock(model, fn)); + } + + /** + * Create a vector index with an {@code text2vec-aws} vectorizer with Sagemaker + * integration. + * + * @param baseUrl Base URL of the inference service. + */ + public static Map.Entry text2vecAwsSagemaker(String baseUrl) { + return text2vecAwsSagemaker(VectorIndex.DEFAULT_VECTOR_NAME, baseUrl); + } + + /** + * Create a vector index with an {@code text2vec-aws} vectorizer with Sagemaker + * integration. + * + * @param baseUrl Base URL of the inference service. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2vecAwsSagemaker( + String baseUrl, + Function> fn) { + return text2vecAwsSagemaker(VectorIndex.DEFAULT_VECTOR_NAME, baseUrl, fn); + } + + /** + * Create a named vector index with an {@code text2vec-aws} + * vectorizer with Sagemaker integration. + * + * @param vectorName Vector name. + * @param baseUrl Base URL of the inference service. + */ + public static Map.Entry text2vecAwsSagemaker(String vectorName, String baseUrl) { + return Map.entry(vectorName, Text2VecAwsVectorizer.sagemaker(baseUrl)); + } + + /** + * Create a named vector index with an {@code text2vec-aws} + * vectorizer with Sagemaker integration. + * + * @param vectorName Vector name. + * @param baseUrl Base URL of the inference service. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2vecAwsSagemaker(String vectorName, + String baseUrl, + Function> fn) { + return Map.entry(vectorName, Text2VecAwsVectorizer.sagemaker(baseUrl, fn)); + } + + /** + * Create a vector index with an {@code text2vec-openai} vectorizer deployed on + * Azure. + */ + public static Map.Entry text2VecAzureOpenAi() { + return text2VecAzureOpenAi(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code text2vec-openai} vectorizer deployed on + * Azure. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecAzureOpenAi( + Function> fn) { + return text2VecAzureOpenAi(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code text2vec-openai} vectorizer + * deployed on Azure. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2VecAzureOpenAi(String vectorName) { + return Map.entry(vectorName, Text2VecAzureOpenAiVectorizer.of()); + } + + /** + * Create a named vector index with an {@code text2vec-openai} vectorizer + * deployed on Azure. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecAzureOpenAi(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecAzureOpenAiVectorizer.of(fn)); + } + + /** Create a vector index with an {@code text2vec-cohere} vectorizer. */ + public static Map.Entry text2vecCohere() { + return text2vecCohere(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code text2vec-cohere} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2vecCohere( + Function> fn) { + return text2vecCohere(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code text2vec-cohere} + * vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2vecCohere(String vectorName) { + return Map.entry(vectorName, Text2VecCohereVectorizer.of()); + } + + /** + * Create a named vector index with an {@code text2vec-cohere} + * vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2vecCohere(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecCohereVectorizer.of(fn)); + } + + /** Create a vector index with an {@code text2vec-databricks} vectorizer. */ + public static Map.Entry text2VecDatabricks() { + return text2VecDatabricks(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code text2vec-databricks} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecDatabricks( + Function> fn) { + return text2VecDatabricks(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code text2vec-databricks} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2VecDatabricks(String vectorName) { + return Map.entry(vectorName, Text2VecDatabricksVectorizer.of()); + } + + /** + * Create a named vector index with an {@code text2vec-databricks} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecDatabricks(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecDatabricksVectorizer.of(fn)); + } + + /** + * Create a vector index with an {@code text2vec-google} vectorizer with Google + * AI Studio integration. + */ + public static Map.Entry text2VecGoogleAiStudio() { + return text2VecGoogleAiStudio(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code text2vec-google} vectorizer with Google + * AI Studio integration. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecGoogleAiStudio( + Function> fn) { + return text2VecGoogleAiStudio(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code text2vec-google} vectorizer with + * Google AI Studio integration. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2VecGoogleAiStudio(String vectorName) { + return Map.entry(vectorName, Text2VecGoogleAiStudioVectorizer.of()); + } + + /** + * Create a named vector index with an {@code text2vec-google} vectorizer with + * Google AI Studio integration. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecGoogleAiStudio(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecGoogleAiStudioVectorizer.of(fn)); + } + + /** Create a vector index with an {@code text2vec-google} vectorizer. */ + public static Map.Entry text2VecGoogle() { + return text2VecGoogle(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code text2vec-google} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecGoogle( + Function> fn) { + return text2VecGoogle(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code text2vec-google} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2VecGoogle(String vectorName) { + return Map.entry(vectorName, Text2VecGoogleVectorizer.of()); + } + + /** + * Create a named vector index with an {@code text2vec-google} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecGoogle(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecGoogleVectorizer.of(fn)); + } + + /** Create a vector index with an {@code text2vec-huggingface} vectorizer. */ + public static Map.Entry text2VecHuggingFace() { + return text2VecHuggingFace(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code text2vec-huggingface} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecHuggingFace( + Function> fn) { + return text2VecHuggingFace(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code text2vec-huggingface} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2VecHuggingFace(String vectorName) { + return Map.entry(vectorName, Text2VecHuggingFaceVectorizer.of()); + } + + /** + * Create a named vector index with an {@code text2vec-huggingface} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecHuggingFace(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecHuggingFaceVectorizer.of(fn)); + } + + /** Create a vector index with an {@code text2vec-jinaai} vectorizer. */ + public static Map.Entry text2VecJinaAi() { + return text2VecJinaAi(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code text2vec-jinaai} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecJinaAi( + Function> fn) { + return text2VecJinaAi(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code text2vec-jinaai} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2VecJinaAi(String vectorName) { + return Map.entry(vectorName, Text2VecJinaAiVectorizer.of()); + } + + /** + * Create a named vector index with an {@code text2vec-jinaai} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecJinaAi(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecJinaAiVectorizer.of(fn)); + } + + /** Create a vector index with an {@code text2vec-mistral} vectorizer. */ + public static Map.Entry text2VecMistral() { + return text2VecMistral(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code text2vec-mistral} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecMistral( + Function> fn) { + return text2VecMistral(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } - private static final Map jsonValueMap = JsonEnum.collectNames(Kind.values()); - private final String jsonValue; + /** + * Create a named vector index with an {@code text2vec-mistral} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2VecMistral(String vectorName) { + return Map.entry(vectorName, Text2VecMistralVectorizer.of()); + } - private Kind(String jsonValue) { - this.jsonValue = jsonValue; - } + /** + * Create a named vector index with an {@code text2vec-mistral} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecMistral(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecMistralVectorizer.of(fn)); + } - @Override - public String jsonValue() { - return this.jsonValue; - } + /** Create a vector index with an {@code text2vec-model2vec} vectorizer. */ + public static Map.Entry text2VecModel2Vec() { + return text2VecModel2Vec(VectorIndex.DEFAULT_VECTOR_NAME); + } - public static Kind valueOfJson(String jsonValue) { - return JsonEnum.valueOfJson(jsonValue, jsonValueMap, Kind.class); - } + /** + * Create a vector index with an {@code text2vec-model2vec} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecModel2Vec( + Function> fn) { + return text2VecModel2Vec(VectorIndex.DEFAULT_VECTOR_NAME, fn); } - Kind _kind(); + /** + * Create a named vector index with an {@code text2vec-model2vec} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2VecModel2Vec(String vectorName) { + return Map.entry(vectorName, Text2VecModel2VecVectorizer.of()); + } - Object _self(); + /** + * Create a named vector index with an {@code text2vec-model2vec} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecModel2Vec(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecModel2VecVectorizer.of(fn)); + } - /** Get vector index configuration for this vector. */ - VectorIndex vectorIndex(); + /** Create a vector index with an {@code text2vec-morph} vectorizer. */ + public static Map.Entry text2VecMorph() { + return text2VecMorph(VectorIndex.DEFAULT_VECTOR_NAME); + } - /** Get quantization configuration for this vector. */ - Quantization quantization(); + /** + * Create a vector index with an {@code text2vec-morph} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecMorph( + Function> fn) { + return text2VecMorph(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } - /** Create a bring-your-own-vector vector index. */ - public static Map.Entry selfProvided() { - return selfProvided(VectorIndex.DEFAULT_VECTOR_NAME); + /** + * Create a named vector index with an {@code text2vec-morph} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2VecMorph(String vectorName) { + return Map.entry(vectorName, Text2VecMorphVectorizer.of()); } /** - * Create a bring-your-own-vector vector index. + * Create a named vector index with an {@code text2vec-morph} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecMorph(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecMorphVectorizer.of(fn)); + } + + /** Create a vector index with an {@code text2vec-nvidia} vectorizer. */ + public static Map.Entry text2VecNvidia() { + return text2VecNvidia(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code text2vec-nvidia} vectorizer. * * @param fn Lambda expression for optional parameters. */ - public static Map.Entry selfProvided( - Function> fn) { - return selfProvided(VectorIndex.DEFAULT_VECTOR_NAME, fn); + public static Map.Entry text2VecNvidia( + Function> fn) { + return text2VecNvidia(VectorIndex.DEFAULT_VECTOR_NAME, fn); } /** - * Create a named bring-your-own-vector vector index. + * Create a named vector index with an {@code text2vec-nvidia} vectorizer. * * @param vectorName Vector name. */ - public static Map.Entry selfProvided(String vectorName) { - return Map.entry(vectorName, SelfProvidedVectorizer.of()); + public static Map.Entry text2VecNvidia(String vectorName) { + return Map.entry(vectorName, Text2VecNvidiaVectorizer.of()); } /** - * Create a named bring-your-own-vector vector index. + * Create a named vector index with an {@code text2vec-nvidia} vectorizer. * * @param vectorName Vector name. * @param fn Lambda expression for optional parameters. */ - public static Map.Entry selfProvided(String vectorName, - Function> fn) { - return Map.entry(vectorName, SelfProvidedVectorizer.of(fn)); + public static Map.Entry text2VecNvidia(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecNvidiaVectorizer.of(fn)); } - /** Create a vector index with an {@code img2vec-neural} vectorizer. */ - public static Map.Entry img2vecNeural() { - return img2vecNeural(VectorIndex.DEFAULT_VECTOR_NAME); + /** Create a vector index with an {@code text2vec-ollama} vectorizer. */ + public static Map.Entry text2VecOllama() { + return text2VecOllama(VectorIndex.DEFAULT_VECTOR_NAME); } /** - * Create a vector index with an {@code img2vec-neural} vectorizer. + * Create a vector index with an {@code text2vec-ollama} vectorizer. * * @param fn Lambda expression for optional parameters. */ - public static Map.Entry img2vecNeural( - Function> fn) { - return img2vecNeural(VectorIndex.DEFAULT_VECTOR_NAME, fn); + public static Map.Entry text2VecOllama( + Function> fn) { + return text2VecOllama(VectorIndex.DEFAULT_VECTOR_NAME, fn); } /** - * Create a named vector index with an {@code img2vec-neural} vectorizer. + * Create a named vector index with an {@code text2vec-ollama} vectorizer. * * @param vectorName Vector name. */ - public static Map.Entry img2vecNeural(String vectorName) { - return Map.entry(vectorName, Img2VecNeuralVectorizer.of()); + public static Map.Entry text2VecOllama(String vectorName) { + return Map.entry(vectorName, Text2VecOllamaVectorizer.of()); } /** - * Create a vector index with an {@code img2vec-neural} vectorizer. + * Create a named vector index with an {@code text2vec-ollama} vectorizer. * * @param vectorName Vector name. * @param fn Lambda expression for optional parameters. */ - public static Map.Entry img2vecNeural(String vectorName, - Function> fn) { - return Map.entry(vectorName, Img2VecNeuralVectorizer.of(fn)); + public static Map.Entry text2VecOllama(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecOllamaVectorizer.of(fn)); } - /** Create a vector index with an {@code multi2vec-clip} vectorizer. */ - public static Map.Entry multi2vecClip() { - return multi2vecClip(VectorIndex.DEFAULT_VECTOR_NAME); + /** Create a vector index with an {@code text2vec-openai} vectorizer. */ + public static Map.Entry text2VecOpenAi() { + return text2VecOpenAi(VectorIndex.DEFAULT_VECTOR_NAME); } /** - * Create a vector index with an {@code multi2vec-clip} vectorizer. + * Create a vector index with an {@code text2vec-openai} vectorizer. * * @param fn Lambda expression for optional parameters. */ - public static Map.Entry multi2vecClip( - Function> fn) { - return multi2vecClip(VectorIndex.DEFAULT_VECTOR_NAME, fn); + public static Map.Entry text2VecOpenAi( + Function> fn) { + return text2VecOpenAi(VectorIndex.DEFAULT_VECTOR_NAME, fn); } /** - * Create a named vector index with an {@code multi2vec-clip} vectorizer. + * Create a named vector index with an {@code text2vec-openai} vectorizer. * * @param vectorName Vector name. */ - public static Map.Entry multi2vecClip(String vectorName) { - return Map.entry(vectorName, Multi2VecClipVectorizer.of()); + public static Map.Entry text2VecOpenAi(String vectorName) { + return Map.entry(vectorName, Text2VecOpenAiVectorizer.of()); } /** - * Create a named vector index with an {@code multi2vec-clip} vectorizer. + * Create a named vector index with an {@code text2vec-openai} vectorizer. * * @param vectorName Vector name. * @param fn Lambda expression for optional parameters. */ - public static Map.Entry multi2vecClip(String vectorName, - Function> fn) { - return Map.entry(vectorName, Multi2VecClipVectorizer.of(fn)); + public static Map.Entry text2VecOpenAi(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecOpenAiVectorizer.of(fn)); } - /** Create a vector index with an {@code text2vec-contextionary} vectorizer. */ - public static Map.Entry text2vecContextionary() { - return text2vecContextionary(VectorIndex.DEFAULT_VECTOR_NAME); + /** Create a vector index with an {@code text2vec-transformers} vectorizer. */ + public static Map.Entry text2VecTransformers() { + return text2VecTransformers(VectorIndex.DEFAULT_VECTOR_NAME); } /** - * Create a vector index with an {@code text2vec-contextionary} vectorizer. + * Create a vector index with an {@code text2vec-transformers} vectorizer. * * @param fn Lambda expression for optional parameters. */ - public static Map.Entry text2vecContextionary( - Function> fn) { - return text2vecContextionary(VectorIndex.DEFAULT_VECTOR_NAME, fn); + public static Map.Entry text2VecTransformers( + Function> fn) { + return text2VecTransformers(VectorIndex.DEFAULT_VECTOR_NAME, fn); } /** - * Create a named vector index with an {@code text2vec-contextionary} - * vectorizer. + * Create a named vector index with an {@code text2vec-transformers} vectorizer. * * @param vectorName Vector name. */ - public static Map.Entry text2vecContextionary(String vectorName) { - return Map.entry(vectorName, Text2VecContextionaryVectorizer.of()); + public static Map.Entry text2VecTransformers(String vectorName) { + return Map.entry(vectorName, Text2VecTransformersVectorizer.of()); } /** - * Create a named vector index with an {@code text2vec-contextionary} - * vectorizer. + * Create a named vector index with an {@code text2vec-transformers} vectorizer. + * + * @param vectorName Vector name. + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecTransformers(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecTransformersVectorizer.of(fn)); + } + + /** Create a vector index with an {@code text2vec-voyageai} vectorizer. */ + public static Map.Entry text2VecVoyageAi() { + return text2VecVoyageAi(VectorIndex.DEFAULT_VECTOR_NAME); + } + + /** + * Create a vector index with an {@code text2vec-voyageai} vectorizer. + * + * @param fn Lambda expression for optional parameters. + */ + public static Map.Entry text2VecVoyageAi( + Function> fn) { + return text2VecVoyageAi(VectorIndex.DEFAULT_VECTOR_NAME, fn); + } + + /** + * Create a named vector index with an {@code text2vec-voyageai} vectorizer. + * + * @param vectorName Vector name. + */ + public static Map.Entry text2VecVoyageAi(String vectorName) { + return Map.entry(vectorName, Text2VecVoyageAiVectorizer.of()); + } + + /** + * Create a named vector index with an {@code text2vec-voyageai} vectorizer. * * @param vectorName Vector name. * @param fn Lambda expression for optional parameters. */ - public static Map.Entry text2vecContextionary(String vectorName, - Function> fn) { - return Map.entry(vectorName, Text2VecContextionaryVectorizer.of(fn)); + public static Map.Entry text2VecVoyageAi(String vectorName, + Function> fn) { + return Map.entry(vectorName, Text2VecVoyageAiVectorizer.of(fn)); } /** Create a vector index with an {@code text2vec-weaviate} vectorizer. */ @@ -235,6 +1239,296 @@ public static Map.Entry text2VecWeaviate(String vectorName return Map.entry(vectorName, Text2VecWeaviateVectorizer.of(fn)); } + /** Is this an instance of {@link Img2VecNeuralVectorizer}? */ + default public boolean isImg2VecNeural() { + return _is(VectorConfig.Kind.IMG2VEC_NEURAL); + } + + /** Convert this instance to {@link Img2VecNeuralVectorizer}. */ + default public Img2VecNeuralVectorizer asImg2VecNeural() { + return _as(VectorConfig.Kind.IMG2VEC_NEURAL); + } + + /** Is this an instance of {@link Multi2MultiVecJinaAiVectorizer}? */ + default public boolean isMulti2MultiVecJinaAi() { + return _is(VectorConfig.Kind.MULTI2MULTIVEC_JINAAI); + } + + /** Convert this instance to {@link Multi2MultiVecJinaAiVectorizer}. */ + default public Multi2MultiVecJinaAiVectorizer asMulti2MultiVecJinaAi() { + return _as(VectorConfig.Kind.MULTI2MULTIVEC_JINAAI); + } + + /** Is this an instance of {@link Multi2VecAwsVectorizer}? */ + default public boolean isMulti2VecAws() { + return _is(VectorConfig.Kind.MULTI2VEC_AWS); + } + + /** Convert this instance to {@link Multi2VecAwsVectorizer}. */ + default public Multi2VecAwsVectorizer asMulti2VecAws() { + return _as(VectorConfig.Kind.MULTI2VEC_AWS); + } + + /** Is this an instance of {@link Multi2VecBindVectorizer}? */ + default public boolean isMulti2VecBind() { + return _is(VectorConfig.Kind.MULTI2VEC_BIND); + } + + /** Convert this instance to {@link Multi2VecBindVectorizer}. */ + default public Multi2VecBindVectorizer asMulti2VecBind() { + return _as(VectorConfig.Kind.MULTI2VEC_BIND); + } + + /** Is this an instance of {@link Multi2VecClipVectorizer}? */ + default public boolean isMulti2VecClip() { + return _is(VectorConfig.Kind.MULTI2VEC_CLIP); + } + + /** Convert this instance to {@link Multi2VecClipVectorizer}. */ + default public Multi2VecClipVectorizer asMulti2VecClip() { + return _as(VectorConfig.Kind.MULTI2VEC_CLIP); + } + + /** Is this an instance of {@link Multi2VecCohereVectorizer}? */ + default public boolean isMulti2VecCohere() { + return _is(VectorConfig.Kind.MULTI2VEC_COHERE); + } + + /** Convert this instance to {@link Multi2VecCohereVectorizer}. */ + default public Multi2VecCohereVectorizer asMulti2VecCohere() { + return _as(VectorConfig.Kind.MULTI2VEC_COHERE); + } + + /** Is this an instance of {@link Multi2VecGoogleVectorizer}? */ + default public boolean isMulti2VecGoogle() { + return _is(VectorConfig.Kind.MULTI2VEC_GOOGLE); + } + + /** Convert this instance to {@link Multi2VecGoogleVectorizer}. */ + default public Multi2VecGoogleVectorizer asMulti2VecGoogle() { + return _as(VectorConfig.Kind.MULTI2VEC_GOOGLE); + } + + /** Is this an instance of {@link Multi2VecJinaAiVectorizer}? */ + default public boolean isMulti2VecJinaAi() { + return _is(VectorConfig.Kind.MULTI2VEC_JINAAI); + } + + /** Convert this instance to {@link Multi2VecJinaAiVectorizer}. */ + default public Multi2VecJinaAiVectorizer asMulti2VecJinaAi() { + return _as(VectorConfig.Kind.MULTI2VEC_JINAAI); + } + + /** Is this an instance of {@link Multi2VecNvidiaVectorizer}? */ + default public boolean isMulti2VecNvidia() { + return _is(VectorConfig.Kind.MULTI2VEC_NVIDIA); + } + + /** Convert this instance to {@link Multi2VecNvidiaVectorizer}. */ + default public Multi2VecNvidiaVectorizer asMulti2VecNvidia() { + return _as(VectorConfig.Kind.MULTI2VEC_NVIDIA); + } + + /** Is this an instance of {@link Multi2VecVoyageAiVectorizer}? */ + default public boolean isMulti2VecVoyageAi() { + return _is(VectorConfig.Kind.MULTI2VEC_VOYAGEAI); + } + + /** Convert this instance to {@link Multi2VecVoyageAiVectorizer}. */ + default public Multi2VecVoyageAiVectorizer asMulti2VecVoyageAi() { + return _as(VectorConfig.Kind.MULTI2VEC_VOYAGEAI); + } + + /** Is this an instance of {@link Ref2VecCentroidVectorizer}? */ + default public boolean isRef2VecCentroid() { + return _is(VectorConfig.Kind.REF2VEC_CENTROID); + } + + /** Convert this instance to {@link Ref2VecCentroidVectorizer}. */ + default public Ref2VecCentroidVectorizer asRef2VecCentroid() { + return _as(VectorConfig.Kind.REF2VEC_CENTROID); + } + + /** Is this an instance of {@link Text2VecAwsVectorizer}? */ + default public boolean isText2VecAws() { + return _is(VectorConfig.Kind.TEXT2VEC_AWS); + } + + /** Convert this instance to {@link Text2VecAwsVectorizer}. */ + default public Text2VecAwsVectorizer asText2VecAws() { + return _as(VectorConfig.Kind.TEXT2VEC_AWS); + } + + /** Is this an instance of {@link Text2VecAzureOpenAiVectorizer}? */ + default public boolean isText2VecAzureOpenAi() { + return _is(VectorConfig.Kind.TEXT2VEC_AZURE_OPENAI); + } + + /** Convert this instance to {@link Text2VecAzureOpenAiVectorizer}. */ + default public Text2VecAzureOpenAiVectorizer asText2VecAzureOpenAi() { + return _as(VectorConfig.Kind.TEXT2VEC_AZURE_OPENAI); + } + + /** Is this an instance of {@link Text2VecCohereVectorizer}? */ + default public boolean isText2VecCohere() { + return _is(VectorConfig.Kind.TEXT2VEC_COHERE); + } + + /** Convert this instance to {@link Text2VecCohereVectorizer}. */ + default public Text2VecCohereVectorizer asText2VecCohere() { + return _as(VectorConfig.Kind.TEXT2VEC_COHERE); + } + + /** Is this an instance of {@link Text2VecDatabricksVectorizer}? */ + default public boolean isText2VecDatabricks() { + return _is(VectorConfig.Kind.TEXT2VEC_DATABRICKS); + } + + /** Convert this instance to {@link Text2VecDatabricksVectorizer}. */ + default public Text2VecDatabricksVectorizer asText2VecDatabricks() { + return _as(VectorConfig.Kind.TEXT2VEC_DATABRICKS); + } + + /** Is this an instance of {@link Text2VecGoogleAiStudioVectorizer}? */ + default public boolean isText2VecGoogleAiStudio() { + return _is(VectorConfig.Kind.TEXT2VEC_GOOGLEAISTUDIO); + } + + /** Convert this instance to {@link Text2VecGoogleAiStudioVectorizer}. */ + default public Text2VecGoogleAiStudioVectorizer asText2VecGoogleAiStudio() { + return _as(VectorConfig.Kind.TEXT2VEC_GOOGLEAISTUDIO); + } + + /** Is this an instance of {@link Text2VecGoogleVectorizer}? */ + default public boolean isText2VecGoogle() { + return _is(VectorConfig.Kind.TEXT2VEC_GOOGLE); + } + + /** Convert this instance to {@link Text2VecGoogleVectorizer}. */ + default public Text2VecGoogleVectorizer asText2VecGoogle() { + return _as(VectorConfig.Kind.TEXT2VEC_GOOGLE); + } + + /** Is this an instance of {@link Text2VecHuggingFaceVectorizer}? */ + default public boolean isText2VecHuggingFace() { + return _is(VectorConfig.Kind.TEXT2VEC_HUGGINGFACE); + } + + /** Convert this instance to {@link Text2VecHuggingFaceVectorizer}. */ + default public Text2VecHuggingFaceVectorizer asText2VecHuggingFace() { + return _as(VectorConfig.Kind.TEXT2VEC_HUGGINGFACE); + } + + /** Is this an instance of {@link Text2MultiVecJinaAiVectorizer}? */ + default public boolean isText2MultiVecJinaAi() { + return _is(VectorConfig.Kind.TEXT2MULTIVEC_JINAAI); + } + + /** Convert this instance to {@link Text2MultiVecJinaAiVectorizer}. */ + default public Text2MultiVecJinaAiVectorizer asText2MultiVecJinaAi() { + return _as(VectorConfig.Kind.TEXT2MULTIVEC_JINAAI); + } + + /** Is this an instance of {@link Text2VecJinaAiVectorizer}? */ + default public boolean isText2VecJinaAi() { + return _is(VectorConfig.Kind.TEXT2VEC_JINAAI); + } + + /** Convert this instance to {@link Text2VecJinaAiVectorizer}. */ + default public Text2VecJinaAiVectorizer asText2VecJinaAi() { + return _as(VectorConfig.Kind.TEXT2VEC_JINAAI); + } + + /** Is this an instance of {@link Text2VecMistralVectorizer}? */ + default public boolean isText2VecMistral() { + return _is(VectorConfig.Kind.TEXT2VEC_MISTRAL); + } + + /** Convert this instance to {@link Text2VecMistralVectorizer}. */ + default public Text2VecMistralVectorizer asText2VecMistral() { + return _as(VectorConfig.Kind.TEXT2VEC_MISTRAL); + } + + /** Is this an instance of {@link Text2VecModel2VecVectorizer}? */ + default public boolean isText2VecModel2Vec() { + return _is(VectorConfig.Kind.TEXT2VEC_MODEL2VEC); + } + + /** Convert this instance to {@link Text2VecModel2VecVectorizer}. */ + default public Text2VecModel2VecVectorizer asText2VecModel2Vec() { + return _as(VectorConfig.Kind.TEXT2VEC_MODEL2VEC); + } + + /** Is this an instance of {@link Text2VecMorphVectorizer}? */ + default public boolean isText2VecMorph() { + return _is(VectorConfig.Kind.TEXT2VEC_MORPH); + } + + /** Convert this instance to {@link Text2VecMorphVectorizer}. */ + default public Text2VecMorphVectorizer asText2VecMorph() { + return _as(VectorConfig.Kind.TEXT2VEC_MORPH); + } + + /** Is this an instance of {@link Text2VecNvidiaVectorizer}? */ + default public boolean isText2VecNvidia() { + return _is(VectorConfig.Kind.TEXT2VEC_NVIDIA); + } + + /** Convert this instance to {@link Text2VecNvidiaVectorizer}. */ + default public Text2VecNvidiaVectorizer asText2VecNvidia() { + return _as(VectorConfig.Kind.TEXT2VEC_NVIDIA); + } + + /** Is this an instance of {@link Text2VecOllamaVectorizer}? */ + default public boolean isText2VecOllama() { + return _is(VectorConfig.Kind.TEXT2VEC_OLLAMA); + } + + /** Convert this instance to {@link Text2VecOllamaVectorizer}. */ + default public Text2VecOllamaVectorizer asText2VecOllama() { + return _as(VectorConfig.Kind.TEXT2VEC_OLLAMA); + } + + /** Is this an instance of {@link Text2VecOpenAiVectorizer}? */ + default public boolean isText2VecOpenAi() { + return _is(VectorConfig.Kind.TEXT2VEC_OPENAI); + } + + /** Convert this instance to {@link Text2VecOpenAiVectorizer}. */ + default public Text2VecOpenAiVectorizer asText2VecOpenAi() { + return _as(VectorConfig.Kind.TEXT2VEC_OPENAI); + } + + /** Is this an instance of {@link Text2VecTransformersVectorizer}? */ + default public boolean isText2VecTransformers() { + return _is(VectorConfig.Kind.TEXT2VEC_TRANSFORMERS); + } + + /** Convert this instance to {@link Text2VecTransformersVectorizer}. */ + default public Text2VecTransformersVectorizer asText2VecTransformers() { + return _as(VectorConfig.Kind.TEXT2VEC_TRANSFORMERS); + } + + /** Is this an instance of {@link Text2VecVoyageAiVectorizer}? */ + default public boolean isText2VecVoyageAi() { + return _is(VectorConfig.Kind.TEXT2VEC_VOYAGEAI); + } + + /** Convert this instance to {@link Text2VecVoyageAiVectorizer}. */ + default public Text2VecVoyageAiVectorizer asText2VecVoyageAi() { + return _as(VectorConfig.Kind.TEXT2VEC_VOYAGEAI); + } + + /** Is this an instance of {@link Text2VecWeaviateVectorizer}? */ + default public boolean isText2VecWeaviate() { + return _is(VectorConfig.Kind.TEXT2VEC_WEAVIATE); + } + + /** Convert this instance to {@link Text2VecWeaviateVectorizer}. */ + default public Text2VecWeaviateVectorizer asText2VecWeaviate() { + return _as(VectorConfig.Kind.TEXT2VEC_WEAVIATE); + } + public static enum CustomTypeAdapterFactory implements TypeAdapterFactory { INSTANCE; @@ -248,10 +1542,35 @@ private final void addAdapter(Gson gson, VectorConfig.Kind kind, Class> fn) { + return AwsGenerative.Provider.bedrock(region, model, fn); + } + + /** + * Configure {@code generative-aws} as a dynamic provider. + * + * @param region AWS region. + * @param baseUrl Base inference URL. + * @param fn Lambda expression for optional parameters. */ - public static DynamicProvider aws( - Function> fn) { - return AwsGenerative.Provider.of(fn); + public static DynamicProvider awsSagemaker( + String region, + String baseUrl, + Function> fn) { + return AwsGenerative.Provider.sagemaker(region, baseUrl, fn); } /** diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/generative/AwsGenerative.java b/src/main/java/io/weaviate/client6/v1/api/collections/generative/AwsGenerative.java index 1589b15db..d49e03900 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/generative/AwsGenerative.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/generative/AwsGenerative.java @@ -9,13 +9,14 @@ import io.weaviate.client6.v1.api.collections.Generative; import io.weaviate.client6.v1.api.collections.generate.DynamicProvider; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecAwsVectorizer.Service; import io.weaviate.client6.v1.internal.ObjectBuilder; import io.weaviate.client6.v1.internal.grpc.protocol.WeaviateProtoBase; import io.weaviate.client6.v1.internal.grpc.protocol.WeaviateProtoGenerative; public record AwsGenerative( @SerializedName("region") String region, - @SerializedName("service") String service, + @SerializedName("service") Service service, @SerializedName("endpoint") String baseUrl, @SerializedName("model") String model) implements Generative { @@ -29,27 +30,37 @@ public Object _self() { return this; } - public static AwsGenerative of(String region, String service) { - return of(region, service, ObjectBuilder.identity()); + public static AwsGenerative bedrock(String region, String model) { + return bedrock(region, model, ObjectBuilder.identity()); } - public static AwsGenerative of(String region, String service, Function> fn) { - return fn.apply(new Builder(region, service)).build(); + public static AwsGenerative bedrock(String region, String model, + Function> fn) { + return fn.apply(new BedrockBuilder(region, model)).build(); + } + + public static AwsGenerative sagemaker(String region, String baseUrl) { + return sagemaker(region, baseUrl, ObjectBuilder.identity()); + } + + public static AwsGenerative sagemaker(String region, String baseUrl, + Function> fn) { + return fn.apply(new SagemakerBuilder(region, baseUrl)).build(); } public AwsGenerative(Builder builder) { this( - builder.service, builder.region, + builder.service, builder.baseUrl, builder.model); } public static class Builder implements ObjectBuilder { private final String region; - private final String service; + private final Service service; - public Builder(String service, String region) { + public Builder(Service service, String region) { this.service = service; this.region = region; } @@ -58,13 +69,13 @@ public Builder(String service, String region) { private String model; /** Base URL of the generative provider. */ - public Builder baseUrl(String baseUrl) { + protected Builder baseUrl(String baseUrl) { this.baseUrl = baseUrl; return this; } /** Select generative model. */ - public Builder model(String model) { + protected Builder model(String model) { this.model = model; return this; } @@ -75,12 +86,37 @@ public AwsGenerative build() { } } + public static class BedrockBuilder extends Builder { + public BedrockBuilder(String region, String model) { + super(Service.BEDROCK, region); + super.model(model); + } + + @Override + /** Required for {@link Service#BEDROCK}. */ + public Builder model(String model) { + return super.model(model); + } + } + + public static class SagemakerBuilder extends Builder { + public SagemakerBuilder(String region, String baseUrl) { + super(Service.SAGEMAKER, region); + super.baseUrl(baseUrl); + } + + /** Required for {@link Service#SAGEMAKER}. */ + public Builder baseUrl(String baseUrl) { + return super.baseUrl(baseUrl); + } + } + public static record Metadata() implements ProviderMetadata { } public static record Provider( String region, - String service, + Service service, String baseUrl, String model, String targetModel, @@ -89,9 +125,18 @@ public static record Provider( List images, List imageProperties) implements DynamicProvider { - public static Provider of( - Function> fn) { - return fn.apply(new Builder()).build(); + public static Provider bedrock( + String region, + String model, + Function> fn) { + return fn.apply(new BedrockBuilder(region, model)).build(); + } + + public static Provider sagemaker( + String region, + String baseUrl, + Function> fn) { + return fn.apply(new SagemakerBuilder(region, baseUrl)).build(); } @Override @@ -102,7 +147,10 @@ public void appendTo( provider.setRegion(region); } if (service != null) { - provider.setService(service); + provider.setService( + service == Service.BEDROCK ? "bedrock" + : service == Service.SAGEMAKER ? "sagemaker" + : "unknown"); } if (baseUrl != null) { provider.setEndpoint(baseUrl); @@ -143,9 +191,9 @@ public Provider(Builder builder) { builder.imageProperties); } - public static class Builder implements ObjectBuilder { - private String region; - private String service; + public abstract static class Builder implements ObjectBuilder { + private final Service service; + private final String region; private String baseUrl; private String model; private String targetModel; @@ -154,24 +202,19 @@ public static class Builder implements ObjectBuilder { private final List images = new ArrayList<>(); private final List imageProperties = new ArrayList<>(); - public Builder region(String region) { - this.region = region; - return this; - } - - public Builder service(String service) { + protected Builder(Service service, String region) { this.service = service; - return this; + this.region = region; } /** Base URL of the generative provider. */ - public Builder baseUrl(String baseUrl) { + protected Builder baseUrl(String baseUrl) { this.baseUrl = baseUrl; return this; } /** Select generative model. */ - public Builder model(String model) { + protected Builder model(String model) { this.model = model; return this; } @@ -218,5 +261,30 @@ public AwsGenerative.Provider build() { return new AwsGenerative.Provider(this); } } + + public static class BedrockBuilder extends Builder { + public BedrockBuilder(String region, String model) { + super(Service.BEDROCK, region); + super.model(model); + } + + @Override + /** Required for {@link Service#BEDROCK}. */ + public Builder model(String model) { + return super.model(model); + } + } + + public static class SagemakerBuilder extends Builder { + public SagemakerBuilder(String region, String baseUrl) { + super(Service.SAGEMAKER, region); + super.baseUrl(baseUrl); + } + + /** Required for {@link Service#SAGEMAKER}. */ + public Builder baseUrl(String baseUrl) { + return super.baseUrl(baseUrl); + } + } } } 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 c5611ef19..12467d283 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 @@ -44,9 +44,10 @@ public Img2VecNeuralVectorizer(Builder builder) { public static class Builder implements ObjectBuilder { private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; - private List imageFields = new ArrayList<>(); private Quantization quantization; + private List imageFields = new ArrayList<>(); + /** Add BLOB properties to include in the embedding. */ public Builder imageFields(List fields) { this.imageFields = 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 new file mode 100644 index 000000000..a4daa8a78 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2MultiVecJinaAiVectorizer.java @@ -0,0 +1,102 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Multi2MultiVecJinaAiVectorizer( + /** BLOB properties included in the embedding. */ + @SerializedName("imageFields") List imageFields, + /** TEXT properties included in the embedding. */ + @SerializedName("textFields") List textFields, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.MULTI2MULTIVEC_JINAAI; + } + + @Override + public Object _self() { + return this; + } + + public static Multi2MultiVecJinaAiVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Multi2MultiVecJinaAiVectorizer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public Multi2MultiVecJinaAiVectorizer(Builder builder) { + this( + builder.imageFields, + builder.textFields, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + private Quantization quantization; + + private final List imageFields = new ArrayList<>(); + private final List textFields = new ArrayList<>(); + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(List fields) { + imageFields.addAll(fields); + return this; + } + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(String... fields) { + return imageFields(Arrays.asList(fields)); + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(List fields) { + textFields.addAll(fields); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(String... fields) { + return textFields(Arrays.asList(fields)); + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + @Override + public Multi2MultiVecJinaAiVectorizer build() { + return new Multi2MultiVecJinaAiVectorizer(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 new file mode 100644 index 000000000..ea39fe339 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecAwsVectorizer.java @@ -0,0 +1,168 @@ +package io.weaviate.client6.v1.api.collections.vectorizers; + +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; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Multi2VecAwsVectorizer( + @SerializedName("model") String model, + @SerializedName("dimensions") Integer dimensions, + @SerializedName("region") String region, + /** BLOB properties included in the embedding. */ + @SerializedName("imageFields") List imageFields, + /** TEXT properties included in the embedding. */ + @SerializedName("textFields") List textFields, + /** Weights of the included properties. */ + @SerializedName("weights") Weights weights, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + private static record Weights( + /** + * Weights of the BLOB properties. Values appear in the same order as the + * corresponding property names in {@code imageFields}. + */ + @SerializedName("imageWeights") List imageWeights, + /** + * Weights of the TEXT properties. Values appear in the same order as the + * corresponding property names in {@code textFields}. + */ + @SerializedName("textWeights") List textWeights) { + } + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.MULTI2VEC_AWS; + } + + @Override + public Object _self() { + return this; + } + + public static Multi2VecAwsVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Multi2VecAwsVectorizer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public Multi2VecAwsVectorizer(Builder builder) { + this( + 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.vectorIndex, + builder.quantization); + } + + 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 String model; + private Integer dimensions; + private String region; + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder dimensions(int dimensions) { + this.dimensions = dimensions; + return this; + } + + public Builder region(String region) { + this.region = region; + return this; + } + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(List fields) { + fields.forEach(field -> imageFields.put(field, null)); + return this; + } + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(String... fields) { + return imageFields(Arrays.asList(fields)); + } + + /** + * Add BLOB property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder imageField(String field, float weight) { + imageFields.put(field, weight); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(List fields) { + fields.forEach(field -> textFields.put(field, null)); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(String... fields) { + return textFields(Arrays.asList(fields)); + } + + /** + * Add TEXT property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder textField(String field, float weight) { + textFields.put(field, weight); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + @Override + public Multi2VecAwsVectorizer build() { + return new Multi2VecAwsVectorizer(this); + } + } +} diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecBindVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecBindVectorizer.java new file mode 100644 index 000000000..72b13b716 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecBindVectorizer.java @@ -0,0 +1,338 @@ +package io.weaviate.client6.v1.api.collections.vectorizers; + +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; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Multi2VecBindVectorizer( + /** BLOB image properties included in the embedding. */ + @SerializedName("imageFields") List imageFields, + /** BLOB audio properties included in the embedding. */ + @SerializedName("audioFields") List audioFields, + /** BLOB video properties included in the embedding. */ + @SerializedName("videoFields") List videoFields, + /** BLOB depth properties included in the embedding. */ + @SerializedName("depthFields") List depthFields, + /** BLOB thermal properties included in the embedding. */ + @SerializedName("thermalFields") List thermalFields, + /** BLOB IMU properties included in the embedding. */ + @SerializedName("imuFields") List imuFields, + /** TEXT properties included in the embedding. */ + @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. */ + Quantization quantization) implements VectorConfig { + + private static record Weights( + /** + * Weights of the BLOB image properties. Values appear in the same order as the + * corresponding property names in {@code imageFields}. + */ + @SerializedName("imageWeights") List imageWeights, + /** + * Weights of the BLOB audio properties. Values appear in the same order as the + * corresponding property names in {@code audioFields}. + */ + @SerializedName("audioWeights") List audioWeights, + /** + * Weights of the BLOB video properties. Values appear in the same order as the + * corresponding property names in {@code videoFields}. + */ + @SerializedName("videoWeights") List videoWeights, + /** + * Weights of the BLOB depth properties. Values appear in the same order as the + * corresponding property names in {@code depthFields}. + */ + @SerializedName("depthWeights") List depthWeights, + /** + * Weights of the BLOB thermal properties. Values appear in the same order as + * the + * corresponding property names in {@code thermalFields}. + */ + @SerializedName("thermalWeights") List thermalWeights, + /** + * Weights of the BLOB IMU properties. Values appear in the same order as the + * corresponding property names in {@code imuFields}. + */ + @SerializedName("imuWeights") List imuWeights, + /** + * Weights of the TEXT properties. Values appear in the same order as the + * corresponding property names in {@code textFields}. + */ + @SerializedName("textWeights") List textWeights) { + } + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.MULTI2VEC_BIND; + } + + @Override + public Object _self() { + return this; + } + + public static Multi2VecBindVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Multi2VecBindVectorizer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public Multi2VecBindVectorizer( + List imageFields, + List audioFields, + List videoFields, + List depthFields, + List thermalFields, + List imuFields, + List textFields, + Weights weights, + boolean vectorizeCollectionName, + VectorIndex vectorIndex, + Quantization quantization) { + this.vectorizeCollectionName = false; + + this.imageFields = imageFields; + this.audioFields = audioFields; + this.videoFields = videoFields; + this.depthFields = depthFields; + this.thermalFields = thermalFields; + this.imuFields = imuFields; + this.textFields = textFields; + this.weights = weights; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Multi2VecBindVectorizer(Builder builder) { + this( + builder.imageFields.keySet().stream().toList(), + builder.audioFields.keySet().stream().toList(), + builder.videoFields.keySet().stream().toList(), + builder.depthFields.keySet().stream().toList(), + builder.thermalFields.keySet().stream().toList(), + builder.imuFields.keySet().stream().toList(), + builder.textFields.keySet().stream().toList(), + new Weights( + builder.imageFields.values().stream().toList(), + builder.audioFields.values().stream().toList(), + builder.videoFields.values().stream().toList(), + builder.depthFields.values().stream().toList(), + builder.thermalFields.values().stream().toList(), + builder.imuFields.values().stream().toList(), + builder.textFields.values().stream().toList()), + builder.vectorizeCollectionName, + 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 audioFields = new LinkedHashMap<>(); + private Map videoFields = new LinkedHashMap<>(); + private Map depthFields = new LinkedHashMap<>(); + private Map thermalFields = new LinkedHashMap<>(); + private Map imuFields = new LinkedHashMap<>(); + private Map textFields = new LinkedHashMap<>(); + + /** Add BLOB image properties to include in the embedding. */ + public Builder imageFields(List fields) { + fields.forEach(field -> imageFields.put(field, null)); + return this; + } + + /** Add BLOB image properties to include in the embedding. */ + public Builder imageFields(String... fields) { + return imageFields(Arrays.asList(fields)); + } + + /** + * Add BLOB image property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder imageField(String field, float weight) { + imageFields.put(field, weight); + return this; + } + + /** Add BLOB audio properties to include in the embedding. */ + public Builder audioFields(List fields) { + fields.forEach(field -> audioFields.put(field, null)); + return this; + } + + /** Add BLOB audio properties to include in the embedding. */ + public Builder audioFields(String... fields) { + return audioFields(Arrays.asList(fields)); + } + + /** + * Add BLOB audio property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder audioField(String field, float weight) { + audioFields.put(field, weight); + return this; + } + + /** Add BLOB video properties to include in the embedding. */ + public Builder videoFields(List fields) { + fields.forEach(field -> videoFields.put(field, null)); + return this; + } + + /** Add BLOB video properties to include in the embedding. */ + public Builder videoFields(String... fields) { + return videoFields(Arrays.asList(fields)); + } + + /** + * Add BLOB video property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder videoField(String field, float weight) { + videoFields.put(field, weight); + return this; + } + + /** Add BLOB depth properties to include in the embedding. */ + public Builder depthFields(List fields) { + fields.forEach(field -> depthFields.put(field, null)); + return this; + } + + /** Add BLOB depth properties to include in the embedding. */ + public Builder depthFields(String... fields) { + return depthFields(Arrays.asList(fields)); + } + + /** + * Add BLOB depth property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder depthField(String field, float weight) { + depthFields.put(field, weight); + return this; + } + + /** Add BLOB thermal properties to include in the embedding. */ + public Builder thermalFields(List fields) { + fields.forEach(field -> thermalFields.put(field, null)); + return this; + } + + /** Add BLOB thermal properties to include in the embedding. */ + public Builder thermalFields(String... fields) { + return thermalFields(Arrays.asList(fields)); + } + + /** + * Add BLOB thermal property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder thermalField(String field, float weight) { + thermalFields.put(field, weight); + return this; + } + + /** Add BLOB IMU properties to include in the embedding. */ + public Builder imuFields(List fields) { + fields.forEach(field -> imuFields.put(field, null)); + return this; + } + + /** Add BLOB IMU properties to include in the embedding. */ + public Builder imuFields(String... fields) { + return imuFields(Arrays.asList(fields)); + } + + /** + * Add BLOB IMU property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder imuField(String field, float weight) { + imuFields.put(field, weight); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(List fields) { + fields.forEach(field -> textFields.put(field, null)); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(String... fields) { + return textFields(Arrays.asList(fields)); + } + + /** + * Add TEXT property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder textField(String field, float weight) { + textFields.put(field, weight); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + @Override + public Multi2VecBindVectorizer build() { + return new Multi2VecBindVectorizer(this); + } + } +} 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 07ccfb0ef..036f77a41 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,7 +1,7 @@ package io.weaviate.client6.v1.api.collections.vectorizers; import java.util.Arrays; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.Function; @@ -15,7 +15,7 @@ public record Multi2VecClipVectorizer( /** Base URL of the embedding service. */ - @SerializedName("inferenceUrl") String inferenceUrl, + @SerializedName("inferenceUrl") String baseUrl, /** BLOB properties included in the embedding. */ @SerializedName("imageFields") List imageFields, /** TEXT properties included in the embedding. */ @@ -60,7 +60,7 @@ public static Multi2VecClipVectorizer of(Function { private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private Quantization quantization; - private String inferenceUrl; - private Map imageFields = new HashMap<>(); - private Map textFields = new HashMap<>(); + + private Map imageFields = new LinkedHashMap<>(); + private Map textFields = new LinkedHashMap<>(); + + private String baseUrl; /** Set base URL of the embedding service. */ - public Builder inferenceUrl(String inferenceUrl) { - this.inferenceUrl = inferenceUrl; + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; return 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 new file mode 100644 index 000000000..c6e0baee7 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecCohereVectorizer.java @@ -0,0 +1,201 @@ +package io.weaviate.client6.v1.api.collections.vectorizers; + +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; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Multi2VecCohereVectorizer( + /** Base URL of the embedding service. */ + @SerializedName("baseURL") String baseUrl, + /** Inference model to use. */ + @SerializedName("model") String model, + /** The truncate strategy to use. */ + @SerializedName("truncate") String truncate, + /** BLOB properties included in the embedding. */ + @SerializedName("imageFields") List imageFields, + /** TEXT properties included in the embedding. */ + @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. */ + Quantization quantization) implements VectorConfig { + + private static record Weights( + /** + * Weights of the BLOB properties. Values appear in the same order as the + * corresponding property names in {@code imageFields}. + */ + @SerializedName("imageWeights") List imageWeights, + /** + * Weights of the TEXT properties. Values appear in the same order as the + * corresponding property names in {@code textFields}. + */ + @SerializedName("textWeights") List textWeights) { + } + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.MULTI2VEC_COHERE; + } + + @Override + public Object _self() { + return this; + } + + public static Multi2VecCohereVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Multi2VecCohereVectorizer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public Multi2VecCohereVectorizer( + String baseUrl, + String model, + String truncate, + List imageFields, + List textFields, + Weights weights, + boolean vectorizeCollectionName, + VectorIndex vectorIndex, + Quantization quantization) { + this.vectorizeCollectionName = false; + this.baseUrl = baseUrl; + this.model = model; + this.truncate = truncate; + this.imageFields = imageFields; + this.textFields = textFields; + this.weights = weights; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Multi2VecCohereVectorizer(Builder builder) { + this( + 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.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 String baseUrl; + private String model; + private String truncate; + + /** Set base URL of the embedding service. */ + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder truncate(String truncate) { + this.truncate = truncate; + return this; + } + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(List fields) { + fields.forEach(field -> imageFields.put(field, null)); + return this; + } + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(String... fields) { + return imageFields(Arrays.asList(fields)); + } + + /** + * Add BLOB property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder imageField(String field, float weight) { + imageFields.put(field, weight); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(List fields) { + fields.forEach(field -> textFields.put(field, null)); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(String... fields) { + return textFields(Arrays.asList(fields)); + } + + /** + * Add TEXT property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder textField(String field, float weight) { + textFields.put(field, weight); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + @Override + public Multi2VecCohereVectorizer build() { + return new Multi2VecCohereVectorizer(this); + } + } +} 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 new file mode 100644 index 000000000..9b4530e6a --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecGoogleVectorizer.java @@ -0,0 +1,243 @@ +package io.weaviate.client6.v1.api.collections.vectorizers; + +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; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Multi2VecGoogleVectorizer( + @SerializedName("projectId") String projectId, + @SerializedName("model") String model, + @SerializedName("dimensions") Integer dimensions, + @SerializedName("location") String location, + /** BLOB image properties included in the embedding. */ + @SerializedName("imageFields") List imageFields, + /** BLOB video properties included in the embedding. */ + @SerializedName("videoFields") List videoFields, + /** TEXT properties included in the embedding. */ + @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. */ + Quantization quantization) implements VectorConfig { + + private static record Weights( + /** + * Weights of the BLOB image properties. Values appear in the same order as the + * corresponding property names in {@code imageFields}. + */ + @SerializedName("imageWeights") List imageWeights, + /** + * Weights of the BLOB video properties. Values appear in the same order as the + * corresponding property names in {@code videoFields}. + */ + @SerializedName("videoWeights") List videoWeights, + /** + * Weights of the TEXT properties. Values appear in the same order as the + * corresponding property names in {@code textFields}. + */ + @SerializedName("textWeights") List textWeights) { + } + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.MULTI2VEC_GOOGLE; + } + + @Override + public Object _self() { + return this; + } + + public static Multi2VecGoogleVectorizer of(String location) { + return of(location, ObjectBuilder.identity()); + } + + public static Multi2VecGoogleVectorizer of( + String location, + Function> fn) { + return fn.apply(new Builder(location)).build(); + } + + public Multi2VecGoogleVectorizer( + String projectId, + String model, + Integer dimensions, + String location, + List imageFields, + List videoFields, + List textFields, + Weights weights, + boolean vectorizeCollectionName, + VectorIndex vectorIndex, + Quantization quantization) { + this.vectorizeCollectionName = false; + + this.projectId = projectId; + this.model = model; + this.dimensions = dimensions; + this.location = location; + this.imageFields = imageFields; + this.videoFields = videoFields; + this.textFields = textFields; + this.weights = weights; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Multi2VecGoogleVectorizer(Builder builder) { + this( + builder.projectId, + builder.model, + builder.dimensions, + builder.location, + 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.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 final String projectId; + private String model; + private String location; + private Integer dimensions; + + public Builder(String projectId) { + this.projectId = projectId; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder location(String location) { + this.location = location; + return this; + } + + public Builder dimensions(int dimensions) { + this.dimensions = dimensions; + return this; + } + + /** Add BLOB image properties to include in the embedding. */ + public Builder imageFields(List fields) { + fields.forEach(field -> imageFields.put(field, null)); + return this; + } + + /** Add BLOB image properties to include in the embedding. */ + public Builder imageFields(String... fields) { + return imageFields(Arrays.asList(fields)); + } + + /** + * Add BLOB image property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder imageField(String field, float weight) { + imageFields.put(field, weight); + return this; + } + + /** Add BLOB video properties to include in the embedding. */ + public Builder videoFields(List fields) { + fields.forEach(field -> videoFields.put(field, null)); + return this; + } + + /** Add BLOB video properties to include in the embedding. */ + public Builder videoFields(String... fields) { + return videoFields(Arrays.asList(fields)); + } + + /** + * Add BLOB video property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder videoField(String field, float weight) { + videoFields.put(field, weight); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(List fields) { + fields.forEach(field -> textFields.put(field, null)); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(String... fields) { + return textFields(Arrays.asList(fields)); + } + + /** + * Add TEXT property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder textField(String field, float weight) { + textFields.put(field, weight); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + @Override + public Multi2VecGoogleVectorizer build() { + return new Multi2VecGoogleVectorizer(this); + } + } +} 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 new file mode 100644 index 000000000..19de6e9a8 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecJinaAiVectorizer.java @@ -0,0 +1,200 @@ +package io.weaviate.client6.v1.api.collections.vectorizers; + +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; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Multi2VecJinaAiVectorizer( + /** Base URL of the embedding service. */ + @SerializedName("baseURL") String baseUrl, + /** Inference model to use. */ + @SerializedName("model") String model, + @SerializedName("dimensions") Integer dimensions, + /** BLOB properties included in the embedding. */ + @SerializedName("imageFields") List imageFields, + /** TEXT properties included in the embedding. */ + @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. */ + Quantization quantization) implements VectorConfig { + + private static record Weights( + /** + * Weights of the BLOB properties. Values appear in the same order as the + * corresponding property names in {@code imageFields}. + */ + @SerializedName("imageWeights") List imageWeights, + /** + * Weights of the TEXT properties. Values appear in the same order as the + * corresponding property names in {@code textFields}. + */ + @SerializedName("textWeights") List textWeights) { + } + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.MULTI2VEC_COHERE; + } + + @Override + public Object _self() { + return this; + } + + public static Multi2VecJinaAiVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Multi2VecJinaAiVectorizer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public Multi2VecJinaAiVectorizer( + String baseUrl, + String model, + Integer dimensions, + List imageFields, + List textFields, + Weights weights, + boolean vectorizeCollectionName, + VectorIndex vectorIndex, + Quantization quantization) { + this.vectorizeCollectionName = false; + this.baseUrl = baseUrl; + this.model = model; + this.dimensions = dimensions; + this.imageFields = imageFields; + this.textFields = textFields; + this.weights = weights; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Multi2VecJinaAiVectorizer(Builder builder) { + this( + 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.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 String baseUrl; + private String model; + private Integer dimensions; + + /** Set base URL of the embedding service. */ + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder dimensions(int dimensions) { + this.dimensions = dimensions; + return this; + } + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(List fields) { + fields.forEach(field -> imageFields.put(field, null)); + return this; + } + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(String... fields) { + return imageFields(Arrays.asList(fields)); + } + + /** + * Add BLOB property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder imageField(String field, float weight) { + imageFields.put(field, weight); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(List fields) { + fields.forEach(field -> textFields.put(field, null)); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(String... fields) { + return textFields(Arrays.asList(fields)); + } + + /** + * Add TEXT property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder textField(String field, float weight) { + textFields.put(field, weight); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + @Override + public Multi2VecJinaAiVectorizer build() { + return new Multi2VecJinaAiVectorizer(this); + } + } +} 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 new file mode 100644 index 000000000..29dcc9599 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecNvidiaVectorizer.java @@ -0,0 +1,180 @@ +package io.weaviate.client6.v1.api.collections.vectorizers; + +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; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Multi2VecNvidiaVectorizer( + /** Base URL of the embedding service. */ + @SerializedName("baseURL") String baseUrl, + /** Inference model to use. */ + @SerializedName("model") String model, + /** Whether to apply truncation. */ + @SerializedName("truncate") Boolean truncate, + @SerializedName("output_encoding") String outputEncoding, + /** BLOB properties included in the embedding. */ + @SerializedName("imageFields") List imageFields, + /** TEXT properties included in the embedding. */ + @SerializedName("textFields") List textFields, + /** Weights of the included properties. */ + @SerializedName("weights") Weights weights, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + private static record Weights( + /** + * Weights of the BLOB properties. Values appear in the same order as the + * corresponding property names in {@code imageFields}. + */ + @SerializedName("imageWeights") List imageWeights, + /** + * Weights of the TEXT properties. Values appear in the same order as the + * corresponding property names in {@code textFields}. + */ + @SerializedName("textWeights") List textWeights) { + } + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.MULTI2VEC_NVIDIA; + } + + @Override + public Object _self() { + return this; + } + + public static Multi2VecNvidiaVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Multi2VecNvidiaVectorizer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public Multi2VecNvidiaVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + builder.truncate, + builder.outputEncoding, + builder.imageFields.keySet().stream().toList(), + builder.textFields.keySet().stream().toList(), + new Weights( + builder.imageFields.values().stream().toList(), + builder.textFields.values().stream().toList()), + builder.vectorIndex, + builder.quantization); + } + + 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 String baseUrl; + private String model; + private Boolean truncate; + private String outputEncoding; + + /** Set base URL of the embedding service. */ + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder truncate(Boolean truncate) { + this.truncate = truncate; + return this; + } + + public Builder outputEncoding(String outputEncoding) { + this.outputEncoding = outputEncoding; + return this; + } + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(List fields) { + fields.forEach(field -> imageFields.put(field, null)); + return this; + } + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(String... fields) { + return imageFields(Arrays.asList(fields)); + } + + /** + * Add BLOB property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder imageField(String field, float weight) { + imageFields.put(field, weight); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(List fields) { + fields.forEach(field -> textFields.put(field, null)); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(String... fields) { + return textFields(Arrays.asList(fields)); + } + + /** + * Add TEXT property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder textField(String field, float weight) { + textFields.put(field, weight); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + @Override + public Multi2VecNvidiaVectorizer build() { + return new Multi2VecNvidiaVectorizer(this); + } + } +} 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 new file mode 100644 index 000000000..d32440dcd --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Multi2VecVoyageAiVectorizer.java @@ -0,0 +1,210 @@ +package io.weaviate.client6.v1.api.collections.vectorizers; + +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; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Multi2VecVoyageAiVectorizer( + /** Base URL of the embedding service. */ + @SerializedName("baseURL") String baseUrl, + /** Inference model to use. */ + @SerializedName("model") String model, + @SerializedName("outputEncoding") String outputEncoding, + @SerializedName("truncate") Boolean truncate, + /** BLOB properties included in the embedding. */ + @SerializedName("imageFields") List imageFields, + /** TEXT properties included in the embedding. */ + @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. */ + Quantization quantization) implements VectorConfig { + + private static record Weights( + /** + * Weights of the BLOB properties. Values appear in the same order as the + * corresponding property names in {@code imageFields}. + */ + @SerializedName("imageWeights") List imageWeights, + /** + * Weights of the TEXT properties. Values appear in the same order as the + * corresponding property names in {@code textFields}. + */ + @SerializedName("textWeights") List textWeights) { + } + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.MULTI2VEC_VOYAGEAI; + } + + @Override + public Object _self() { + return this; + } + + public static Multi2VecVoyageAiVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Multi2VecVoyageAiVectorizer of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + public Multi2VecVoyageAiVectorizer( + String baseUrl, + String model, + String outputEncoding, + Boolean truncate, + List imageFields, + List textFields, + Weights weights, + boolean vectorizeCollectionName, + VectorIndex vectorIndex, + Quantization quantization) { + this.vectorizeCollectionName = false; + this.baseUrl = baseUrl; + this.model = model; + this.outputEncoding = outputEncoding; + this.truncate = truncate; + this.imageFields = imageFields; + this.textFields = textFields; + this.weights = weights; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Multi2VecVoyageAiVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + builder.outputEncoding, + 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.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 String baseUrl; + private String model; + private String outputEncoding; + private Boolean truncate; + + /** Set base URL of the embedding service. */ + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder outputEncoding(String outputEncoding) { + this.outputEncoding = outputEncoding; + return this; + } + + public Builder truncate(boolean truncate) { + this.truncate = truncate; + return this; + } + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(List fields) { + fields.forEach(field -> imageFields.put(field, null)); + return this; + } + + /** Add BLOB properties to include in the embedding. */ + public Builder imageFields(String... fields) { + return imageFields(Arrays.asList(fields)); + } + + /** + * Add BLOB property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder imageField(String field, float weight) { + imageFields.put(field, weight); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(List fields) { + fields.forEach(field -> textFields.put(field, null)); + return this; + } + + /** Add TEXT properties to include in the embedding. */ + public Builder textFields(String... fields) { + return textFields(Arrays.asList(fields)); + } + + /** + * Add TEXT property to include in the embedding. + * + * @param field Property name. + * @param weight Custom weight between 0.0 and 1.0. + */ + public Builder textField(String field, float weight) { + textFields.put(field, weight); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + @Override + public Multi2VecVoyageAiVectorizer build() { + return new Multi2VecVoyageAiVectorizer(this); + } + } +} diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Ref2VecCentroidVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Ref2VecCentroidVectorizer.java new file mode 100644 index 000000000..b018ca1f3 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Ref2VecCentroidVectorizer.java @@ -0,0 +1,100 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Ref2VecCentroidVectorizer( + @SerializedName("referenceProperties") List referenceProperties, + @SerializedName("method") Method method, + + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.REF2VEC_CENTROID; + } + + @Override + public Object _self() { + return this; + } + + public enum Method { + @SerializedName("mean") + MEAN; + } + + public static Ref2VecCentroidVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Ref2VecCentroidVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public Ref2VecCentroidVectorizer(Builder builder) { + this( + builder.referenceProperties, + builder.method, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private Quantization quantization; + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private List referenceProperties = new ArrayList<>(); + private Method method = Method.MEAN; + + /** Add properties to include in the embedding. */ + public Builder referenceProperties(String... properties) { + return referenceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder referenceProperties(List properties) { + this.referenceProperties.addAll(properties); + return this; + } + + public Builder method(Method method) { + this.method = method; + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Ref2VecCentroidVectorizer build() { + return new Ref2VecCentroidVectorizer(this); + } + } +} 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 new file mode 100644 index 000000000..f8fc5e063 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2MultiVecJinaAiVectorizer.java @@ -0,0 +1,133 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2MultiVecJinaAiVectorizer( + @SerializedName("model") String model, + @SerializedName("dimensions") Integer dimensions, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2MULTIVEC_JINAAI; + } + + @Override + public Object _self() { + return this; + } + + public static Text2MultiVecJinaAiVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2MultiVecJinaAiVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2MultiVecJinaAiVectorizer( + String model, + Integer dimensions, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.model = model; + this.dimensions = dimensions; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2MultiVecJinaAiVectorizer(Builder builder) { + this( + builder.model, + builder.dimensions, + + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String model; + private Integer dimensions; + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder dimensions(int dimensions) { + this.dimensions = dimensions; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2MultiVecJinaAiVectorizer build() { + return new Text2MultiVecJinaAiVectorizer(this); + } + } +} 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 new file mode 100644 index 000000000..0523baade --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecAwsVectorizer.java @@ -0,0 +1,201 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecAwsVectorizer( + @SerializedName("endpoint") String baseUrl, + @SerializedName("model") String model, + @SerializedName("region") String region, + @SerializedName("service") Service service, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_AWS; + } + + @Override + public Object _self() { + return this; + } + + public enum Service { + @SerializedName("bedrock") + BEDROCK, + @SerializedName("sagemaker") + SAGEMAKER; + } + + public static final String AMAZON_TITAN_EMBED_TEXT_V1 = "amazon.titan-embed-text-v1"; + public static final String COHERE_EMBED_ENGLISH_V3 = "cohere.embed-english-v3"; + public static final String COHERE_EMBED_MULTILINGUAL_V3 = "cohere.embed-multilingual-v3"; + + public static Text2VecAwsVectorizer bedrock(String model) { + return bedrock(model, ObjectBuilder.identity()); + } + + public static Text2VecAwsVectorizer bedrock( + String model, + Function> fn) { + return fn.apply(new BedrockBuilder(model)).build(); + } + + public static Text2VecAwsVectorizer sagemaker(String baseUrl) { + return sagemaker(baseUrl, ObjectBuilder.identity()); + } + + public static Text2VecAwsVectorizer sagemaker( + String baseUrl, + Function> fn) { + return fn.apply(new SagemakerBuilder(baseUrl)).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecAwsVectorizer( + String baseUrl, + String model, + String region, + Service service, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.baseUrl = baseUrl; + this.model = model; + this.region = region; + this.service = service; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecAwsVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + builder.region, + builder.service, + + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public abstract static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private final Service service; + private String baseUrl; + private String model; + private String region; + + protected Builder(Service service) { + this.service = service; + } + + /** Required for {@link Service#SAGEMAKER}. */ + protected Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + /** Required for {@link Service#BEDROCK}. */ + protected Builder model(String model) { + this.model = model; + return this; + } + + public Builder region(String region) { + this.region = region; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecAwsVectorizer build() { + return new Text2VecAwsVectorizer(this); + } + } + + public static class BedrockBuilder extends Builder { + public BedrockBuilder(String model) { + super(Service.BEDROCK); + super.model(model); + } + + @Override + /** Required for {@link Service#BEDROCK}. */ + public Builder model(String model) { + return super.model(model); + } + } + + public static class SagemakerBuilder extends Builder { + public SagemakerBuilder(String baseUrl) { + super(Service.SAGEMAKER); + super.baseUrl(baseUrl); + } + + /** Required for {@link Service#SAGEMAKER}. */ + protected Builder baseUrl(String baseUrl) { + return super.baseUrl(baseUrl); + } + } +} 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 new file mode 100644 index 000000000..121ad478a --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecAzureOpenAiVectorizer.java @@ -0,0 +1,143 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecAzureOpenAiVectorizer( + @SerializedName("baseURL") String baseUrl, + @SerializedName("deploymentId") String deploymentId, + @SerializedName("resourceName") String resourceName, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_AZURE_OPENAI; + } + + @Override + public Object _self() { + return this; + } + + public static Text2VecAzureOpenAiVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecAzureOpenAiVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecAzureOpenAiVectorizer( + String baseUrl, + String deploymentId, + String resourceName, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.baseUrl = baseUrl; + this.deploymentId = deploymentId; + this.resourceName = resourceName; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecAzureOpenAiVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.deploymentId, + builder.resourceName, + + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String baseUrl; + private String deploymentId; + private String resourceName; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder deploymentId(String deploymentId) { + this.deploymentId = deploymentId; + return this; + } + + public Builder resourceName(String resourceName) { + this.resourceName = resourceName; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecAzureOpenAiVectorizer build() { + return new Text2VecAzureOpenAiVectorizer(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 new file mode 100644 index 000000000..1cfc239aa --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecCohereVectorizer.java @@ -0,0 +1,155 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecCohereVectorizer( + @SerializedName("baseUrl") String baseUrl, + @SerializedName("model") String model, + @SerializedName("truncate") Truncate truncate, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_COHERE; + } + + @Override + public Object _self() { + return this; + } + + public enum Truncate { + @SerializedName("NONE") + NONE, + @SerializedName("START") + START, + @SerializedName("END") + END, + @SerializedName("LEFT") + LEFT, + @SerializedName("RIGHT") + RIGHT; + } + + public static Text2VecCohereVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecCohereVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecCohereVectorizer( + String baseUrl, + String model, + Truncate truncate, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.model = model; + this.truncate = truncate; + this.baseUrl = baseUrl; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecCohereVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + builder.truncate, + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String model; + private Truncate truncate; + private String baseUrl; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder truncate(Truncate truncate) { + this.truncate = truncate; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecCohereVectorizer build() { + return new Text2VecCohereVectorizer(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 new file mode 100644 index 000000000..960b9aa16 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecDatabricksVectorizer.java @@ -0,0 +1,133 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecDatabricksVectorizer( + @SerializedName("endpoint") String baseUrl, + @SerializedName("instruction") String instruction, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_MISTRAL; + } + + @Override + public Object _self() { + return this; + } + + public static Text2VecDatabricksVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecDatabricksVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecDatabricksVectorizer( + String baseUrl, + String instruction, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.baseUrl = baseUrl; + this.instruction = instruction; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecDatabricksVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.instruction, + + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String baseUrl; + private String instruction; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder instruction(String instruction) { + this.instruction = instruction; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecDatabricksVectorizer build() { + return new Text2VecDatabricksVectorizer(this); + } + } +} diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecGoogleAiStudioVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecGoogleAiStudioVectorizer.java new file mode 100644 index 000000000..b477ca6d9 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecGoogleAiStudioVectorizer.java @@ -0,0 +1,104 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecGoogleAiStudioVectorizer( + @SerializedName("model") String model, + @SerializedName("titleProperty") String titleProperty, + + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_GOOGLEAISTUDIO; + } + + @Override + public Object _self() { + return this; + } + + public static Text2VecGoogleAiStudioVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecGoogleAiStudioVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public Text2VecGoogleAiStudioVectorizer(Builder builder) { + this( + builder.model, + builder.titleProperty, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String model; + private String titleProperty; + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder titleProperty(String titleProperty) { + this.titleProperty = titleProperty; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecGoogleAiStudioVectorizer build() { + return new Text2VecGoogleAiStudioVectorizer(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 new file mode 100644 index 000000000..c891e1a5c --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecGoogleVectorizer.java @@ -0,0 +1,163 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecGoogleVectorizer( + @SerializedName("apiEndpoint") String baseUrl, + @SerializedName("model") String model, + @SerializedName("titleProperty") String titleProperty, + @SerializedName("dimensions") Integer dimensions, + @SerializedName("projectId") String projectId, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_GOOGLE; + } + + @Override + public Object _self() { + return this; + } + + public static Text2VecGoogleVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecGoogleVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecGoogleVectorizer( + String baseUrl, + String model, + String titleProperty, + Integer dimensions, + String projectId, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.baseUrl = baseUrl; + this.model = model; + this.titleProperty = titleProperty; + this.dimensions = dimensions; + this.projectId = projectId; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecGoogleVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + builder.titleProperty, + builder.dimensions, + builder.projectId, + + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String baseUrl; + private String model; + private String titleProperty; + private Integer dimensions; + private String projectId; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder dimensions(int dimensions) { + this.dimensions = dimensions; + return this; + } + + public Builder titleProperty(String titleProperty) { + this.titleProperty = titleProperty; + return this; + } + + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecGoogleVectorizer build() { + return new Text2VecGoogleVectorizer(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 new file mode 100644 index 000000000..ea63e30e4 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecHuggingfaceVectorizer.java @@ -0,0 +1,184 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecHuggingFaceVectorizer( + @SerializedName("endpointURL") String baseUrl, + @SerializedName("model") String model, + @SerializedName("passageModel") String passageModel, + @SerializedName("queryModel") String queryModel, + @SerializedName("useCache") Boolean useCache, + @SerializedName("useGPU") Boolean useGpu, + @SerializedName("waitForModel") Boolean waitForModel, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_HUGGINGFACE; + } + + @Override + public Object _self() { + return this; + } + + public static Text2VecHuggingFaceVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecHuggingFaceVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecHuggingFaceVectorizer( + String baseUrl, + String model, + String passageModel, + String queryModel, + Boolean useCache, + Boolean useGpu, + Boolean waitForModel, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.baseUrl = baseUrl; + this.model = model; + this.passageModel = passageModel; + this.queryModel = queryModel; + this.useCache = useCache; + this.useGpu = useGpu; + this.waitForModel = waitForModel; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecHuggingFaceVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + builder.passageModel, + builder.queryModel, + builder.useCache, + builder.useGpu, + builder.waitForModel, + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String baseUrl; + private String model; + private String passageModel; + private String queryModel; + private Boolean useCache; + private Boolean useGpu; + private Boolean waitForModel; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + /** The model to use for passage vectorization. */ + public Builder passageModel(String passageModel) { + this.passageModel = passageModel; + return this; + } + + /** The model to use for query vectorization. */ + public Builder queryModel(String queryModel) { + this.queryModel = queryModel; + return this; + } + + public Builder useCache(boolean useCache) { + this.useCache = useCache; + return this; + } + + public Builder useGpu(boolean useGpu) { + this.useGpu = useGpu; + return this; + } + + public Builder waitForModel(boolean waitForModel) { + this.waitForModel = waitForModel; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecHuggingFaceVectorizer build() { + return new Text2VecHuggingFaceVectorizer(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 new file mode 100644 index 000000000..acec520c7 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecJinaAiVectorizer.java @@ -0,0 +1,126 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecJinaAiVectorizer( + @SerializedName("model") String model, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_JINAAI; + } + + @Override + public Object _self() { + return this; + } + + public static String JINA_EMBEDDINGS_V2_BASE_EN = "jina-embeddings-v2-base-en"; + public static String JINA_EMBEDDINGS_V2_SMALL_EN = "jina-embeddings-v2-small-en"; + + public static Text2VecJinaAiVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecJinaAiVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecJinaAiVectorizer( + String model, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.model = model; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecJinaAiVectorizer(Builder builder) { + this( + builder.model, + + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String model; + + public Builder model(String model) { + this.model = model; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecJinaAiVectorizer build() { + return new Text2VecJinaAiVectorizer(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 new file mode 100644 index 000000000..efabaff8b --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecMistralVectorizer.java @@ -0,0 +1,135 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecMistralVectorizer( + @SerializedName("baseURL") String baseUrl, + @SerializedName("model") String model, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_MISTRAL; + } + + @Override + public Object _self() { + return this; + } + + public static String MISTRAL_EMBED = "mistral-embed"; + + public static Text2VecMistralVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecMistralVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecMistralVectorizer( + String baseUrl, + String model, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.baseUrl = baseUrl; + this.model = model; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecMistralVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String baseUrl; + private String model; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecMistralVectorizer build() { + return new Text2VecMistralVectorizer(this); + } + } +} diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecContextionaryVectorizer.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecModel2VecVectorizer.java similarity index 69% rename from src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecContextionaryVectorizer.java rename to src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecModel2VecVectorizer.java index 9f7a4808a..a852734cb 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecContextionaryVectorizer.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecModel2VecVectorizer.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.function.Function; @@ -13,12 +12,11 @@ import io.weaviate.client6.v1.api.collections.VectorIndex; import io.weaviate.client6.v1.internal.ObjectBuilder; -public record Text2VecContextionaryVectorizer( +public record Text2VecModel2VecVectorizer( + @SerializedName("inferenceURL") String baseUrl, + /** * Weaviate defaults to {@code true} if the value is not provided. - * Because text2vec-contextionary cannot handle underscores in collection names, - * this quickly becomes inconvenient. - * * To avoid that we send "vectorizeClassName": false all the time * and make it impossible to enable this feature, as it is deprecated. */ @@ -32,7 +30,7 @@ public record Text2VecContextionaryVectorizer( @Override public VectorConfig.Kind _kind() { - return VectorConfig.Kind.TEXT2VEC_CONTEXTIONARY; + return VectorConfig.Kind.TEXT2VEC_COHERE; } @Override @@ -40,37 +38,55 @@ public Object _self() { return this; } - public static Text2VecContextionaryVectorizer of() { + public static Text2VecModel2VecVectorizer of() { return of(ObjectBuilder.identity()); } - public static Text2VecContextionaryVectorizer of( - Function> fn) { + public static Text2VecModel2VecVectorizer of( + Function> fn) { return fn.apply(new Builder()).build(); } /** * Canonical constructor always sets {@link #vectorizeCollectionName} to false. */ - public Text2VecContextionaryVectorizer(boolean vectorizeCollectionName, List sourceProperties, - VectorIndex vectorIndex, Quantization quantization) { + public Text2VecModel2VecVectorizer( + String baseUrl, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.baseUrl = baseUrl; + this.vectorizeCollectionName = false; - this.sourceProperties = Collections.emptyList(); + this.sourceProperties = sourceProperties; this.vectorIndex = vectorIndex; this.quantization = quantization; } - public Text2VecContextionaryVectorizer(Builder builder) { - this(builder.vectorizeCollectionName, builder.sourceProperties, builder.vectorIndex, builder.quantization); + public Text2VecModel2VecVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); } - public static class Builder implements ObjectBuilder { + public static class Builder implements ObjectBuilder { private final boolean vectorizeCollectionName = false; private Quantization quantization; - private List sourceProperties = new ArrayList<>(); private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + private String baseUrl; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + /** Add properties to include in the embedding. */ public Builder sourceProperties(String... properties) { return sourceProperties(Arrays.asList(properties)); @@ -99,8 +115,8 @@ public Builder quantization(Quantization quantization) { return this; } - public Text2VecContextionaryVectorizer build() { - return new Text2VecContextionaryVectorizer(this); + public Text2VecModel2VecVectorizer build() { + return new Text2VecModel2VecVectorizer(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 new file mode 100644 index 000000000..8fd7660d7 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecMorphVectorizer.java @@ -0,0 +1,104 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecMorphVectorizer( + @SerializedName("baseURL") String baseUrl, + @SerializedName("model") String model, + + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_HUGGINGFACE; + } + + @Override + public Object _self() { + return this; + } + + public static Text2VecMorphVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecMorphVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public Text2VecMorphVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String baseUrl; + private String model; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecMorphVectorizer build() { + return new Text2VecMorphVectorizer(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 new file mode 100644 index 000000000..e06016c84 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecNvidiaVectorizer.java @@ -0,0 +1,143 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecNvidiaVectorizer( + @SerializedName("baseURL") String baseUrl, + @SerializedName("model") String model, + @SerializedName("truncate") Boolean truncate, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_NVIDIA; + } + + @Override + public Object _self() { + return this; + } + + public static Text2VecNvidiaVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecNvidiaVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecNvidiaVectorizer( + String baseUrl, + String model, + Boolean truncate, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.baseUrl = baseUrl; + this.model = model; + this.truncate = truncate; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecNvidiaVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + builder.truncate, + + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String baseUrl; + private String model; + private Boolean truncate; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder truncate(Boolean truncate) { + this.truncate = truncate; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecNvidiaVectorizer build() { + return new Text2VecNvidiaVectorizer(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 new file mode 100644 index 000000000..f2f0a0ad8 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecOllamaVectorizer.java @@ -0,0 +1,133 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecOllamaVectorizer( + @SerializedName("apiEndpoint") String baseUrl, + @SerializedName("model") String model, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_OLLAMA; + } + + @Override + public Object _self() { + return this; + } + + public static Text2VecOllamaVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecOllamaVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecOllamaVectorizer( + String baseUrl, + String model, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.baseUrl = baseUrl; + this.model = model; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecOllamaVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String baseUrl; + private String model; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecOllamaVectorizer build() { + return new Text2VecOllamaVectorizer(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 new file mode 100644 index 000000000..12892d897 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecOpenAiVectorizer.java @@ -0,0 +1,174 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecOpenAiVectorizer( + @SerializedName("baseURL") String baseUrl, + @SerializedName("model") String model, + @SerializedName("modelVersion") String modelVersion, + @SerializedName("dimensions") Integer dimensions, + @SerializedName("type") ModelType modelType, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_OPENAI; + } + + public static String TEXT_EMBEDDING_3_SMALL = "text-embeding-3-small"; + public static String TEXT_EMBEDDING_3_LARGE = "text-embeding-3-large"; + public static String TEXT_EMBEDDING_ADA_002 = "text-embeding-ada-002"; + + @Override + public Object _self() { + return this; + } + + public enum ModelType { + @SerializedName("CODE") + CODE, + @SerializedName("TEXT") + TEXT; + } + + public static Text2VecOpenAiVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecOpenAiVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecOpenAiVectorizer( + String baseUrl, + String model, + String modelVersion, + Integer dimensions, + ModelType modelType, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.baseUrl = baseUrl; + this.model = model; + this.modelVersion = modelVersion; + this.dimensions = dimensions; + this.modelType = modelType; + + this.vectorizeCollectionName = false; + this.sourceProperties = sourceProperties; + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecOpenAiVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + builder.modelVersion, + builder.dimensions, + builder.modelType, + + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String baseUrl; + private String model; + private String modelVersion; + private Integer dimensions; + private ModelType modelType; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder dimensions(int dimensions) { + this.dimensions = dimensions; + return this; + } + + public Builder modelVersion(String modelVersion) { + this.modelVersion = modelVersion; + return this; + } + + public Builder modelType(ModelType modelType) { + this.modelType = modelType; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecOpenAiVectorizer build() { + return new Text2VecOpenAiVectorizer(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 new file mode 100644 index 000000000..e6dcba73e --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecTransformersVectorizer.java @@ -0,0 +1,127 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecTransformersVectorizer( + @SerializedName("inferenceUrl") String baseUrl, + @SerializedName("passageInferenceUrl") String passageInferenceUrl, + @SerializedName("queryInferenceUrl") String queryInferenceUrl, + @SerializedName("poolingStrategy") PoolingStrategy poolingStrategy, + + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_TRANSFORMERS; + } + + @Override + public Object _self() { + return this; + } + + public enum PoolingStrategy { + @SerializedName("MASKED_MEAN") + MASKED_MEAN, + @SerializedName("CLS") + CLS; + } + + public static Text2VecTransformersVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecTransformersVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + public Text2VecTransformersVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.passageInferenceUrl, + builder.queryInferenceUrl, + builder.poolingStrategy, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String baseUrl; + private String passageInferenceUrl; + private String queryInferenceUrl; + private PoolingStrategy poolingStrategy; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder passageInferenceUrl(String passageInferenceUrl) { + this.passageInferenceUrl = passageInferenceUrl; + return this; + } + + public Builder queryInferenceUrl(String queryInferenceUrl) { + this.queryInferenceUrl = queryInferenceUrl; + return this; + } + + public Builder poolingStrategy(PoolingStrategy poolingStrategy) { + this.poolingStrategy = poolingStrategy; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecTransformersVectorizer build() { + return new Text2VecTransformersVectorizer(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 new file mode 100644 index 000000000..cd3da6e00 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorizers/Text2VecVoyageAiVectorizer.java @@ -0,0 +1,143 @@ +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; + +import com.google.gson.annotations.SerializedName; + +import io.weaviate.client6.v1.api.collections.Quantization; +import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; +import io.weaviate.client6.v1.internal.ObjectBuilder; + +public record Text2VecVoyageAiVectorizer( + @SerializedName("baseUrl") String baseUrl, + @SerializedName("model") String model, + @SerializedName("truncate") Boolean truncate, + + /** + * 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, + /** Properties included in the embedding. */ + @SerializedName("sourceProperties") List sourceProperties, + /** Vector index configuration. */ + VectorIndex vectorIndex, + /** Vector quantization method. */ + Quantization quantization) implements VectorConfig { + + @Override + public VectorConfig.Kind _kind() { + return VectorConfig.Kind.TEXT2VEC_VOYAGEAI; + } + + @Override + public Object _self() { + return this; + } + + public static Text2VecVoyageAiVectorizer of() { + return of(ObjectBuilder.identity()); + } + + public static Text2VecVoyageAiVectorizer of( + Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Canonical constructor always sets {@link #vectorizeCollectionName} to false. + */ + public Text2VecVoyageAiVectorizer( + String baseUrl, + String model, + Boolean truncate, + + boolean vectorizeCollectionName, + List sourceProperties, + VectorIndex vectorIndex, + Quantization quantization) { + this.model = model; + this.truncate = truncate; + this.baseUrl = baseUrl; + + this.vectorizeCollectionName = false; + this.sourceProperties = Collections.emptyList(); + this.vectorIndex = vectorIndex; + this.quantization = quantization; + } + + public Text2VecVoyageAiVectorizer(Builder builder) { + this( + builder.baseUrl, + builder.model, + builder.truncate, + builder.vectorizeCollectionName, + builder.sourceProperties, + builder.vectorIndex, + builder.quantization); + } + + public static class Builder implements ObjectBuilder { + private final boolean vectorizeCollectionName = false; + private Quantization quantization; + private List sourceProperties = new ArrayList<>(); + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; + + private String model; + private Boolean truncate; + private String baseUrl; + + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; + return this; + } + + public Builder model(String model) { + this.model = model; + return this; + } + + public Builder truncate(boolean truncate) { + this.truncate = truncate; + return this; + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(String... properties) { + return sourceProperties(Arrays.asList(properties)); + } + + /** Add properties to include in the embedding. */ + public Builder sourceProperties(List properties) { + this.sourceProperties.addAll(properties); + return this; + } + + /** + * Override default vector index configuration. + * + * HNSW + * is the default vector index. + */ + public Builder vectorIndex(VectorIndex vectorIndex) { + this.vectorIndex = vectorIndex; + return this; + } + + public Builder quantization(Quantization quantization) { + this.quantization = quantization; + return this; + } + + public Text2VecVoyageAiVectorizer build() { + return new Text2VecVoyageAiVectorizer(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 629befb73..05972637d 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 @@ -14,7 +14,7 @@ public record Text2VecWeaviateVectorizer( /** Weaviate Embeddings Service base URL. */ - @SerializedName("baseUrl") String inferenceUrl, + @SerializedName("baseURL") String baseUrl, /** Dimensionality of the generated vectors. */ @SerializedName("dimensions") Integer dimensions, /** Embedding model. */ @@ -46,7 +46,7 @@ public static Text2VecWeaviateVectorizer of(Function { private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; private Quantization quantization; - private String inferenceUrl; + private String baseUrl; private Integer dimensions; private String model; private List sourceProperties = new ArrayList<>(); @@ -70,8 +70,8 @@ public static class Builder implements ObjectBuilder * to a Weaviate Cloud instance: the client will automatically set the necessary * headers. */ - public Builder inferenceUrl(String inferenceUrl) { - this.inferenceUrl = inferenceUrl; + public Builder baseUrl(String baseUrl) { + this.baseUrl = baseUrl; 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 f6f15e0dd..773340a5a 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 @@ -39,7 +39,7 @@ import io.weaviate.client6.v1.api.collections.vectorizers.Img2VecNeuralVectorizer; import io.weaviate.client6.v1.api.collections.vectorizers.Multi2VecClipVectorizer; import io.weaviate.client6.v1.api.collections.vectorizers.SelfProvidedVectorizer; -import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecContextionaryVectorizer; +import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecCohereVectorizer; import io.weaviate.client6.v1.api.collections.vectorizers.Text2VecWeaviateVectorizer; import io.weaviate.client6.v1.api.rbac.AliasesPermission; import io.weaviate.client6.v1.api.rbac.BackupsPermission; @@ -92,7 +92,7 @@ public static Object[][] testCases() { { VectorConfig.class, Multi2VecClipVectorizer.of(m2v -> m2v - .inferenceUrl("http://example.com") + .baseUrl("http://example.com") .imageField("img", 1f) .textField("txt", 2f)), """ @@ -115,13 +115,13 @@ public static Object[][] testCases() { }, { VectorConfig.class, - Text2VecContextionaryVectorizer.of(), + Text2VecCohereVectorizer.of(), """ { "vectorIndexType": "hnsw", "vectorIndexConfig": {}, "vectorizer": { - "text2vec-contextionary": { + "text2vec-cohere": { "vectorizeClassName": false, "sourceProperties": [] } @@ -132,7 +132,7 @@ public static Object[][] testCases() { { VectorConfig.class, Text2VecWeaviateVectorizer.of(t2v -> t2v - .inferenceUrl("http://example.com") + .baseUrl("http://example.com") .dimensions(4) .model("very-good-model")), """ @@ -141,7 +141,7 @@ public static Object[][] testCases() { "vectorIndexConfig": {}, "vectorizer": { "text2vec-weaviate": { - "baseUrl": "http://example.com", + "baseURL": "http://example.com", "dimensions": 4, "model": "very-good-model", "sourceProperties": [] @@ -933,19 +933,34 @@ public static Object[][] testCases() { }, { Generative.class, - Generative.aws( + Generative.awsBedrock( "aws-region", - "aws-service", + "example-model", cfg -> cfg - .baseUrl("https://example.com") .model("example-model")), """ { "generative-aws": { - "endpoint": "https://example.com", "model": "example-model", "region": "aws-region", - "service": "aws-service" + "service": "bedrock" + } + } + """, + }, + { + Generative.class, + Generative.awsSagemaker( + "aws-region", + "https://example.com", + cfg -> cfg + .baseUrl("https://example.com")), + """ + { + "generative-aws": { + "endpoint": "https://example.com", + "region": "aws-region", + "service": "sagemaker" } } """,