Skip to content

Commit c4fccf5

Browse files
authored
Elasticsearch / Redis / Milvus: Remove lombok and small update for IT (#101)
<!-- Thank you so much for your contribution! Please fill in all the sections below. Please open the PR as a draft initially. Once it is reviewed and approved, we will ask you to add documentation and examples. Please note that PRs with breaking changes or without tests will be rejected. Please note that PRs will be reviewed based on the priority of the issues they address. We ask for your patience. We are doing our best to review your PR as quickly as possible. Please refrain from pinging and asking when it will be reviewed. Thank you for understanding! --> ## Issue <!-- Please specify the ID of the issue this PR is addressing. For example: "Closes #1234" or "Fixes #1234" --> Closes [langchain4j#2336](langchain4j/langchain4j#2336) ## Change <!-- Please describe the changes you made. --> 1. Remove `lombok` in Elasticsearch / Redis / Milvus 2. Configure `maven-source-plugin:test-jar-no-fork` for `langchain4j-spring-boot-tests`, in order to see test source in community repo. 3. Redis: update `prefix` parameter introducing in [this PR](langchain4j/langchain4j#1981) ## General checklist <!-- Please double-check the following points and mark them like this: [X] --> - [x] There are no breaking changes - [ ] I have added unit and/or integration tests for my change - [ ] The tests cover both positive and negative cases - [x] I have manually run all the unit and integration tests in the module I have added/changed, and they are all green <!-- Before adding documentation and example(s) (below), please wait until the PR is reviewed and approved. --> - [ ] I have added/updated the [documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs) - [ ] I have added an example in the [examples repo](https://github.com/langchain4j/langchain4j-examples) (only for "big" features)
1 parent 38346a6 commit c4fccf5

File tree

12 files changed

+302
-75
lines changed

12 files changed

+302
-75
lines changed

langchain4j-elasticsearch-spring-boot-starter/pom.xml

-7
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@
5252
<optional>true</optional>
5353
</dependency>
5454

55-
<!-- should be listed before spring-boot-configuration-processor -->
56-
<dependency>
57-
<groupId>org.projectlombok</groupId>
58-
<artifactId>lombok</artifactId>
59-
<scope>provided</scope>
60-
</dependency>
61-
6255
<!-- needed to generate automatic metadata about available config properties -->
6356
<dependency>
6457
<groupId>org.springframework.boot</groupId>

langchain4j-elasticsearch-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/elasticsearch/spring/ElasticsearchEmbeddingStoreProperties.java

+56-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package dev.langchain4j.store.embedding.elasticsearch.spring;
22

3-
import lombok.Getter;
4-
import lombok.Setter;
53
import org.springframework.boot.context.properties.ConfigurationProperties;
64

7-
@Getter
8-
@Setter
95
@ConfigurationProperties(prefix = ElasticsearchEmbeddingStoreProperties.PREFIX)
106
public class ElasticsearchEmbeddingStoreProperties {
117

@@ -21,4 +17,60 @@ public class ElasticsearchEmbeddingStoreProperties {
2117
private String indexName;
2218
private Boolean checkSslCertificates;
2319
private String caCertificateAsBase64String;
20+
21+
public String getServerUrl() {
22+
return serverUrl;
23+
}
24+
25+
public void setServerUrl(String serverUrl) {
26+
this.serverUrl = serverUrl;
27+
}
28+
29+
public String getApiKey() {
30+
return apiKey;
31+
}
32+
33+
public void setApiKey(String apiKey) {
34+
this.apiKey = apiKey;
35+
}
36+
37+
public String getUsername() {
38+
return username;
39+
}
40+
41+
public void setUsername(String username) {
42+
this.username = username;
43+
}
44+
45+
public String getPassword() {
46+
return password;
47+
}
48+
49+
public void setPassword(String password) {
50+
this.password = password;
51+
}
52+
53+
public String getIndexName() {
54+
return indexName;
55+
}
56+
57+
public void setIndexName(String indexName) {
58+
this.indexName = indexName;
59+
}
60+
61+
public Boolean getCheckSslCertificates() {
62+
return checkSslCertificates;
63+
}
64+
65+
public void setCheckSslCertificates(Boolean checkSslCertificates) {
66+
this.checkSslCertificates = checkSslCertificates;
67+
}
68+
69+
public String getCaCertificateAsBase64String() {
70+
return caCertificateAsBase64String;
71+
}
72+
73+
public void setCaCertificateAsBase64String(String caCertificateAsBase64String) {
74+
this.caCertificateAsBase64String = caCertificateAsBase64String;
75+
}
2476
}

langchain4j-elasticsearch-spring-boot-starter/src/test/java/dev/langchain4j/store/embedding/elasticsearch/spring/ElasticsearchEmbeddingStoreAutoConfigurationIT.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import dev.langchain4j.store.embedding.EmbeddingStore;
55
import dev.langchain4j.store.embedding.elasticsearch.ElasticsearchEmbeddingStore;
66
import dev.langchain4j.store.embedding.spring.EmbeddingStoreAutoConfigurationIT;
7-
import lombok.SneakyThrows;
87
import org.elasticsearch.client.Request;
98
import org.elasticsearch.client.RestClient;
109
import org.junit.jupiter.api.AfterAll;
@@ -65,9 +64,12 @@ protected String dimensionPropertyKey() {
6564
}
6665

6766
@Override
68-
@SneakyThrows
6967
protected void awaitUntilPersisted(ApplicationContext context) {
70-
RestClient restClient = context.getBean(RestClient.class);
71-
restClient.performRequest(new Request("POST", "/" + indexName + "/_refresh"));
68+
try {
69+
RestClient restClient = context.getBean(RestClient.class);
70+
restClient.performRequest(new Request("POST", "/" + indexName + "/_refresh"));
71+
} catch (IOException e) {
72+
throw new RuntimeException(e);
73+
}
7274
}
7375
}

langchain4j-milvus-spring-boot-starter/pom.xml

-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@
3232
<optional>true</optional>
3333
</dependency>
3434

35-
<!-- should be listed before spring-boot-configuration-processor -->
36-
<dependency>
37-
<groupId>org.projectlombok</groupId>
38-
<artifactId>lombok</artifactId>
39-
<scope>provided</scope>
40-
</dependency>
41-
4235
<!-- needed to generate automatic metadata about available config properties -->
4336
<dependency>
4437
<groupId>org.springframework.boot</groupId>

langchain4j-milvus-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/milvus/spring/MilvusEmbeddingStoreProperties.java

+112-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
import io.milvus.common.clientenum.ConsistencyLevelEnum;
44
import io.milvus.param.IndexType;
55
import io.milvus.param.MetricType;
6-
import lombok.Getter;
7-
import lombok.Setter;
86
import org.springframework.boot.context.properties.ConfigurationProperties;
97

108
import static io.milvus.common.clientenum.ConsistencyLevelEnum.STRONG;
119

12-
@Getter
13-
@Setter
1410
@ConfigurationProperties(prefix = MilvusEmbeddingStoreProperties.PREFIX)
1511
public class MilvusEmbeddingStoreProperties {
1612

@@ -34,4 +30,116 @@ public class MilvusEmbeddingStoreProperties {
3430
private Boolean retrieveEmbeddingsOnSearch;
3531
private Boolean autoFlushOnInsert;
3632
private String databaseName;
33+
34+
public String getHost() {
35+
return host;
36+
}
37+
38+
public void setHost(String host) {
39+
this.host = host;
40+
}
41+
42+
public Integer getPort() {
43+
return port;
44+
}
45+
46+
public void setPort(Integer port) {
47+
this.port = port;
48+
}
49+
50+
public String getCollectionName() {
51+
return collectionName;
52+
}
53+
54+
public void setCollectionName(String collectionName) {
55+
this.collectionName = collectionName;
56+
}
57+
58+
public Integer getDimension() {
59+
return dimension;
60+
}
61+
62+
public void setDimension(Integer dimension) {
63+
this.dimension = dimension;
64+
}
65+
66+
public IndexType getIndexType() {
67+
return indexType;
68+
}
69+
70+
public void setIndexType(IndexType indexType) {
71+
this.indexType = indexType;
72+
}
73+
74+
public MetricType getMetricType() {
75+
return metricType;
76+
}
77+
78+
public void setMetricType(MetricType metricType) {
79+
this.metricType = metricType;
80+
}
81+
82+
public String getUri() {
83+
return uri;
84+
}
85+
86+
public void setUri(String uri) {
87+
this.uri = uri;
88+
}
89+
90+
public String getToken() {
91+
return token;
92+
}
93+
94+
public void setToken(String token) {
95+
this.token = token;
96+
}
97+
98+
public String getUsername() {
99+
return username;
100+
}
101+
102+
public void setUsername(String username) {
103+
this.username = username;
104+
}
105+
106+
public String getPassword() {
107+
return password;
108+
}
109+
110+
public void setPassword(String password) {
111+
this.password = password;
112+
}
113+
114+
public ConsistencyLevelEnum getConsistencyLevel() {
115+
return consistencyLevel;
116+
}
117+
118+
public void setConsistencyLevel(ConsistencyLevelEnum consistencyLevel) {
119+
this.consistencyLevel = consistencyLevel;
120+
}
121+
122+
public Boolean getRetrieveEmbeddingsOnSearch() {
123+
return retrieveEmbeddingsOnSearch;
124+
}
125+
126+
public void setRetrieveEmbeddingsOnSearch(Boolean retrieveEmbeddingsOnSearch) {
127+
this.retrieveEmbeddingsOnSearch = retrieveEmbeddingsOnSearch;
128+
}
129+
130+
public Boolean getAutoFlushOnInsert() {
131+
return autoFlushOnInsert;
132+
}
133+
134+
public void setAutoFlushOnInsert(Boolean autoFlushOnInsert) {
135+
this.autoFlushOnInsert = autoFlushOnInsert;
136+
}
137+
138+
public String getDatabaseName() {
139+
return databaseName;
140+
}
141+
142+
public void setDatabaseName(String databaseName) {
143+
this.databaseName = databaseName;
144+
}
37145
}

langchain4j-milvus-spring-boot-starter/src/test/java/MilvusEmbeddingStoreAutoConfigurationIT.java

+10-19
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import dev.langchain4j.data.segment.TextSegment;
2-
import dev.langchain4j.model.embedding.onnx.allminilml6v2q.AllMiniLmL6V2QuantizedEmbeddingModel;
32
import dev.langchain4j.store.embedding.EmbeddingStore;
43
import dev.langchain4j.store.embedding.milvus.MilvusEmbeddingStore;
54
import dev.langchain4j.store.embedding.milvus.spring.MilvusEmbeddingStoreAutoConfiguration;
65
import dev.langchain4j.store.embedding.spring.EmbeddingStoreAutoConfigurationIT;
76
import org.junit.jupiter.api.AfterAll;
87
import org.junit.jupiter.api.BeforeAll;
98
import org.junit.jupiter.api.BeforeEach;
10-
import org.springframework.boot.autoconfigure.AutoConfigurations;
11-
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
129
import org.testcontainers.milvus.MilvusContainer;
1310

11+
import static dev.langchain4j.internal.Utils.randomUUID;
12+
1413
class MilvusEmbeddingStoreAutoConfigurationIT extends EmbeddingStoreAutoConfigurationIT {
1514

1615
static MilvusContainer milvus = new MilvusContainer("milvusdb/milvus:v2.3.16");
17-
static final String COLLECTION_NAME = "test_collection";
16+
17+
String collectionName;
18+
19+
@BeforeEach
20+
void setCollectionName() {
21+
collectionName = "langchain4j" + randomUUID().replace("-", "_");
22+
}
1823

1924
@BeforeAll
2025
static void beforeAll() {
@@ -26,20 +31,6 @@ static void afterAll() {
2631
milvus.stop();
2732
}
2833

29-
@BeforeEach
30-
void beforeEach() {
31-
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
32-
.withConfiguration(AutoConfigurations.of(autoConfigurationClass()));
33-
34-
contextRunner
35-
.withBean(AllMiniLmL6V2QuantizedEmbeddingModel.class)
36-
.withPropertyValues(properties())
37-
.run(context -> {
38-
MilvusEmbeddingStore embeddingStore = context.getBean(MilvusEmbeddingStore.class);
39-
embeddingStore.dropCollection(COLLECTION_NAME);
40-
});
41-
}
42-
4334
@Override
4435
protected Class<?> autoConfigurationClass() {
4536
return MilvusEmbeddingStoreAutoConfiguration.class;
@@ -55,7 +46,7 @@ protected String[] properties() {
5546
return new String[]{
5647
"langchain4j.milvus.host=" + milvus.getHost(),
5748
"langchain4j.milvus.port=" + milvus.getMappedPort(19530),
58-
"langchain4j.milvus.collectionName=" + COLLECTION_NAME,
49+
"langchain4j.milvus.collectionName=" + collectionName,
5950
"langchain4j.milvus.retrieveEmbeddingsOnSearch=true"
6051
};
6152
}

langchain4j-redis-spring-boot-starter/pom.xml

+2-9
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@
3232
<optional>true</optional>
3333
</dependency>
3434

35-
<!-- should be listed before spring-boot-configuration-processor -->
36-
<dependency>
37-
<groupId>org.projectlombok</groupId>
38-
<artifactId>lombok</artifactId>
39-
<scope>provided</scope>
40-
</dependency>
41-
4235
<!-- needed to generate automatic metadata about available config properties -->
4336
<dependency>
4437
<groupId>org.springframework.boot</groupId>
@@ -68,9 +61,9 @@
6861
</dependency>
6962

7063
<dependency>
71-
<groupId>com.redis.testcontainers</groupId>
64+
<groupId>com.redis</groupId>
7265
<artifactId>testcontainers-redis</artifactId>
73-
<version>1.6.4</version>
66+
<version>2.2.2</version>
7467
<scope>test</scope>
7568
</dependency>
7669

langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfiguration.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
import java.util.List;
1414
import java.util.Optional;
1515

16-
import static dev.langchain4j.store.embedding.redis.spring.RedisEmbeddingStoreProperties.PREFIX;
16+
import static dev.langchain4j.store.embedding.redis.spring.RedisEmbeddingStoreProperties.CONFIG_PREFIX;
1717

1818
@AutoConfiguration
1919
@EnableConfigurationProperties(RedisEmbeddingStoreProperties.class)
20-
@ConditionalOnProperty(prefix = PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true)
20+
@ConditionalOnProperty(prefix = CONFIG_PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true)
2121
public class RedisEmbeddingStoreAutoConfiguration {
2222

2323
private static final String DEFAULT_HOST = "localhost";
@@ -39,6 +39,7 @@ public RedisEmbeddingStore redisEmbeddingStore(RedisEmbeddingStoreProperties pro
3939
.port(port)
4040
.user(properties.getUser())
4141
.password(properties.getPassword())
42+
.prefix(properties.getPrefix())
4243
.indexName(indexName)
4344
.dimension(dimension)
4445
.metadataKeys(metadataKeys)

0 commit comments

Comments
 (0)