See https://gomomento.com/
add_message(message: langchain.schema.BaseMessage) → None[source]#
Store a message in the cache.
Parameters
message (BaseMessage) – The message object to store.
Raises
SdkException – Momento service or network error.
Exception – Unexpected response.
clear() → None[source]#
Remove the session’s messages from the cache.
Raises
SdkException – Momento service or network error.
Exception – Unexpected response.
classmethod from_client_params(session_id: str, cache_name: str, ttl: timedelta, *, configuration: Optional[momento.config.Configuration] = None, auth_token: Optional[str] = None, **kwargs: Any) → MomentoChatMessageHistory[source]#
Construct cache from CacheClient parameters.
property messages: list[langchain.schema.BaseMessage]#
Retrieve the messages from Momento.
Raises
SdkException – Momento service or network error
Exception – Unexpected response
Returns
List of cached messages
Return type
list[BaseMessage]
class langchain.memory.MongoDBChatMessageHistory(connection_string: str, session_id: str, database_name: str = 'chat_history', collection_name: str = 'message_store')[source]#
Chat message history that stores history in MongoDB.
Parameters
connection_string – connection string to connect to MongoDB
session_id – arbitrary key that is used to store the messages
of a single chat session.
database_name – name of the database to use
collection_name – name of the collection to use
add_message(message: langchain.schema.BaseMessage) → None[source]#
Append the message to the record in MongoDB
clear() → None[source]#
Clear session memory from MongoDB
property messages: List[langchain.schema.BaseMessage]#
Retrieve the messages from MongoDB
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html