package io.quarkiverse.langchain4j.samples;

import java.util.function.Supplier;

import dev.langchain4j.memory.ChatMemory;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.store.memory.chat.InMemoryChatMemoryStore;

public class CustomProvider implements Supplier<ChatMemoryProvider> {

    private final InMemoryChatMemoryStore store = new InMemoryChatMemoryStore();

    @Override
    public ChatMemoryProvider get() {
        return new ChatMemoryProvider() {

            @Override
            public ChatMemory get(Object memoryId) {
                return MessageWindowChatMemory.builder()
                        .maxMessages(20)
                        .id(memoryId)
                        .chatMemoryStore(store)
                        .build();
            }
        };
    }
}

dev.langchain4j.memory.chat.MessageWindowChatMemory.builder
[((652, 845), 'dev.langchain4j.memory.chat.MessageWindowChatMemory.builder'), ((652, 812), 'dev.langchain4j.memory.chat.MessageWindowChatMemory.builder'), ((652, 764), 'dev.langchain4j.memory.chat.MessageWindowChatMemory.builder'), ((652, 726), 'dev.langchain4j.memory.chat.MessageWindowChatMemory.builder')]