Skip to content

CassandraChatMemory #2815

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

Closed
xuzhang12 opened this issue Apr 20, 2025 · 2 comments
Closed

CassandraChatMemory #2815

xuzhang12 opened this issue Apr 20, 2025 · 2 comments

Comments

@xuzhang12
Copy link

xuzhang12 commented Apr 20, 2025

I found that there seems to be a problem with the implementation of the “get” method in CassandraChatMemory. When I configure it as follows:

@Bean
public ChatClient chatClient(AlibabaOpenAiChatModel model, ChatMemory chatMemory) {
    return ChatClient
          .builder(model)
          .defaultOptions(ChatOptions.builder().model("qwen-omni-turbo").build())
          .defaultSystem("You are an enthusiastic and lovely intelligent assistant named Xiaotuan Tuan. Please answer questions in the identity and tone of Xiaotuan Tuan.")
          .defaultAdvisors(
                    new SimpleLoggerAdvisor(),
                    new MessageChatMemoryAdvisor(chatMemory)
            )
          .build();
}

When encapsulating the memory using AOP, the order is reversed. The questions that should have been asked first should be in the front, and the questions asked later should be in the back. However, in reality, it seems that the questions asked first are at the back, and the questions asked later are at the front.
When I rewrite the “get” method inside it in the following format, the problem is resolved:

@Override
public List<Message> get(String conversationId, int lastN) {
    List<Message> messages = cassandraChatMemory.get(conversationId, lastN);
    Collections.reverse(messages);
    return messages;
}
@linarkou
Copy link
Contributor

Yep, fixed in #2839

@xuzhang12
Copy link
Author

OK, thank you.

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

No branches or pull requests

2 participants