|
| 1 | +package io.weaviate.client6.v1.api.collections.vectorizers; |
| 2 | + |
| 3 | +import java.util.Arrays; |
| 4 | +import java.util.List; |
| 5 | +import java.util.function.Function; |
| 6 | + |
| 7 | +import com.google.gson.annotations.SerializedName; |
| 8 | + |
| 9 | +import io.weaviate.client6.v1.api.collections.Quantization; |
| 10 | +import io.weaviate.client6.v1.api.collections.VectorConfig; |
| 11 | +import io.weaviate.client6.v1.api.collections.VectorIndex; |
| 12 | +import io.weaviate.client6.v1.internal.ObjectBuilder; |
| 13 | + |
| 14 | +public record Multi2MultiVecWeaviateVectorizer( |
| 15 | + /** Base URL of the embedding service. */ |
| 16 | + @SerializedName("baseURL") String baseUrl, |
| 17 | + /** Inference model to use. */ |
| 18 | + @SerializedName("model") String model, |
| 19 | + /** BLOB properties included in the embedding. */ |
| 20 | + @SerializedName("imageFields") List<String> imageFields, |
| 21 | + /** TEXT properties included in the embedding. */ |
| 22 | + @SerializedName("textFields") List<String> textFields, |
| 23 | + /** Vector index configuration. */ |
| 24 | + VectorIndex vectorIndex, |
| 25 | + /** Vector quantization method. */ |
| 26 | + Quantization quantization) implements VectorConfig { |
| 27 | + |
| 28 | + @Override |
| 29 | + public VectorConfig.Kind _kind() { |
| 30 | + return VectorConfig.Kind.MULTI2MULTIVEC_WEAVIATE; |
| 31 | + } |
| 32 | + |
| 33 | + @Override |
| 34 | + public Object _self() { |
| 35 | + return this; |
| 36 | + } |
| 37 | + |
| 38 | + /** ColBERT-family model available in the Weaviate Embedding Service. */ |
| 39 | + public static String MODERNVBERT_COLMODERNVBERT = "ModernVBERT/colmodernvbert"; |
| 40 | + |
| 41 | + public static Multi2MultiVecWeaviateVectorizer of() { |
| 42 | + return of(ObjectBuilder.identity()); |
| 43 | + } |
| 44 | + |
| 45 | + public static Multi2MultiVecWeaviateVectorizer of( |
| 46 | + Function<Builder, ObjectBuilder<Multi2MultiVecWeaviateVectorizer>> fn) { |
| 47 | + return fn.apply(new Builder()).build(); |
| 48 | + } |
| 49 | + |
| 50 | + public Multi2MultiVecWeaviateVectorizer(Builder builder) { |
| 51 | + this( |
| 52 | + builder.baseUrl, |
| 53 | + builder.model, |
| 54 | + builder.imageFields, |
| 55 | + builder.textFields, |
| 56 | + builder.vectorIndex, |
| 57 | + builder.quantization); |
| 58 | + } |
| 59 | + |
| 60 | + public static class Builder implements ObjectBuilder<Multi2MultiVecWeaviateVectorizer> { |
| 61 | + private VectorIndex vectorIndex = VectorIndex.DEFAULT_VECTOR_INDEX; |
| 62 | + private Quantization quantization; |
| 63 | + |
| 64 | + private String baseUrl; |
| 65 | + private String model; |
| 66 | + |
| 67 | + private List<String> imageFields; |
| 68 | + private List<String> textFields; |
| 69 | + |
| 70 | + public Builder baseUrl(String baseUrl) { |
| 71 | + this.baseUrl = baseUrl; |
| 72 | + return this; |
| 73 | + } |
| 74 | + |
| 75 | + public Builder model(String model) { |
| 76 | + this.model = model; |
| 77 | + return this; |
| 78 | + } |
| 79 | + |
| 80 | + /** Add BLOB properties to include in the embedding. */ |
| 81 | + public Builder imageFields(List<String> fields) { |
| 82 | + imageFields = fields; |
| 83 | + return this; |
| 84 | + } |
| 85 | + |
| 86 | + /** Add BLOB properties to include in the embedding. */ |
| 87 | + public Builder imageFields(String... fields) { |
| 88 | + return imageFields(Arrays.asList(fields)); |
| 89 | + } |
| 90 | + |
| 91 | + /** Add TEXT properties to include in the embedding. */ |
| 92 | + public Builder textFields(List<String> fields) { |
| 93 | + textFields = fields; |
| 94 | + return this; |
| 95 | + } |
| 96 | + |
| 97 | + /** Add TEXT properties to include in the embedding. */ |
| 98 | + public Builder textFields(String... fields) { |
| 99 | + return textFields(Arrays.asList(fields)); |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * Override default vector index configuration. |
| 104 | + * |
| 105 | + * <a href= |
| 106 | + * "https://docs.weaviate.io/weaviate/config-refs/indexing/vector-index#hnsw-index-parameters">HNSW</a> |
| 107 | + * is the default vector index. |
| 108 | + */ |
| 109 | + public Builder vectorIndex(VectorIndex vectorIndex) { |
| 110 | + this.vectorIndex = vectorIndex; |
| 111 | + return this; |
| 112 | + } |
| 113 | + |
| 114 | + public Builder quantization(Quantization quantization) { |
| 115 | + this.quantization = quantization; |
| 116 | + return this; |
| 117 | + } |
| 118 | + |
| 119 | + @Override |
| 120 | + public Multi2MultiVecWeaviateVectorizer build() { |
| 121 | + return new Multi2MultiVecWeaviateVectorizer(this); |
| 122 | + } |
| 123 | + } |
| 124 | +} |
0 commit comments