langchain/docs/extras
Viktor Zhemchuzhnikov 507e46844e
Extend SQLChatMessageHistory (#9849)
### Description

There is a really nice class for saving chat messages into a database -
SQLChatMessageHistory.
It leverages SqlAlchemy to be compatible with any supported database (in
contrast with PostgresChatMessageHistory, which is basically the same
but is limited to Postgres).

However, the class is not really customizable in terms of what you can
store. I can imagine a lot of use cases, when one will need to save a
message date, along with some additional metadata.

To solve this, I propose to extract the converting logic from
BaseMessage to SQLAlchemy model (and vice versa) into a separate class -
message converter. So instead of rewriting the whole
SQLChatMessageHistory class, a user will only need to write a custom
model and a simple mapping class, and pass its instance as a parameter.

I also noticed that there is no documentation on this class, so I added
that too, with an example of custom message converter.

### Issue

N/A

### Dependencies

N/A

### Tag maintainer

Not yet

### Twitter handle

N/A
2023-09-03 15:49:53 -07:00
..
_templates Update Integrations links (#8206) 2023-07-24 21:20:32 -07:00
additional_resources Mv LCEL docs up a level (#10073) 2023-09-01 08:20:55 -07:00
expression_language Mv LCEL docs up a level (#10073) 2023-09-01 08:20:55 -07:00
guides Add prompt hub for various use-cases (#9879) 2023-09-03 15:32:22 -07:00
integrations Extend SQLChatMessageHistory (#9849) 2023-09-03 15:49:53 -07:00
modules docs: chains & memory fixes (#9895) 2023-09-03 15:06:20 -07:00
use_cases Add prompt hub for various use-cases (#9879) 2023-09-03 15:32:22 -07:00