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: int | None = None)[source]¶
Bases:
BaseChatMessageHistoryChat 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.
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
Attributes
Retrieve all session messages from DB
- 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.
- property messages: List[langchain.schema.messages.BaseMessage]¶
Retrieve all session messages from DB