File tree Expand file tree Collapse file tree 3 files changed +4
-9
lines changed
src/main/java/com/xiaozhi Expand file tree Collapse file tree 3 files changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -60,12 +60,5 @@ public ApplicationListener<WebServerInitializedEvent> webServerInitializedListen
6060 logger .info ("==========================================================" );
6161 };
6262 }
63- @ Bean
64- public ChatMemory chatMemory (){
65- // 历史记录默认限制数量
66- final int DEFAULT_HISTORY_LIMIT = 10 ;
67- // TODO 后续指定ChatMemoryRepository,从数据库中加载历史记录。也就是基于spring-ai 将ChatMemory与ChatMemoryRepository直接关联。
68- return MessageWindowChatMemory .builder ().maxMessages (DEFAULT_HISTORY_LIMIT ).build ();
6963
70- }
7164}
Original file line number Diff line number Diff line change 2121import jakarta .annotation .Resource ;
2222import org .slf4j .Logger ;
2323import org .slf4j .LoggerFactory ;
24+ import org .springframework .beans .factory .annotation .Autowired ;
2425import org .springframework .stereotype .Component ;
2526import org .springframework .util .ObjectUtils ;
2627import org .springframework .util .StringUtils ;
@@ -65,7 +66,7 @@ public class MessageHandler {
6566 @ Resource
6667 private SttServiceFactory sttFactory ;
6768
68- @ Resource
69+ @ Autowired
6970 private ChatMemory chatMemory ;
7071
7172 @ Resource
Original file line number Diff line number Diff line change 33import com .xiaozhi .communication .common .ChatSession ;
44import com .xiaozhi .dialogue .llm .api .StreamResponseListener ;
55import com .xiaozhi .dialogue .llm .factory .ChatModelFactory ;
6+ import com .xiaozhi .dialogue .llm .memory .ChatMemory ;
67import com .xiaozhi .dialogue .llm .memory .Conversation ;
78import com .xiaozhi .dialogue .llm .memory .DatabaseChatMemory ;
89import com .xiaozhi .dialogue .llm .memory .MessageWindowConversation ;
@@ -70,7 +71,7 @@ public class ChatService {
7071 private static final int NEW_SENTENCE_TOKEN_THRESHOLD = 8 ;
7172
7273 @ Resource
73- private DatabaseChatMemory chatMemoryStore ;
74+ private ChatMemory chatMemoryStore ;
7475
7576 // TODO 移到构建者模式,由连接通过认证,可正常对话时,创建实例,构建好一个完整的Role.
7677 @ Resource
You can’t perform that action at this time.
0 commit comments