Open
Description
Bug description
deserialization. Currently, ChatMemory only implements a memory-based dialogue cache storage. I wanted to implement a Redis-based cache for Memory in my project, but I encountered a problem: the implementation classes of the Memory interface do not implement the Serializable interface, which causes failures in accessing Redis.
Environment
Spring AI 1.0.0-SNAPSHOT
Steps to reproduce
step1 :
`@Slf4j
public class RedisChatMemory implements ChatMemory {
private static final String PREFIX = "chat:";
@Override
public void add(String conversationId, List<Message> messages) {
messages.forEach(message -> RedisUtils.lSet(PREFIX + conversationId, message, CommonConst.CHAT_EXPIRE_TIME));
}
@Override
public List<Message> get(String conversationId, int lastN) {
List<Message> messages = RedisUtils.lGet(PREFIX + conversationId, -lastN, -1);
log.info("history conversation :{}", JSONObject.toJSONString(messages));
return messages;
}
@Override
public void clear(String conversationId) {
RedisUtils.del(PREFIX + conversationId);
}
}`
Step2:
Runtime error
Expected behavior
Support for Redis-based session storage