家居大模型联调,微信小程序联调
This commit is contained in:
@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -39,9 +40,11 @@ public class EnbedingModelConfig {
|
||||
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private EmbeddingModel embeddingModel;
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
RedisEmbeddingStore redisEmbeddingStore;
|
||||
/**
|
||||
* 创建向量数据库操作对象
|
||||
@@ -107,11 +110,13 @@ public class EnbedingModelConfig {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
public ContentRetriever contentRetriever(@Qualifier("myEmbeddingStoreInMemory")EmbeddingStore store){
|
||||
// 使用 @Lazy 注解延迟初始化,避免启动时连接阿里云
|
||||
// embeddingModel 也是 @Lazy 的,只有在实际使用 RAG 功能时才会初始化并连接
|
||||
EmbeddingStoreContentRetriever contentRetriever = EmbeddingStoreContentRetriever.builder()
|
||||
// .embeddingStore(redisEmbeddingStore)
|
||||
.embeddingStore( redisEmbeddingStore)
|
||||
.embeddingModel(embeddingModel)
|
||||
.embeddingStore(store)
|
||||
.embeddingModel(embeddingModel) // 保持 @Lazy,延迟初始化
|
||||
.minScore(0.5)//相似度
|
||||
.maxResults(3) //最多返回3条
|
||||
.build();
|
||||
|
||||
Reference in New Issue
Block a user