feat(ai): 实现对话记忆与消息持久化功能

- 移除 Cassandra 相关配置及依赖
- 新增 CustomChatMemoryAdvisor 实现对话记忆管理
-重命名并扩展 CustomStreamLoggerAdvisor 为 CustomStreamLoggerAndMessage2DBAdvisor,增加消息入库逻辑
- 在 ChatController 中集成新的 Advisor 并注入相关依赖
- 使用 TransactionTemplate 管理消息存储事务
-限制记忆消息数量为最新 50 条
- 支持将用户消息与 AI 回答同步写入数据库
This commit is contained in:
2025-11-03 16:31:19 +08:00
parent f3f320f390
commit 59eb69747b
6 changed files with 219 additions and 74 deletions

View File

@@ -43,11 +43,6 @@
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter-dashscope</artifactId>
</dependency>
<!-- Cassandra -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-chat-memory-repository-cassandra</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>