Skip to content

Optimise CassandraChatMemoryRepository for MessageWindowChatMemory usage pattern #3097

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

Conversation

michaelsembwever
Copy link
Contributor

@michaelsembwever michaelsembwever commented May 11, 2025

Time-series each chat window in Cassandra, keeping past (and deleted) windows still in the db. Add ability to store different MessageTypes.

ref: #2998

@michaelsembwever michaelsembwever force-pushed the mck/CassandraChatMemoryRepository_0 branch 2 times, most recently from af0c80d to a5649da Compare May 11, 2025 19:38
…age pattern

Time-series each chat window in Cassandra, keeping past (and deleted) windows still in the db.
Add ability to store different MessageTypes.

Signed-off-by: mck <[email protected]>
@michaelsembwever michaelsembwever force-pushed the mck/CassandraChatMemoryRepository_0 branch from a5649da to 73e31d1 Compare May 11, 2025 19:42
@michaelsembwever michaelsembwever marked this pull request as ready for review May 11, 2025 19:42
stmt = stmt.whereColumn(columnName).isEqualTo(QueryBuilder.bindMarker(columnName));
private Message getMessage(UdtValue udt) {
String content = udt.getString(this.conf.messageUdtContentColumn);
Map<String, Object> props = Map.of(CONVERSATION_TS, udt.getInstant(this.conf.messageUdtTimestampColumn));
Copy link
Contributor Author

@michaelsembwever michaelsembwever May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZYMCao messages have the timestamp value in their metadata, as an Instant instance, under the CONVERSATION_TS key.

The literal for that key is found here: https://github.com/spring-projects/spring-ai/blob/main/memory/spring-ai-model-chat-memory-cassandra/src/main/java/org/springframework/ai/chat/memory/cassandra/CassandraChatMemoryRepository.java#L50-L51

@ilayaperumalg ilayaperumalg self-assigned this May 12, 2025
@markpollack markpollack added this to the 1.0.0-RC1 milestone May 13, 2025
@ilayaperumalg
Copy link
Member

@michaelsembwever Thanks for the PR! Rebased and merged as 87b680a

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

Successfully merging this pull request may close these issues.

3 participants