Skip to content

MessageChatMemoryAdvisor and PromptChatMemoryAdvisor lack a way to pass custom Message metadata #2437

Open
@sunyuhan1998

Description

@sunyuhan1998

Expected Behavior
I am trying to implement a persistent ChatMemory myself. In my persistent storage, I want each Message to have a custom unique primary key and other accompanying metadata (I think this is also a common requirement for many people). I will specify this when I construct the ChatClientRequestSpec, and then get it from the Message parameter when implementing the ChatMemory add method.

Current Behavior
I found that there is no part in the parameters of the ChatMemory add method that can carry custom metadata for the Message. Although the metadata property is provided in AbstractMessage, unfortunately, MessageChatMemoryAdvisor and PromptChatMemoryAdvisor create a new Message object when calling the add method, and do not pass any Metadata properties.

Context

I think I can use Advisor's adviseContext to achieve this goal. I can pass the metadata in by specifying params when constructing ChatClientRequestSpec, and then get them in MessageChatMemoryAdvisor and PromptChatMemoryAdvisor by getting the adviseContext of AdvisedRequest, add them to Message, and pass them to ChatMemory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions