Class CassandraChatMemoryStore

java.lang.Object
dev.langchain4j.store.memory.chat.cassandra.CassandraChatMemoryStore
All Implemented Interfaces:
ChatMemoryStore

public class CassandraChatMemoryStore extends Object implements 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:
  • Field Details

  • 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 session
      tableName - 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

      public List<ChatMessage> getMessages(@NonNull @NonNull Object memoryId)
      Retrieves messages for a specified chat memory.
      Specified by:
      getMessages in interface ChatMemoryStore
      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 interface ChatMemoryStore
      Parameters:
      memoryId - The ID of the chat memory.
      messages - List of messages for the specified chat memory, that represent the current state of the ChatMemory. Can be serialized to JSON using ChatMessageSerializer.
    • deleteMessages

      public void deleteMessages(@NonNull @NonNull Object memoryId)
      Deletes all messages for a specified chat memory.
      Specified by:
      deleteMessages in interface ChatMemoryStore
      Parameters:
      memoryId - The ID of the chat memory.
    • builder

      public static CassandraChatMemoryStore.Builder builder()
    • builderAstra

      public static CassandraChatMemoryStore.BuilderAstra builderAstra()