langchain_community.chat_message_histories.astradb.AstraDBChatMessageHistory¶
class langchain_community.chat_message_histories.astradb.AstraDBChatMessageHistory(*, session_id: str, collection_name: str = 'langchain_message_store', token: Optional[str] = None, api_endpoint: Optional[str] = None, astra_db_client: Optional[LibAstraDB] = None, namespace: Optional[str] = None)[source]¶
Chat message history that stores history in Astra DB.
Args (only keyword-arguments accepted):
session_id: arbitrary key that is used to store the messagesof a single chat session.
collection_name (str): name of the Astra DB collection to create/use.
token (Optional[str]): API token for Astra DB usage.
api_endpoint (Optional[str]): full URL to the API endpoint,
such as “https://<DB-ID>-us-east1.apps.astra.datastax.com”.
astra_db_client (Optional[Any]): alternative to token+api_endpoint,you can pass an already-created ‘astrapy.db.AstraDB’ instance.
namespace (Optional[str]): namespace (aka keyspace) where thecollection is created. Defaults to the database’s “default namespace”.
Create an Astra DB chat message history.
Attributes
messages
Retrieve all session messages from DB
Methods
__init__(*, session_id[, collection_name, ...])
Create an Astra DB chat message history.
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