langchain.memory.chat_message_histories.cassandra.CassandraChatMessageHistory

class langchain.memory.chat_message_histories.cassandra.CassandraChatMessageHistory(session_id: str, session: Session, keyspace: str, table_name: str = 'message_store', ttl_seconds: Optional[int] = None)[source]

Chat message history that stores history in Cassandra.

Parameters
  • session_id – arbitrary key that is used to store the messages of a single chat session.

  • session – a Cassandra Session object (an open DB connection)

  • keyspace – name of the keyspace to use.

  • table_name – name of the table to use.

  • ttl_seconds – time-to-live (seconds) for automatic expiration of stored entries. None (default) for no expiration.

Attributes

messages

Retrieve all session messages from DB

Methods

__init__(session_id, session, keyspace[, ...])

add_ai_message(message)

Convenience method for adding an AI message string to the store.

add_message(message)

Write a message to the table

add_user_message(message)

Convenience method for adding a human message string to the store.

clear()

Clear session memory from DB

__init__(session_id: str, session: Session, keyspace: str, table_name: str = 'message_store', ttl_seconds: Optional[int] = None) None[source]
add_ai_message(message: str) None

Convenience method for adding an AI message string to the store.

Parameters

message – The string contents of an AI message.

add_message(message: BaseMessage) None[source]

Write a message to the table

add_user_message(message: str) None

Convenience method for adding a human message string to the store.

Parameters

message – The string contents of a human message.

clear() None[source]

Clear session memory from DB

Examples using CassandraChatMessageHistory