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

Conversation

zhangshenghang
Copy link

When I use something like ReReadingAdvisor, I will use {re2_input_query} for parameter substitution.

image

However, when MessageChatMemoryAdvisor executes this.getChatMemoryStore().add, it does not perform replacement and will directly save {re2_input_query} to ChatMemory. This is incorrect.

// 4. Add the new user input to the conversation memory.
		UserMessage userMessage = new UserMessage(request.userText(), request.media());
		this.getChatMemoryStore().add(this.doGetConversationId(request.adviseContext()), userMessage);

image

We need to replace {re2_input_query} with real content. Modified code:

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);

@zhangshenghang zhangshenghang force-pushed the fix-message-chat-memory-advisor branch from cc27e91 to 13fc058 Compare April 18, 2025 08:00
@zhangshenghang zhangshenghang force-pushed the fix-message-chat-memory-advisor branch from 13fc058 to 3d8cb47 Compare April 18, 2025 08:02
@zhangshenghang
Copy link
Author

@tzolov @markpollack @ilayaperumalg PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant