家居大模型联调,微信小程序联调

This commit is contained in:
ZLI263
2025-11-23 22:35:14 +08:00
parent 64fb90c381
commit 108a838c31
2 changed files with 31 additions and 6 deletions

View File

@@ -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();

View File

@@ -25,6 +25,8 @@ langchain4j:
log-requests: true
log-responses: true
max-segments-per-batch: 10
# 禁用启动时的连接测试
enabled: true
# redis 向量数据库
community:
redis:
@@ -34,6 +36,8 @@ langchain4j:
logging:
level:
dev.langchain4j: DEBUG
dev.langchain4j.http.client.log: ERROR
dev.langchain4j.internal.RetryUtils: ERROR
# MyBatis Plus SQL日志
com.baomidou.mybatisplus: DEBUG
# MyBatis SQL日志
@@ -58,16 +62,32 @@ spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://124.221.59.58:3309/ai_smart_badge?useUnicode=true&characterEncoding=utf8
url: jdbc:mysql://101.35.52.237:13307/ai_smart_badge?useUnicode=true&characterEncoding=utf8
url: jdbc:mysql://101.35.52.237:13307/ai_smart_badge?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&autoReconnect=true&failOverReadOnly=false&maxReconnects=3&initialTimeout=2&connectTimeout=30000&socketTimeout=60000
username: root
password: cstcom.123!
# password: ChangAndb.123!
hikari:
# 连接池大小配置
maximumPoolSize: 10
minimumIdle: 5
idleTimeout: 300000
maxLifetime: 600000
# 连接超时配置(毫秒)
connectionTimeout: 30000 # 获取连接的超时时间30秒
validationTimeout: 5000 # 连接验证的超时时间5秒
# 连接生命周期配置(毫秒)
idleTimeout: 300000 # 空闲连接超时时间5分钟
maxLifetime: 1800000 # 连接最大生存时间30分钟建议小于MySQL wait_timeout
# 连接验证配置
connectionTestQuery: "SELECT 1"
# 连接泄漏检测(毫秒)- 如果连接超过此时间未归还,会记录警告
leakDetectionThreshold: 60000 # 60秒
# 保持连接活跃(毫秒)- 定期发送keepalive查询保持连接活跃
keepaliveTime: 300000 # 5分钟
# 连接池名称(便于监控和调试)
poolName: HikariPool-Main
# 连接初始化配置
initializationFailTimeout: 1 # 初始化失败时立即失败,不等待
# 是否允许连接池自动提交
autoCommit: true
output:
ansi:
enabled: always