Skip to content

Parameters not saved in ChatMemory when using PromptUserSpec #2618

Closed
@eugeniace

Description

@eugeniace

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions