fix: Refactored chat memory implementation to use MessageWindowChatMemory

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
Christian Tzolov
2025-05-08 09:15:43 +02:00
parent 58ae24ce71
commit 4a54643c11
3 changed files with 7 additions and 7 deletions

View File

@@ -17,7 +17,7 @@ package org.springframework.ai.openai.samples.helloworld;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.memory.InMemoryChatMemory;
import org.springframework.ai.chat.memory.MessageWindowChatMemory;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.stereotype.Component;
@@ -36,7 +36,7 @@ public class ReflectionAgent {
Your task is to Generate the best content possible for the user's request. If the user provides critique,
respond with a revised version of your previous attempt.
""")
.defaultAdvisors(new MessageChatMemoryAdvisor(new InMemoryChatMemory()))
.defaultAdvisors(new MessageChatMemoryAdvisor(MessageWindowChatMemory.builder().build()))
.build();
this.critiqueChatClient = ChatClient.builder(chatModel)
@@ -45,7 +45,7 @@ public class ReflectionAgent {
If the user content has something wrong or something to be improved, output a list of recommendations
and critiques. If the user content is ok and there's nothing to change, output this: <OK>
""")
.defaultAdvisors(new MessageChatMemoryAdvisor(new InMemoryChatMemory()))
.defaultAdvisors(new MessageChatMemoryAdvisor(MessageWindowChatMemory.builder().build()))
.build();
}