Files
han-ai-robot-backend/src/main/resources/application.yml
Hanserwei 59eb69747b feat(ai): 实现对话记忆与消息持久化功能
- 移除 Cassandra 相关配置及依赖
- 新增 CustomChatMemoryAdvisor 实现对话记忆管理
-重命名并扩展 CustomStreamLoggerAdvisor 为 CustomStreamLoggerAndMessage2DBAdvisor,增加消息入库逻辑
- 在 ChatController 中集成新的 Advisor 并注入相关依赖
- 使用 TransactionTemplate 管理消息存储事务
-限制记忆消息数量为最新 50 条
- 支持将用户消息与 AI 回答同步写入数据库
2025-11-03 16:31:19 +08:00

43 lines
1.6 KiB
YAML

#file: noinspection SpringBootConfigYamlInspection
spring:
application:
name: han-ai-robot-springboot
datasource:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver # 数据库驱动类名
url: jdbc:p6spy:postgresql://localhost:5432/han_ai_robot # 数据库连接 URL
username: postgres # 数据库用户名
password: postgressql # 数据库密码
hikari: # HikariCP 连接池配置
pool-name: AI-Robot-HikariCP # 自定义连接池名称
auto-commit: true # 是否自动提交事务
connection-timeout: 30000 # 连接超时时间(毫秒)
idle-timeout: 600000 # 空闲连接存活最大时间(毫秒)
max-lifetime: 1800000 # 连接最大存活时间(毫秒)
minimum-idle: 5 # 最小空闲连接数
maximum-pool-size: 20 # 最大连接池大小
connection-test-query: SELECT 1 # 连接测试查询
validation-timeout: 5000 # 验证连接的有效性
ai:
dashscope:
api-key: ENC(cMgcKZkFllyE88DIbGwLKot9Vg02co+gsmY8L8o4/o3UjhcmqO4lJzFU35Sx0n+qFG8pDL0wBjoWrT8X6BuRw9vNlQhY1LgRWHaF9S1zzyM=)
chat:
options:
model: qwen-plus
temperature: 0.5
chat:
memory:
repository:
cassandra:
keyspace: han_ai_robot
table: t_ai_chat_memory
time-to-live: 1095d
initialize-schema: true
jasypt:
encryptor:
password: ${jasypt.encryptor.password}
algorithm: PBEWithHMACSHA512AndAES_256
iv-generator-classname: org.jasypt.iv.RandomIvGenerator
logging:
level:
org.springframework.ai.chat.client.advisor: debug
config: classpath:log4j2.xml # 设置日志配置文件路径