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
Modifier and TypeClassDescriptionstatic class
static class
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCassandraChatMemoryStore
(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()
void
clear()
Delete all rows.void
create()
Create the table if not exist.void
delete()
Delete the table.void
deleteMessages
(@NonNull Object memoryId) Deletes all messages for a specified chat memory.com.datastax.oss.driver.api.core.CqlSession
Access the cassandra session for fined grained operation.getMessages
(@NonNull Object memoryId) Retrieves messages for a specified chat memory.void
updateMessages
(@NonNull Object memoryId, @NonNull List<ChatMessage> messages) Updates messages for a specified chat memory.
-
Field Details
-
DEFAULT_TABLE_NAME
Default message store.- See Also:
-
-
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:
getMessages
in 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
public void updateMessages(@NonNull @NonNull Object memoryId, @NonNull @NonNull List<ChatMessage> messages) Updates messages for a specified chat memory.- Specified by:
updateMessages
in 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:
deleteMessages
in interfaceChatMemoryStore
- Parameters:
memoryId
- The ID of the chat memory.
-
builder
-
builderAstra
-