package com.iwe3.langchain4j.config;

import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.store.memory.chat.InMemoryChatMemoryStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SeparateChatAssistantConfig {

    /**
     * 聊天记忆提供器
     * 配置：采用memoryId来完成隔离
     * @return
     */
    @Bean
    ChatMemoryProvider chatMemoryProvider() {
        return memoryId -> MessageWindowChatMemory.builder()
                .id(memoryId)
                .maxMessages(10).chatMemoryStore(new InMemoryChatMemoryStore())
                .build();
        //如果未来想自定义 -> 则自己写一个类实现 ChatMemoryStore
    }
}
