Skip to content

fix(MessageChatMemory) When adding data to Message Chat Memory Data, the actual data was not replaced #2794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.ArrayList;
import java.util.List;

import org.springframework.ai.chat.prompt.PromptTemplate;
import org.springframework.util.CollectionUtils;
import reactor.core.publisher.Flux;

import org.springframework.ai.chat.client.advisor.api.AdvisedRequest;
Expand Down Expand Up @@ -94,7 +96,12 @@ private AdvisedRequest before(AdvisedRequest request) {
AdvisedRequest advisedRequest = AdvisedRequest.from(request).messages(advisedMessages).build();

// 4. Add the new user input to the conversation memory.
UserMessage userMessage = new UserMessage(request.userText(), request.media());
String processedUserText = request.userText();
if (!CollectionUtils.isEmpty(request.userParams())) {
processedUserText = new PromptTemplate(processedUserText, request.userParams()).render();
}
UserMessage userMessage = new UserMessage(processedUserText, request.media());

this.getChatMemoryStore().add(this.doGetConversationId(request.adviseContext()), userMessage);

return advisedRequest;
Expand Down