Skip to content

data persistence with SQLAlchemyDataLayer possibility to change default schema public  #1519

Description

@cesi08

I followed the following documentation to have chat and feedback persistence https://docs.chainlit.io/data-persistence/custom

Below I report the code of my app and the requirements

import chainlit as cl
import os
from chainlit.data.storage_clients import AzureStorageClient
from chainlit.data.sql_alchemy import SQLAlchemyDataLayer
from azure.core.credentials import AzureNamedKeyCredential

account_name = ""
postgres_connection_string = ""
account_url = f"https://{account_name}.dfs.core.windows.net/"
account_key = ""
credential = AzureNamedKeyCredential(account_name, account_key)
storage_client = AzureStorageClient(account_url=account_url, container="chatbot", credential=credential)
sql_data_layer = SQLAlchemyDataLayer(conninfo=postgres_connection_string, storage_provider=storage_client,
                                     show_logger=True)
cl.data._data_layer = sql_data_layer
with_datalayer = True

@cl.on_chat_start
async def on_chat_start():
    await cl.Message(
        content="welcome to the chatbot! How can I help you today?"
    ).send()

@cl.on_message
async def on_message(message: cl.Message):
    msg = cl.Message(content="")
    await msg.send()
    msg.content = "hello"
    await msg.update()

requirements

azure-identity==1.19.0
boto3==1.35.59
azure-storage-file-datalake==12.17.0
aiohttp==3.10.10
SQLAlchemy==2.0.36
asyncpg==0.30.0

by default sql alchemy uses the public schema is there the possibility to specify the schema? because inside chainlit.data.sql_alchemy SQLAlchemyDataLayer there is no option to customize it

another thing I noticed is that the steps table must have the column
disableFeedback" bool NULL
because otherwise you always get the following error
image

@dokterbob @dosu

Metadata

Metadata

Assignees

No one assigned

    Labels

    data layerPertains to data layers.needs-triagestaleIssue has not had recent activity or appears to be solved. Stale issues will be automatically closed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions