Files
chainlit--chainlit/cypress/e2e/custom_data_layer/sql_alchemy.py
T
wehub-resource-sync b7f52be4c9
CI / Run CI (push) Has been cancelled
CI / check-backend (push) Has been cancelled
CI / check-frontend (push) Has been cancelled
CI / tests (push) Has been cancelled
CI / e2e-tests (push) Has been cancelled
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:48:47 +08:00

39 lines
921 B
Python

import os
from typing import Optional
import chainlit as cl
from chainlit.data.sql_alchemy import SQLAlchemyDataLayer
from chainlit.data.storage_clients.azure import AzureStorageClient
os.environ["CHAINLIT_AUTH_SECRET"] = "SUPER_SECRET" # nosec B105
storage_client = AzureStorageClient(
account_url="<your_account_url>", container="<your_container>"
)
@cl.data_layer
def data_layer():
return SQLAlchemyDataLayer(
conninfo="<your conninfo>", storage_provider=storage_client
)
@cl.on_chat_start
async def main():
await cl.Message("Hello, send me a message!").send()
@cl.on_message
async def handle_message():
await cl.sleep(2)
await cl.Message("Ok!").send()
@cl.password_auth_callback
def auth_callback(username: str, password: str) -> Optional[cl.User]:
if (username, password) == ("admin", "admin"):
return cl.User(identifier="admin")
else:
return None