{
private Integer code;
private String msg;
private T data;
+
+ ResponseWrapper() {
+
+ }
+
+ ResponseWrapper(Integer code, String msg, T data) {
+ this.code = code;
+ this.msg = msg;
+ this.data = data;
+ }
}
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/RetrievalParam.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/RetrievalParam.java
index b35db1d0c..176d0ef75 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/RetrievalParam.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/RetrievalParam.java
@@ -1,20 +1,35 @@
package dev.langchain4j.store.embedding.vearch;
-import com.google.gson.annotations.SerializedName;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
+import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
/**
* As a constraint of all engine type only
*
* @see RetrievalType
*/
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(NON_NULL)
+@JsonNaming(SnakeCaseStrategy.class)
public abstract class RetrievalParam {
+ protected RetrievalParam() {
+
+ }
+
@Getter
@Setter
@Builder
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
public static class IVFPQParam extends RetrievalParam {
@Builder.Default
@@ -31,11 +46,23 @@ public abstract class RetrievalParam {
* default 64, must be a multiple of 4
*/
private Integer nsubvector;
+
+ public IVFPQParam() {
+ }
+
+ public IVFPQParam(MetricType metricType, Integer ncentroids, Integer nsubvector) {
+ this.metricType = metricType;
+ this.ncentroids = ncentroids;
+ this.nsubvector = nsubvector;
+ }
}
@Getter
@Setter
@Builder
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
public static class HNSWParam extends RetrievalParam {
@Builder.Default
@@ -52,13 +79,24 @@ public abstract class RetrievalParam {
* default 40
* The higher the value, the better the construction effect, and the longer it takes
*/
- @SerializedName("efConstruction")
private Integer efConstruction;
+
+ public HNSWParam() {
+ }
+
+ public HNSWParam(MetricType metricType, Integer nlinks, Integer efConstruction) {
+ this.metricType = metricType;
+ this.nlinks = nlinks;
+ this.efConstruction = efConstruction;
+ }
}
@Getter
@Setter
@Builder
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
public static class GPUParam extends RetrievalParam {
@Builder.Default
@@ -75,11 +113,23 @@ public abstract class RetrievalParam {
* default 64
*/
private Integer nsubvector;
+
+ public GPUParam() {
+ }
+
+ public GPUParam(MetricType metricType, Integer ncentroids, Integer nsubvector) {
+ this.metricType = metricType;
+ this.ncentroids = ncentroids;
+ this.nsubvector = nsubvector;
+ }
}
@Getter
@Setter
@Builder
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
public static class IVFFLATParam extends RetrievalParam {
@Builder.Default
@@ -90,6 +140,14 @@ public abstract class RetrievalParam {
* default 2048
*/
private Integer ncentroids;
+
+ public IVFFLATParam() {
+ }
+
+ public IVFFLATParam(MetricType metricType, Integer ncentroids) {
+ this.metricType = metricType;
+ this.ncentroids = ncentroids;
+ }
}
@Getter
@@ -103,6 +161,14 @@ public abstract class RetrievalParam {
* default 256
*/
private Integer ncentroids;
+
+ public BINARYIVFParam() {
+
+ }
+
+ public BINARYIVFParam(Integer ncentroids) {
+ this.ncentroids = ncentroids;
+ }
}
@Getter
@@ -112,5 +178,12 @@ public abstract class RetrievalParam {
@Builder.Default
private MetricType metricType = MetricType.INNER_PRODUCT;
+
+ public FLAT() {
+ }
+
+ public FLAT(MetricType metricType) {
+ this.metricType = metricType;
+ }
}
}
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/RetrievalType.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/RetrievalType.java
index 63538bb16..880b5e6bc 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/RetrievalType.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/RetrievalType.java
@@ -1,7 +1,15 @@
package dev.langchain4j.store.embedding.vearch;
-import lombok.Getter;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
+import com.fasterxml.jackson.databind.annotation.JsonNaming;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(NON_NULL)
+@JsonNaming(SnakeCaseStrategy.class)
public enum RetrievalType {
IVFPQ(RetrievalParam.IVFPQParam.class),
@@ -11,10 +19,13 @@ public enum RetrievalType {
BINARYIVF(RetrievalParam.BINARYIVFParam.class),
FLAT(RetrievalParam.FLAT.class);
- @Getter
- private Class extends RetrievalParam> paramClass;
+ private final Class extends RetrievalParam> paramClass;
RetrievalType(Class extends RetrievalParam> paramClass) {
this.paramClass = paramClass;
}
+
+ public Class extends RetrievalParam> getParamClass() {
+ return paramClass;
+ }
}
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SearchRequest.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SearchRequest.java
index fa8abc936..948dda868 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SearchRequest.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SearchRequest.java
@@ -1,35 +1,78 @@
package dev.langchain4j.store.embedding.vearch;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
+import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
@Getter
@Setter
@Builder
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(NON_NULL)
+@JsonNaming(SnakeCaseStrategy.class)
class SearchRequest {
private QueryParam query;
private Integer size;
private List fields;
- @Getter
- @Setter
- @Builder
- public static class QueryParam {
+ SearchRequest() {
- private List sum;
+ }
+
+ SearchRequest(QueryParam query, Integer size, List fields) {
+ this.query = query;
+ this.size = size;
+ this.fields = fields;
}
@Getter
@Setter
@Builder
- public static class VectorParam {
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
+ static class QueryParam {
+
+ private List sum;
+
+ QueryParam() {
+
+ }
+
+ QueryParam(List sum) {
+ this.sum = sum;
+ }
+ }
+
+ @Getter
+ @Setter
+ @Builder
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
+ static class VectorParam {
private String field;
private List feature;
private Double minScore;
+
+ VectorParam() {
+
+ }
+
+ VectorParam(String field, List feature, Double minScore) {
+ this.field = field;
+ this.feature = feature;
+ this.minScore = minScore;
+ }
}
}
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SearchResponse.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SearchResponse.java
index 00dbf7006..6d99c7b25 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SearchResponse.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SearchResponse.java
@@ -1,48 +1,90 @@
package dev.langchain4j.store.embedding.vearch;
-import com.google.gson.annotations.SerializedName;
-import lombok.Builder;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
+import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
@Getter
@Setter
-@Builder
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(NON_NULL)
+@JsonNaming(SnakeCaseStrategy.class)
class SearchResponse {
private Integer took;
- @SerializedName("timed_out")
+ @JsonProperty("timed_out")
private Boolean timeout;
/**
* not support shards yet
*/
- @SerializedName("_shards")
+ @JsonProperty("_shards")
private Object shards;
private Hit hits;
+ SearchResponse() {
+
+ }
+
+ SearchResponse(Integer took, Boolean timeout, Hit hits, Object shards) {
+ this.took = took;
+ this.timeout = timeout;
+ this.hits = hits;
+ this.shards = shards;
+ }
+
@Getter
@Setter
- @Builder
- public static class Hit {
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
+ static class Hit {
private Integer total;
private Double maxScore;
private List hits;
+
+ Hit() {
+
+ }
+
+ Hit(Integer total, Double maxScore, List hits) {
+ this.total = total;
+ this.maxScore = maxScore;
+ this.hits = hits;
+ }
}
@Getter
@Setter
- @Builder
- public static class SearchedDocument {
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
+ static class SearchedDocument {
- @SerializedName("_id")
+ @JsonProperty("_id")
private String id;
- @SerializedName("_score")
+ @JsonProperty("_score")
private Double score;
- @SerializedName("_source")
+ @JsonProperty("_source")
private Map source;
+
+ SearchedDocument() {
+
+ }
+
+ SearchedDocument(String id, Double score, Map source) {
+ this.id = id;
+ this.score = score;
+ this.source = source;
+ }
}
}
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceEngine.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceEngine.java
index 1ede67568..50c6a6e77 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceEngine.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceEngine.java
@@ -1,10 +1,19 @@
package dev.langchain4j.store.embedding.vearch;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
+import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Getter;
import lombok.Setter;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
@Getter
@Setter
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(NON_NULL)
+@JsonNaming(SnakeCaseStrategy.class)
public class SpaceEngine {
private String name;
@@ -23,6 +32,10 @@ public class SpaceEngine {
setRetrievalParam(retrievalParam);
}
+ public static Builder builder() {
+ return new Builder();
+ }
+
public void setRetrievalParam(RetrievalParam retrievalParam) {
// do some constraint check
Class extends RetrievalParam> clazz = retrievalType.getParamClass();
@@ -34,10 +47,6 @@ public class SpaceEngine {
this.retrievalParam = retrievalParam;
}
- public static Builder builder() {
- return new Builder();
- }
-
public static class Builder {
private String name;
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpacePropertyParam.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpacePropertyParam.java
index ad901981d..3782d73ce 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpacePropertyParam.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpacePropertyParam.java
@@ -1,14 +1,25 @@
package dev.langchain4j.store.embedding.vearch;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
+import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
/**
* As a constraint type of all Space property only
*
* @see CreateSpaceRequest
*/
+@Getter
+@Setter
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(NON_NULL)
+@JsonNaming(SnakeCaseStrategy.class)
public abstract class SpacePropertyParam {
protected SpacePropertyType type;
@@ -19,6 +30,9 @@ public abstract class SpacePropertyParam {
@Getter
@Setter
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
public static class StringParam extends SpacePropertyParam {
/**
@@ -44,6 +58,9 @@ public abstract class SpacePropertyParam {
@Getter
@Setter
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
public static class IntegerParam extends SpacePropertyParam {
/**
@@ -66,6 +83,9 @@ public abstract class SpacePropertyParam {
@Getter
@Setter
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
public static class FloatParam extends SpacePropertyParam {
/**
@@ -88,6 +108,9 @@ public abstract class SpacePropertyParam {
@Getter
@Setter
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
public static class VectorParam extends SpacePropertyParam {
private Boolean index;
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpacePropertyType.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpacePropertyType.java
index de5f76470..bb41fbe90 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpacePropertyType.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpacePropertyType.java
@@ -1,26 +1,28 @@
package dev.langchain4j.store.embedding.vearch;
-import com.google.gson.annotations.SerializedName;
-import lombok.Getter;
+import com.fasterxml.jackson.annotation.JsonProperty;
public enum SpacePropertyType {
/**
* keyword is equivalent to string
*/
- @SerializedName("string")
+ @JsonProperty("string")
STRING(SpacePropertyParam.StringParam.class),
- @SerializedName("integer")
+ @JsonProperty("integer")
INTEGER(SpacePropertyParam.IntegerParam.class),
- @SerializedName("float")
+ @JsonProperty("float")
FLOAT(SpacePropertyParam.FloatParam.class),
- @SerializedName("vector")
+ @JsonProperty("vector")
VECTOR(SpacePropertyParam.VectorParam.class);
- @Getter
private final Class extends SpacePropertyParam> paramClass;
SpacePropertyType(Class extends SpacePropertyParam> paramClass) {
this.paramClass = paramClass;
}
+
+ public Class extends SpacePropertyParam> getParamClass() {
+ return paramClass;
+ }
}
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceStoreParam.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceStoreParam.java
index 48b4075bd..6eb8d3fd4 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceStoreParam.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceStoreParam.java
@@ -1,12 +1,21 @@
package dev.langchain4j.store.embedding.vearch;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
+import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
@Getter
@Setter
@Builder
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(NON_NULL)
+@JsonNaming(SnakeCaseStrategy.class)
public class SpaceStoreParam {
/**
@@ -18,6 +27,9 @@ public class SpaceStoreParam {
@Getter
@Setter
@Builder
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ @JsonInclude(NON_NULL)
+ @JsonNaming(SnakeCaseStrategy.class)
public static class CompressRate {
private Integer rate;
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceStoreType.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceStoreType.java
index 0b09e6927..1906bb5f5 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceStoreType.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/SpaceStoreType.java
@@ -1,14 +1,13 @@
package dev.langchain4j.store.embedding.vearch;
-import com.google.gson.annotations.SerializedName;
-import lombok.Getter;
+import com.fasterxml.jackson.annotation.JsonProperty;
public enum SpaceStoreType {
- @SerializedName("MemoryOnly")
+ @JsonProperty("MemoryOnly")
MEMORY_ONLY,
- @SerializedName("Mmap")
+ @JsonProperty("Mmap")
M_MAP,
- @SerializedName("RocksDB")
+ @JsonProperty("RocksDB")
ROCKS_DB
}
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchApi.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchApi.java
index f28b0824e..a566efc1c 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchApi.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchApi.java
@@ -6,7 +6,7 @@ import retrofit2.http.*;
import java.util.List;
-public interface VearchApi {
+interface VearchApi {
int OK = 200;
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchClient.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchClient.java
index de7f4659e..a425b0957 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchClient.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchClient.java
@@ -1,7 +1,6 @@
package dev.langchain4j.store.embedding.vearch;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import com.fasterxml.jackson.databind.ObjectMapper;
import dev.langchain4j.internal.Utils;
import lombok.Builder;
import okhttp3.MediaType;
@@ -9,7 +8,7 @@ import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import retrofit2.Response;
import retrofit2.Retrofit;
-import retrofit2.converter.gson.GsonConverterFactory;
+import retrofit2.converter.jackson.JacksonConverterFactory;
import java.io.IOException;
import java.time.Duration;
@@ -17,14 +16,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static com.google.gson.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES;
+import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
import static dev.langchain4j.store.embedding.vearch.VearchApi.OK;
class VearchClient {
- private static final Gson GSON = new GsonBuilder()
- .setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES)
- .create();
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private final VearchApi vearchApi;
@@ -40,7 +37,7 @@ class VearchClient {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Utils.ensureTrailingForwardSlash(baseUrl))
.client(okHttpClient)
- .addConverterFactory(GsonConverterFactory.create(GSON))
+ .addConverterFactory(JacksonConverterFactory.create(OBJECT_MAPPER))
.build();
vearchApi = retrofit.create(VearchApi.class);
@@ -133,7 +130,7 @@ class VearchClient {
fieldsExceptId.put(fieldName, value);
}
}
- bodyString.append(GSON.toJson(fieldsExceptId)).append("\n");
+ bodyString.append(OBJECT_MAPPER.writeValueAsString(fieldsExceptId)).append("\n");
}
RequestBody body = RequestBody.create(bodyString.toString(), MediaType.parse("application/json; charset=utf-8"));
Response> response = vearchApi.bulk(dbName, spaceName, body).execute();
diff --git a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchEmbeddingStore.java b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchEmbeddingStore.java
index 4102efc1f..7c0dfeb76 100644
--- a/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchEmbeddingStore.java
+++ b/langchain4j-vearch/src/main/java/dev/langchain4j/store/embedding/vearch/VearchEmbeddingStore.java
@@ -56,44 +56,6 @@ public class VearchEmbeddingStore implements EmbeddingStore {
return new Builder();
}
- public static class Builder {
-
- private VearchConfig vearchConfig;
- private String baseUrl;
- private Duration timeout;
- private Boolean normalizeEmbeddings;
-
- public Builder vearchConfig(VearchConfig vearchConfig) {
- this.vearchConfig = vearchConfig;
- return this;
- }
-
- public Builder baseUrl(String baseUrl) {
- this.baseUrl = baseUrl;
- return this;
- }
-
- public Builder timeout(Duration timeout) {
- this.timeout = timeout;
- return this;
- }
-
- /**
- * Set whether to normalize embedding when add to embedding store
- *
- * @param normalizeEmbeddings whether to normalize embedding when add to embedding store
- * @return builder
- */
- public Builder normalizeEmbeddings(Boolean normalizeEmbeddings) {
- this.normalizeEmbeddings = normalizeEmbeddings;
- return this;
- }
-
- public VearchEmbeddingStore build() {
- return new VearchEmbeddingStore(baseUrl, timeout, vearchConfig, normalizeEmbeddings);
- }
- }
-
@Override
public String add(Embedding embedding) {
String id = randomUUID();
@@ -284,4 +246,42 @@ public class VearchEmbeddingStore implements EmbeddingStore {
throw new RuntimeException("Unsupported SpacePropertyParam type " + param.type);
}
}
+
+ public static class Builder {
+
+ private VearchConfig vearchConfig;
+ private String baseUrl;
+ private Duration timeout;
+ private Boolean normalizeEmbeddings;
+
+ public Builder vearchConfig(VearchConfig vearchConfig) {
+ this.vearchConfig = vearchConfig;
+ return this;
+ }
+
+ public Builder baseUrl(String baseUrl) {
+ this.baseUrl = baseUrl;
+ return this;
+ }
+
+ public Builder timeout(Duration timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+
+ /**
+ * Set whether to normalize embedding when add to embedding store
+ *
+ * @param normalizeEmbeddings whether to normalize embedding when add to embedding store
+ * @return builder
+ */
+ public Builder normalizeEmbeddings(Boolean normalizeEmbeddings) {
+ this.normalizeEmbeddings = normalizeEmbeddings;
+ return this;
+ }
+
+ public VearchEmbeddingStore build() {
+ return new VearchEmbeddingStore(baseUrl, timeout, vearchConfig, normalizeEmbeddings);
+ }
+ }
}
diff --git a/langchain4j-vearch/src/test/java/dev/langchain4j/store/embedding/vearch/DeleteSpaceLastOrderer.java b/langchain4j-vearch/src/test/java/dev/langchain4j/store/embedding/vearch/DeleteSpaceLastOrderer.java
deleted file mode 100644
index 109b1e2b4..000000000
--- a/langchain4j-vearch/src/test/java/dev/langchain4j/store/embedding/vearch/DeleteSpaceLastOrderer.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package dev.langchain4j.store.embedding.vearch;
-
-import org.junit.jupiter.api.MethodOrderer;
-import org.junit.jupiter.api.MethodOrdererContext;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class DeleteSpaceLastOrderer implements MethodOrderer {
- @Override
- public void orderMethods(MethodOrdererContext methodOrdererContext) {
- // should equal to VearchEmbeddingStoreIT#should_delete_space test name
- String deleteSpaceTestName = "should_delete_space";
- List methodNames = new ArrayList<>();
- methodOrdererContext.getMethodDescriptors().forEach(methodDescriptor -> methodNames.add(methodDescriptor.getMethod().getName()));
- methodNames.sort((methodName1, methodName2) -> {
- //
- if (methodName1.equals(deleteSpaceTestName)) {
- return 1;
- } else if (methodName2.equals(deleteSpaceTestName)) {
- return -1;
- } else {
- return 0;
- }
- });
- methodOrdererContext.getMethodDescriptors().sort((md1, md2) -> {
- int index1 = methodNames.indexOf(md1.getMethod().getName());
- int index2 = methodNames.indexOf(md2.getMethod().getName());
- return Integer.compare(index1, index2);
- });
- }
-}
diff --git a/langchain4j-vearch/src/test/java/dev/langchain4j/store/embedding/vearch/VearchEmbeddingStoreIT.java b/langchain4j-vearch/src/test/java/dev/langchain4j/store/embedding/vearch/VearchEmbeddingStoreIT.java
index b00b837d6..bacacc30f 100644
--- a/langchain4j-vearch/src/test/java/dev/langchain4j/store/embedding/vearch/VearchEmbeddingStoreIT.java
+++ b/langchain4j-vearch/src/test/java/dev/langchain4j/store/embedding/vearch/VearchEmbeddingStoreIT.java
@@ -3,10 +3,12 @@ package dev.langchain4j.store.embedding.vearch;
import dev.langchain4j.data.document.Metadata;
import dev.langchain4j.data.embedding.Embedding;
import dev.langchain4j.data.segment.TextSegment;
-import dev.langchain4j.model.embedding.onnx.allminilml6v2q.AllMiniLmL6V2QuantizedEmbeddingModel;
import dev.langchain4j.model.embedding.EmbeddingModel;
+import dev.langchain4j.model.embedding.onnx.allminilml6v2q.AllMiniLmL6V2QuantizedEmbeddingModel;
import dev.langchain4j.store.embedding.*;
-import org.junit.jupiter.api.*;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;