langchain.memory.chat_message_histories.redis.RedisChatMessageHistory¶
- class langchain.memory.chat_message_histories.redis.RedisChatMessageHistory(session_id: str, url: str = 'redis://localhost:6379/0', key_prefix: str = 'message_store:', ttl: Optional[int] = None)[source]¶
Bases:
BaseChatMessageHistoryChat message history stored in a Redis database.
Methods
__init__(session_id[, url, key_prefix, ttl])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 Redis
add_user_message(message)Convenience method for adding a human message string to the store.
clear()Clear session memory from Redis
Attributes
Construct the record key to use
Retrieve the messages from Redis
- 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 Redis
- 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 key: str¶
Construct the record key to use
- property messages: List[langchain.schema.messages.BaseMessage]¶
Retrieve the messages from Redis