From 7c911397244cf5433cc19e39c8d3f14fac890f16 Mon Sep 17 00:00:00 2001 From: Martin7-1 Date: Thu, 26 Dec 2024 14:33:53 +0800 Subject: [PATCH 1/2] remove lombok and add spring-boot-tests test-jar --- .../pom.xml | 7 -- ...ElasticsearchEmbeddingStoreProperties.java | 60 ++++++++- ...archEmbeddingStoreAutoConfigurationIT.java | 10 +- .../pom.xml | 7 -- .../MilvusEmbeddingStoreProperties.java | 116 +++++++++++++++++- ...lvusEmbeddingStoreAutoConfigurationIT.java | 29 ++--- langchain4j-redis-spring-boot-starter/pom.xml | 11 +- .../RedisEmbeddingStoreAutoConfiguration.java | 6 +- .../spring/RedisEmbeddingStoreProperties.java | 74 +++++++++-- ...edisEmbeddingStoreAutoConfigurationIT.java | 20 +-- langchain4j-spring-boot-tests/pom.xml | 16 +++ .../EmbeddingStoreAutoConfigurationIT.java | 22 +++- 12 files changed, 303 insertions(+), 75 deletions(-) diff --git a/langchain4j-elasticsearch-spring-boot-starter/pom.xml b/langchain4j-elasticsearch-spring-boot-starter/pom.xml index 310691ab..85d53e48 100644 --- a/langchain4j-elasticsearch-spring-boot-starter/pom.xml +++ b/langchain4j-elasticsearch-spring-boot-starter/pom.xml @@ -52,13 +52,6 @@ true - - - org.projectlombok - lombok - provided - - org.springframework.boot diff --git a/langchain4j-elasticsearch-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/elasticsearch/spring/ElasticsearchEmbeddingStoreProperties.java b/langchain4j-elasticsearch-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/elasticsearch/spring/ElasticsearchEmbeddingStoreProperties.java index fd58bfb8..766abb50 100644 --- a/langchain4j-elasticsearch-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/elasticsearch/spring/ElasticsearchEmbeddingStoreProperties.java +++ b/langchain4j-elasticsearch-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/elasticsearch/spring/ElasticsearchEmbeddingStoreProperties.java @@ -1,11 +1,7 @@ package dev.langchain4j.store.embedding.elasticsearch.spring; -import lombok.Getter; -import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; -@Getter -@Setter @ConfigurationProperties(prefix = ElasticsearchEmbeddingStoreProperties.PREFIX) public class ElasticsearchEmbeddingStoreProperties { @@ -21,4 +17,60 @@ public class ElasticsearchEmbeddingStoreProperties { private String indexName; private Boolean checkSslCertificates; private String caCertificateAsBase64String; + + public String getServerUrl() { + return serverUrl; + } + + public void setServerUrl(String serverUrl) { + this.serverUrl = serverUrl; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getIndexName() { + return indexName; + } + + public void setIndexName(String indexName) { + this.indexName = indexName; + } + + public Boolean getCheckSslCertificates() { + return checkSslCertificates; + } + + public void setCheckSslCertificates(Boolean checkSslCertificates) { + this.checkSslCertificates = checkSslCertificates; + } + + public String getCaCertificateAsBase64String() { + return caCertificateAsBase64String; + } + + public void setCaCertificateAsBase64String(String caCertificateAsBase64String) { + this.caCertificateAsBase64String = caCertificateAsBase64String; + } } diff --git a/langchain4j-elasticsearch-spring-boot-starter/src/test/java/dev/langchain4j/store/embedding/elasticsearch/spring/ElasticsearchEmbeddingStoreAutoConfigurationIT.java b/langchain4j-elasticsearch-spring-boot-starter/src/test/java/dev/langchain4j/store/embedding/elasticsearch/spring/ElasticsearchEmbeddingStoreAutoConfigurationIT.java index 651fe229..eebc7103 100644 --- a/langchain4j-elasticsearch-spring-boot-starter/src/test/java/dev/langchain4j/store/embedding/elasticsearch/spring/ElasticsearchEmbeddingStoreAutoConfigurationIT.java +++ b/langchain4j-elasticsearch-spring-boot-starter/src/test/java/dev/langchain4j/store/embedding/elasticsearch/spring/ElasticsearchEmbeddingStoreAutoConfigurationIT.java @@ -4,7 +4,6 @@ import dev.langchain4j.store.embedding.EmbeddingStore; import dev.langchain4j.store.embedding.elasticsearch.ElasticsearchEmbeddingStore; import dev.langchain4j.store.embedding.spring.EmbeddingStoreAutoConfigurationIT; -import lombok.SneakyThrows; import org.elasticsearch.client.Request; import org.elasticsearch.client.RestClient; import org.junit.jupiter.api.AfterAll; @@ -65,9 +64,12 @@ protected String dimensionPropertyKey() { } @Override - @SneakyThrows protected void awaitUntilPersisted(ApplicationContext context) { - RestClient restClient = context.getBean(RestClient.class); - restClient.performRequest(new Request("POST", "/" + indexName + "/_refresh")); + try { + RestClient restClient = context.getBean(RestClient.class); + restClient.performRequest(new Request("POST", "/" + indexName + "/_refresh")); + } catch (IOException e) { + throw new RuntimeException(e); + } } } diff --git a/langchain4j-milvus-spring-boot-starter/pom.xml b/langchain4j-milvus-spring-boot-starter/pom.xml index f8c551f0..90d8251a 100644 --- a/langchain4j-milvus-spring-boot-starter/pom.xml +++ b/langchain4j-milvus-spring-boot-starter/pom.xml @@ -32,13 +32,6 @@ true - - - org.projectlombok - lombok - provided - - org.springframework.boot diff --git a/langchain4j-milvus-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/milvus/spring/MilvusEmbeddingStoreProperties.java b/langchain4j-milvus-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/milvus/spring/MilvusEmbeddingStoreProperties.java index 9bc4703b..536a1054 100644 --- a/langchain4j-milvus-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/milvus/spring/MilvusEmbeddingStoreProperties.java +++ b/langchain4j-milvus-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/milvus/spring/MilvusEmbeddingStoreProperties.java @@ -3,14 +3,10 @@ import io.milvus.common.clientenum.ConsistencyLevelEnum; import io.milvus.param.IndexType; import io.milvus.param.MetricType; -import lombok.Getter; -import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; import static io.milvus.common.clientenum.ConsistencyLevelEnum.STRONG; -@Getter -@Setter @ConfigurationProperties(prefix = MilvusEmbeddingStoreProperties.PREFIX) public class MilvusEmbeddingStoreProperties { @@ -34,4 +30,116 @@ public class MilvusEmbeddingStoreProperties { private Boolean retrieveEmbeddingsOnSearch; private Boolean autoFlushOnInsert; private String databaseName; + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public String getCollectionName() { + return collectionName; + } + + public void setCollectionName(String collectionName) { + this.collectionName = collectionName; + } + + public Integer getDimension() { + return dimension; + } + + public void setDimension(Integer dimension) { + this.dimension = dimension; + } + + public IndexType getIndexType() { + return indexType; + } + + public void setIndexType(IndexType indexType) { + this.indexType = indexType; + } + + public MetricType getMetricType() { + return metricType; + } + + public void setMetricType(MetricType metricType) { + this.metricType = metricType; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public ConsistencyLevelEnum getConsistencyLevel() { + return consistencyLevel; + } + + public void setConsistencyLevel(ConsistencyLevelEnum consistencyLevel) { + this.consistencyLevel = consistencyLevel; + } + + public Boolean getRetrieveEmbeddingsOnSearch() { + return retrieveEmbeddingsOnSearch; + } + + public void setRetrieveEmbeddingsOnSearch(Boolean retrieveEmbeddingsOnSearch) { + this.retrieveEmbeddingsOnSearch = retrieveEmbeddingsOnSearch; + } + + public Boolean getAutoFlushOnInsert() { + return autoFlushOnInsert; + } + + public void setAutoFlushOnInsert(Boolean autoFlushOnInsert) { + this.autoFlushOnInsert = autoFlushOnInsert; + } + + public String getDatabaseName() { + return databaseName; + } + + public void setDatabaseName(String databaseName) { + this.databaseName = databaseName; + } } diff --git a/langchain4j-milvus-spring-boot-starter/src/test/java/MilvusEmbeddingStoreAutoConfigurationIT.java b/langchain4j-milvus-spring-boot-starter/src/test/java/MilvusEmbeddingStoreAutoConfigurationIT.java index cf63eef0..9ba25d53 100644 --- a/langchain4j-milvus-spring-boot-starter/src/test/java/MilvusEmbeddingStoreAutoConfigurationIT.java +++ b/langchain4j-milvus-spring-boot-starter/src/test/java/MilvusEmbeddingStoreAutoConfigurationIT.java @@ -1,5 +1,4 @@ import dev.langchain4j.data.segment.TextSegment; -import dev.langchain4j.model.embedding.onnx.allminilml6v2q.AllMiniLmL6V2QuantizedEmbeddingModel; import dev.langchain4j.store.embedding.EmbeddingStore; import dev.langchain4j.store.embedding.milvus.MilvusEmbeddingStore; import dev.langchain4j.store.embedding.milvus.spring.MilvusEmbeddingStoreAutoConfiguration; @@ -7,14 +6,20 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.testcontainers.milvus.MilvusContainer; +import static dev.langchain4j.internal.Utils.randomUUID; + class MilvusEmbeddingStoreAutoConfigurationIT extends EmbeddingStoreAutoConfigurationIT { static MilvusContainer milvus = new MilvusContainer("milvusdb/milvus:v2.3.16"); - static final String COLLECTION_NAME = "test_collection"; + + String collectionName; + + @BeforeEach + void setCollectionName() { + collectionName = "langchain4j" + randomUUID().replace("-", "_"); + } @BeforeAll static void beforeAll() { @@ -26,20 +31,6 @@ static void afterAll() { milvus.stop(); } - @BeforeEach - void beforeEach() { - ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(autoConfigurationClass())); - - contextRunner - .withBean(AllMiniLmL6V2QuantizedEmbeddingModel.class) - .withPropertyValues(properties()) - .run(context -> { - MilvusEmbeddingStore embeddingStore = context.getBean(MilvusEmbeddingStore.class); - embeddingStore.dropCollection(COLLECTION_NAME); - }); - } - @Override protected Class autoConfigurationClass() { return MilvusEmbeddingStoreAutoConfiguration.class; @@ -55,7 +46,7 @@ protected String[] properties() { return new String[]{ "langchain4j.milvus.host=" + milvus.getHost(), "langchain4j.milvus.port=" + milvus.getMappedPort(19530), - "langchain4j.milvus.collectionName=" + COLLECTION_NAME, + "langchain4j.milvus.collectionName=" + collectionName, "langchain4j.milvus.retrieveEmbeddingsOnSearch=true" }; } diff --git a/langchain4j-redis-spring-boot-starter/pom.xml b/langchain4j-redis-spring-boot-starter/pom.xml index 12485537..280633cf 100644 --- a/langchain4j-redis-spring-boot-starter/pom.xml +++ b/langchain4j-redis-spring-boot-starter/pom.xml @@ -32,13 +32,6 @@ true - - - org.projectlombok - lombok - provided - - org.springframework.boot @@ -68,9 +61,9 @@ - com.redis.testcontainers + com.redis testcontainers-redis - 1.6.4 + 2.2.2 test diff --git a/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfiguration.java b/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfiguration.java index bff93acc..ee3c89c8 100644 --- a/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfiguration.java +++ b/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfiguration.java @@ -13,11 +13,11 @@ import java.util.List; import java.util.Optional; -import static dev.langchain4j.store.embedding.redis.spring.RedisEmbeddingStoreProperties.PREFIX; +import static dev.langchain4j.store.embedding.redis.spring.RedisEmbeddingStoreProperties.CONFIG_PREFIX; @AutoConfiguration @EnableConfigurationProperties(RedisEmbeddingStoreProperties.class) -@ConditionalOnProperty(prefix = PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true) +@ConditionalOnProperty(prefix = CONFIG_PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true) public class RedisEmbeddingStoreAutoConfiguration { private static final String DEFAULT_HOST = "localhost"; @@ -30,6 +30,7 @@ public RedisEmbeddingStore redisEmbeddingStore(RedisEmbeddingStoreProperties pro @Nullable EmbeddingModel embeddingModel) { String host = Optional.ofNullable(properties.getHost()).orElse(DEFAULT_HOST); int port = Optional.ofNullable(properties.getPort()).orElse(DEFAULT_PORT); + String prefix = Optional.ofNullable(properties.getPrefix()).orElse(DEFAULT_INDEX_NAME + ":"); String indexName = Optional.ofNullable(properties.getIndexName()).orElse(DEFAULT_INDEX_NAME); Integer dimension = Optional.ofNullable(properties.getDimension()).orElseGet(() -> embeddingModel == null ? null : embeddingModel.dimension()); List metadataKeys = Optional.ofNullable(properties.getMetadataKeys()).orElse(new ArrayList<>()); @@ -39,6 +40,7 @@ public RedisEmbeddingStore redisEmbeddingStore(RedisEmbeddingStoreProperties pro .port(port) .user(properties.getUser()) .password(properties.getPassword()) + .prefix(prefix) .indexName(indexName) .dimension(dimension) .metadataKeys(metadataKeys) diff --git a/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreProperties.java b/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreProperties.java index daf07961..4783fb86 100644 --- a/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreProperties.java +++ b/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreProperties.java @@ -1,24 +1,84 @@ package dev.langchain4j.store.embedding.redis.spring; -import lombok.Getter; -import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; -import java.util.ArrayList; import java.util.List; -@ConfigurationProperties(prefix = RedisEmbeddingStoreProperties.PREFIX) -@Getter -@Setter +@ConfigurationProperties(prefix = RedisEmbeddingStoreProperties.CONFIG_PREFIX) public class RedisEmbeddingStoreProperties { - static final String PREFIX = "langchain4j.redis"; + static final String CONFIG_PREFIX = "langchain4j.redis"; private String host; private Integer port; private String user; private String password; private String indexName; + private String prefix; private Integer dimension; private List metadataKeys; + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getIndexName() { + return indexName; + } + + public void setIndexName(String indexName) { + this.indexName = indexName; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public Integer getDimension() { + return dimension; + } + + public void setDimension(Integer dimension) { + this.dimension = dimension; + } + + public List getMetadataKeys() { + return metadataKeys; + } + + public void setMetadataKeys(List metadataKeys) { + this.metadataKeys = metadataKeys; + } } diff --git a/langchain4j-redis-spring-boot-starter/src/test/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfigurationIT.java b/langchain4j-redis-spring-boot-starter/src/test/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfigurationIT.java index aa05e4a2..feed852f 100644 --- a/langchain4j-redis-spring-boot-starter/src/test/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfigurationIT.java +++ b/langchain4j-redis-spring-boot-starter/src/test/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfigurationIT.java @@ -1,6 +1,6 @@ package dev.langchain4j.store.embedding.redis.spring; -import com.redis.testcontainers.RedisContainer; +import com.redis.testcontainers.RedisStackContainer; import dev.langchain4j.data.segment.TextSegment; import dev.langchain4j.store.embedding.EmbeddingStore; import dev.langchain4j.store.embedding.redis.RedisEmbeddingStore; @@ -8,16 +8,16 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.testcontainers.containers.wait.strategy.Wait; -import redis.clients.jedis.JedisPooled; import static com.redis.testcontainers.RedisStackContainer.DEFAULT_IMAGE_NAME; import static com.redis.testcontainers.RedisStackContainer.DEFAULT_TAG; +import static dev.langchain4j.internal.Utils.randomUUID; class RedisEmbeddingStoreAutoConfigurationIT extends EmbeddingStoreAutoConfigurationIT { - static RedisContainer redis = new RedisContainer(DEFAULT_IMAGE_NAME.withTag(DEFAULT_TAG)) - .waitingFor(Wait.defaultWaitStrategy()); + static RedisStackContainer redis = new RedisStackContainer(DEFAULT_IMAGE_NAME.withTag(DEFAULT_TAG)); + + String indexName; @BeforeAll static void beforeAll() { @@ -30,10 +30,8 @@ static void afterAll() { } @BeforeEach - void beforeEach() { - try (JedisPooled jedis = new JedisPooled(redis.getHost(), redis.getFirstMappedPort())) { - jedis.flushDB(); // TODO fix: why redis returns embeddings from different indexes? - } + void setIndexName() { + indexName = randomUUID(); } @Override @@ -50,7 +48,9 @@ protected Class> embeddingStoreClass() { protected String[] properties() { return new String[]{ "langchain4j.redis.host=" + redis.getHost(), - "langchain4j.redis.port=" + redis.getFirstMappedPort() + "langchain4j.redis.port=" + redis.getFirstMappedPort(), + "langchain4j.redis.prefix=" + indexName + ":", + "langchain4j.redis.index-name=" + indexName }; } diff --git a/langchain4j-spring-boot-tests/pom.xml b/langchain4j-spring-boot-tests/pom.xml index 2e2afe8d..dfccb648 100644 --- a/langchain4j-spring-boot-tests/pom.xml +++ b/langchain4j-spring-boot-tests/pom.xml @@ -49,6 +49,22 @@ + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + test-jar-no-fork + + + + diff --git a/langchain4j-spring-boot-tests/src/test/java/dev/langchain4j/store/embedding/spring/EmbeddingStoreAutoConfigurationIT.java b/langchain4j-spring-boot-tests/src/test/java/dev/langchain4j/store/embedding/spring/EmbeddingStoreAutoConfigurationIT.java index 6b7950f4..ee8301e5 100644 --- a/langchain4j-spring-boot-tests/src/test/java/dev/langchain4j/store/embedding/spring/EmbeddingStoreAutoConfigurationIT.java +++ b/langchain4j-spring-boot-tests/src/test/java/dev/langchain4j/store/embedding/spring/EmbeddingStoreAutoConfigurationIT.java @@ -2,9 +2,11 @@ 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.EmbeddingMatch; +import dev.langchain4j.store.embedding.EmbeddingSearchRequest; +import dev.langchain4j.store.embedding.EmbeddingSearchResult; import dev.langchain4j.store.embedding.EmbeddingStore; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; @@ -31,7 +33,10 @@ public abstract class EmbeddingStoreAutoConfigurationIT { */ protected abstract String dimensionPropertyKey(); - ApplicationContextRunner contextRunner = new ApplicationContextRunner() + /** + * Inherited IT can reuse this contextRunner for additional test. + */ + protected ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(autoConfigurationClass())); @Test @@ -93,6 +98,19 @@ void should_provide_embedding_store_with_embedding_model() { assertThat(match.embeddingId()).isEqualTo(id); assertThat(match.embedding()).isEqualTo(embedding); assertThat(match.embedded()).isEqualTo(segment); + + // New API + EmbeddingSearchResult searchResult = embeddingStore.search(EmbeddingSearchRequest.builder() + .queryEmbedding(embedding) + .maxResults(10) + .build()); + + assertThat(searchResult.matches()).hasSize(1); + match = searchResult.matches().get(0); + assertThat(match.score()).isCloseTo(1, withPercentage(1)); + assertThat(match.embeddingId()).isEqualTo(id); + assertThat(match.embedding()).isEqualTo(embedding); + assertThat(match.embedded()).isEqualTo(segment); }); } From 2b4230118a023a31493c9650dd219d4a9ef4805d Mon Sep 17 00:00:00 2001 From: Martin7-1 Date: Fri, 3 Jan 2025 00:50:49 +0800 Subject: [PATCH 2/2] remove prefix default value in spring-boot-starter --- .../redis/spring/RedisEmbeddingStoreAutoConfiguration.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfiguration.java b/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfiguration.java index ee3c89c8..57d41794 100644 --- a/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfiguration.java +++ b/langchain4j-redis-spring-boot-starter/src/main/java/dev/langchain4j/store/embedding/redis/spring/RedisEmbeddingStoreAutoConfiguration.java @@ -30,7 +30,6 @@ public RedisEmbeddingStore redisEmbeddingStore(RedisEmbeddingStoreProperties pro @Nullable EmbeddingModel embeddingModel) { String host = Optional.ofNullable(properties.getHost()).orElse(DEFAULT_HOST); int port = Optional.ofNullable(properties.getPort()).orElse(DEFAULT_PORT); - String prefix = Optional.ofNullable(properties.getPrefix()).orElse(DEFAULT_INDEX_NAME + ":"); String indexName = Optional.ofNullable(properties.getIndexName()).orElse(DEFAULT_INDEX_NAME); Integer dimension = Optional.ofNullable(properties.getDimension()).orElseGet(() -> embeddingModel == null ? null : embeddingModel.dimension()); List metadataKeys = Optional.ofNullable(properties.getMetadataKeys()).orElse(new ArrayList<>()); @@ -40,7 +39,7 @@ public RedisEmbeddingStore redisEmbeddingStore(RedisEmbeddingStoreProperties pro .port(port) .user(properties.getUser()) .password(properties.getPassword()) - .prefix(prefix) + .prefix(properties.getPrefix()) .indexName(indexName) .dimension(dimension) .metadataKeys(metadataKeys)