Class CassandraChatMemoryStore
java.lang.Object
dev.langchain4j.store.memory.chat.cassandra.CassandraChatMemoryStore
- All Implemented Interfaces:
ChatMemoryStore
Implementation of
ChatMemoryStore using Astra DB Vector Search.
Table contains all chats. (default name is message_store). Each chat with multiple messages
is a partition.Message id is a time uuid.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCassandraChatMemoryStore(com.datastax.oss.driver.api.core.CqlSession session) Constructor for message storeCassandraChatMemoryStore(com.datastax.oss.driver.api.core.CqlSession session, String tableName) Constructor for message store -
Method Summary
Modifier and TypeMethodDescriptionbuilder()voidclear()Delete all rows.voidcreate()Create the table if not exist.voiddelete()Delete the table.voiddeleteMessages(@NonNull Object memoryId) Deletes all messages for a specified chat memory.com.datastax.oss.driver.api.core.CqlSessionAccess the cassandra session for fined grained operation.getMessages(@NonNull Object memoryId) Retrieves messages for a specified chat memory.voidupdateMessages(@NonNull Object memoryId, @NonNull List<ChatMessage> messages) Updates messages for a specified chat memory.
-
Field Details
-
DEFAULT_TABLE_NAME
-
-
Constructor Details
-
CassandraChatMemoryStore
public CassandraChatMemoryStore(com.datastax.oss.driver.api.core.CqlSession session) Constructor for message store- Parameters:
session- cassandra session
-
CassandraChatMemoryStore
public CassandraChatMemoryStore(com.datastax.oss.driver.api.core.CqlSession session, String tableName) Constructor for message store- Parameters:
session- cassandra sessiontableName- table name
-
-
Method Details
-
create
public void create()Create the table if not exist. -
delete
public void delete()Delete the table. -
clear
public void clear()Delete all rows. -
getCassandraSession
public com.datastax.oss.driver.api.core.CqlSession getCassandraSession()Access the cassandra session for fined grained operation.- Returns:
- current cassandra session
-
getMessages
Retrieves messages for a specified chat memory.- Specified by:
getMessagesin interfaceChatMemoryStore- Parameters:
memoryId- The ID of the chat memory.- Returns:
- List of messages for the specified chat memory. Must not be null. Can be deserialized from JSON using
ChatMessageDeserializer.
-
updateMessages
Updates messages for a specified chat memory.- Specified by:
updateMessagesin interfaceChatMemoryStore- Parameters:
memoryId- The ID of the chat memory.messages- List of messages for the specified chat memory, that represent the current state of theChatMemory. Can be serialized to JSON usingChatMessageSerializer.
-
deleteMessages
Deletes all messages for a specified chat memory.- Specified by:
deleteMessagesin interfaceChatMemoryStore- Parameters:
memoryId- The ID of the chat memory.
-
builder
-
builderAstra
-