Closed AZCodingAccount closed 2 weeks ago
Can we use the approach that adds Jackson annotations since creating an instance of a message without content in code does not make sense. For example.
class MyClass {
private final int id;
private final String name;
@JsonCreator
public MyClass(@JsonProperty("id") int id, @JsonProperty("name") String name) {
this.id = id;
this.name = name;
}
....
thx
Background
Hey there, while developing with Spring Boot, I encountered issues with Jackson deserialization when storing historical messages into the Redis client. After troubleshooting using the control variable method, I found that there is room for improvement in the classes under the Message package. I made two code modifications to accommodate the new version of Jackson's deserialization process.
Solution
UserMessage
,SystemMessage
,FunctionMessage
, andAssistMessage
, and modifiedAbstractMessage
to include a single-argument constructor. This resolves the following serialization error:textContent
andmediaData
inAbstractMessage
tocontent
andmedia
to align with the methods exposed by the message. This change can resolve the following error:PS: Additional Information
Version Information: Spring Boot 3.2.4, spring-boot-starter-data-redis 3.2.4, SpringAI 1.0.0-SNAPSHOT
RedisTemplateConfig.java: