Open Source Data Layers
SQLAlchemy Data Layer
This custom layer has been tested for PostgreSQL, however it should support more SQL databases thanks to the use of the SQL Alchemy database.
This data layer also supports the BaseStorageClient
that enables you to store your elements into Azure Blob Storage or AWS S3.
Here is the SQL used to create the schema for this data layer:
Example
Here is an example of setting up this data layer on a PostgreSQL database with an Azure storage client. First install the required dependencies:
Import the custom data layer and storage client, and indicate which data layer to use with @cl.data_layer
at the beginning of your Chainlit app:
Note that you need to add +asyncpg
to the protocol in the conninfo
string so that it uses the asyncpg library.
Was this page helpful?