I currently have a simple working prototype with Spring AI. Currently this is setup like
@Bean
public ChatClient buildClient(
MessageChatMemoryAdvisor messageChatMemoryAdvisor
) {
return openAiBuilder
.defaultAdvisors(
messageChatMemoryAdvisor,
questionAnswerAdvisor
)
.defaultSystem(instructions)
.defaultOptions(new OpenAiChatOptions())
.build();
}
@Bean
public MessageChatMemoryAdvisor messageChatMemoryAdvisor() {
return new MessageChatMemoryAdvisor(new InMemoryChatMemory());
}
the problem is this saves the messages for every request, not just the ones for that user. I have Spring Auth setup with a session getting created so it would make sense for the MessageChatMemoryAdvisor to use that but I am unsure how to do that.
What would be the best way to store the message history per session?