Skip to content

org.springframework.ai.chat.messages.Message should have a getId() method #2902

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
enricorampazzo opened this issue Apr 26, 2025 · 1 comment

Comments

@enricorampazzo
Copy link

enricorampazzo commented Apr 26, 2025

Let's say I have a chatbot, and I want the user to be able to give a feedback on whether the assistant message is good or not: it is necessary to have an id to identify that message univocally, but at the moment the Message interface does not have a way to get it.

Of course it would be possible to just have it in the message metadata, however for Document (which has the same super interface of Message, i.e. Content) the id field is provided directly, and not as a part of its metadata

So my suggestion is just to add

String getId(); to org.springframework.ai.model.Content

If you think this is a good idea I can prepare the PR

@markpollack
Copy link
Member

Things in the design have changed, they isn't a common interface for document and message anymore. The response from OpenAI API will have an ID in it for the entire response. That can be used to uniquely identify the message. The inner payload that contains user messages in the response does not contain an ID. So you can use the outer one to create a synthetic ID if there is more than on user message in the response (when n > 1).

We we are approaching RC1, and haven't had other requests to add message ID into the core domain object, I think you can use that ID from the response and then add that to a message object which you persist to the thumbs up and thumbs down evaluation.

Post RC1/GA we can investigate the use case (which I agree is super common) and see if there is something that need to be added to the Message objects ,which are design really for the transfer back and forth with the model.

hope this helps. let us know.

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

No branches or pull requests

2 participants