langchain.memory.chat_message_histories.dynamodb.DynamoDBChatMessageHistory¶
- class langchain.memory.chat_message_histories.dynamodb.DynamoDBChatMessageHistory(table_name: str, session_id: str, endpoint_url: Optional[str] = None)[source]¶
Bases:
BaseChatMessageHistoryChat message history that stores history in AWS DynamoDB.
This class expects that a DynamoDB table with name table_name and a partition Key of SessionId is present.
- Parameters
table_name – name of the DynamoDB table
session_id – arbitrary key that is used to store the messages of a single chat session.
endpoint_url – URL of the AWS endpoint to connect to. This argument is optional and useful for test purposes, like using Localstack. If you plan to use AWS cloud service, you normally don’t have to worry about setting the endpoint_url.
Methods
__init__(table_name, session_id[, endpoint_url])add_ai_message(message)Convenience method for adding an AI message string to the store.
add_message(message)Append the message to the record in DynamoDB
add_user_message(message)Convenience method for adding a human message string to the store.
clear()Clear session memory from DynamoDB
Attributes
Retrieve the messages from DynamoDB
- 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]¶
Append the message to the record in DynamoDB
- 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 the messages from DynamoDB