Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion backend/chainlit/data/sql_alchemy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from importlib import metadata
import json
import ssl
import uuid
Expand Down Expand Up @@ -115,7 +116,15 @@ async def get_user(self, identifier: str) -> Optional[PersistedUser]:
result = await self.execute_sql(query=query, parameters=parameters)
if result and isinstance(result, list):
user_data = result[0]
return PersistedUser(**user_data)
metadata = user_data.get("metadata") or {}
if metadata is not Dict:
metadata = json.loads(metadata)
return PersistedUser(
id=user_data.get("id"),
identifier=user_data.get("identifier"),
createdAt=user_data.get("createdAt"),
metadata=metadata,
)
return None

async def create_user(self, user: User) -> Optional[PersistedUser]:
Expand Down
2 changes: 2 additions & 0 deletions backend/chainlit/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ async def resume_thread(session: WebsocketSession):

if user_is_author:
metadata = thread.get("metadata") or {}
if metadata is not Dict:
metadata = json.loads(metadata)
user_sessions[session.id] = metadata.copy()
if chat_profile := metadata.get("chat_profile"):
session.chat_profile = chat_profile
Expand Down