package com.ruoyi.ai.config; import com.ruoyi.ai.store.MongoChatMemoryStore; import dev.langchain4j.memory.chat.ChatMemoryProvider; import dev.langchain4j.memory.chat.MessageWindowChatMemory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * @author :yys * @date : 2025/5/2 19:20 */ @Configuration public class SeparateChatAssistantConfig { //注入持久化对象 @Autowired private MongoChatMemoryStore mongoChatMemoryStore; @Bean ChatMemoryProvider chatMemoryProvider() { return memoryId -> MessageWindowChatMemory.builder() .id(memoryId) .maxMessages(10) .chatMemoryStore(mongoChatMemoryStore)//配置持久化对象 .build(); } }