Skip to content

Parameters not saved in ChatMemory when using PromptUserSpec #2618

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
eugeniace opened this issue Apr 2, 2025 · 0 comments
Open

Parameters not saved in ChatMemory when using PromptUserSpec #2618

eugeniace opened this issue Apr 2, 2025 · 0 comments

Comments

@eugeniace
Copy link

When trying to implement ChatMemory with PromptUserSpec messages, only the template is saved in history, without the actual parameters being replaced.

Example:

    private ChatClient.ChatClientRequestSpec buildChatClientRequestSpecRAGAdvisor(Question question, String conversationId) {
        return chatClient.prompt()
                .user(userSpec -> userSpec
                        .text("{question} (error: '{error}')?")
                        .param("question", question.question())
                        .param("error", question.error()!=null?question.error():""))
                .advisors( advisorSpec -> advisorSpec.param(AbstractChatMemoryAdvisor.CHAT_MEMORY_CONVERSATION_ID_KEY, conversationId))            ;
    }

In the history a user message like this is saved: "{question} (error: {error})", without the actual values being used.
I have tested with all types of ChatMemory. The problems comes from the advisor code (eg. PromptChatMemoryAdvisor), method before:

this.getChatMemoryStore().add(this.doGetConversationId(request.adviseContext()), userMessage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment