SQLChatMessageHistory(
self,
session_id: str,
table_name: str = 'message_store',
session_id_field_name: str| Name | Type | Description |
|---|---|---|
session_id* | str | Indicates the id of the same session. |
table_name | str | Default: 'message_store'Table name used to save data. |
session_id_field_name | str | Default: 'session_id'The name of field of |
custom_message_converter | Optional[BaseMessageConverter] | Default: None |
connection | Union[None, DBConnection] | Default: None |
engine_args | Optional[Dict[str, Any]] | Default: None |
async_mode | Optional[bool] | Default: None |
Chat message history stored in an SQL database.
Example:
.. code-block:: python
from langchain_core.messages import HumanMessage
from langchain_community.chat_message_histories import SQLChatMessageHistory
message_history = SQLChatMessageHistory( session_id='foo', connection_string='sqlite///:memory.db' ) message_history.add_message(HumanMessage("hello")) message_history.message
Custom message converter for converting
database data and BaseMessage
Database connection object, which can be a string containing connection configuration, Engine object or AsyncEngine object.
Additional configuration for creating database engines.
Whether it is an asynchronous connection.