spring-projects / spring-projects/spring-ai
Getting textContent but method name getText causes serialization failure issue !!!!
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Bug description
SpringAI provides a Message interface for its conversation records, which has corresponding implementation classes. For example, UserMessage is the question asked by the user, and AssistantMessage is the question answered by the large model. In these implementation classes, the content of his answers is saved in the textContent field, but there is no get method provided. Instead, a getText method is provided, which results in no content in the JSON when serialized.
Environment
SpringAI 1.0.0-M6 , JDK17
Steps to reproduce
Expected behavior
I expect to add the getTextContent() method on top of the original one
Minimal Complete Reproducible example
I see that 2 pieces of data were indeed stored, but unfortunately, the specific content was not stored.
That's because the textContent property in the implementation class of the org.springframework.ai.chat.messages.Message interface does not provide a get method, only a getText() method, which results in the inability to retrieve the value.
Later on, I wrote a serialization and deserialization tool class (reflection) specifically for this message, which solved the problem. However, it was quite troublesome, so I decided to add a getTextContent() method directly. This would be very convenient to use, and I hope to receive a reply after seeing it. Thank you
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the UserMessage and AssistantMessage implementations of org.springframework.ai.chat.messages.Message, focusing on how textContent is exposed for JSON serialization. Reproduce the reported serialization case and verify that the serialized JSON includes the message content while preserving the existing getText() behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100