|
|
|
@ -1,22 +1,25 @@
|
|
|
|
|
package com.supervision.config;
|
|
|
|
|
|
|
|
|
|
import org.springframework.ai.vectorstore.RedisVectorStore;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
@EnableConfigurationProperties({RedisVectorProperties.class, EmbeddingProperties.class})
|
|
|
|
|
public class VectorSimilarityConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@SuppressWarnings("all")
|
|
|
|
|
@ConditionalOnProperty(prefix = "embedding", name = "url")
|
|
|
|
|
public VectorEmbeddingClient vectorEmbeddingClient(EmbeddingProperties embeddingProperties) {
|
|
|
|
|
Assert.notNull(embeddingProperties.getUrl(), "配置文件embedding:url未找到");
|
|
|
|
|
return new VectorEmbeddingClient(embeddingProperties.getUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@SuppressWarnings("all")
|
|
|
|
|
@ConditionalOnProperty(prefix = "vector.redis", name = "uri")
|
|
|
|
|
public RedisVectorStore redisVectorStore(VectorEmbeddingClient vectorEmbeddingClient, RedisVectorProperties redisVectorProperties) {
|
|
|
|
|
Assert.notNull(redisVectorProperties.getUri(), "配置文件vector.redis.uri未找到");
|
|
|
|
|
RedisVectorStore.RedisVectorStoreConfig config = RedisVectorStore.RedisVectorStoreConfig.builder()
|
|
|
|
|