Skip to content

Commit

Permalink
fix(SQLAlchemyDataLayer): Fix sqlite json columns
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Tao <[email protected]>
  • Loading branch information
tcx4c70 committed Jan 28, 2025
1 parent f308392 commit 58dc338
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions backend/chainlit/data/sql_alchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,10 @@ async def get_all_user_threads(
for thread in user_threads:
thread_id = thread["thread_id"]
if thread_id is not None:
# SQLite returns JSON as string, we most convert it.
thread_metadata = thread.get("thread_metadata", {})
if isinstance(thread_metadata, str):
thread_metadata = json.loads(thread_metadata)
thread_dicts[thread_id] = ThreadDict(
id=thread_id,
createdAt=thread["thread_createdat"],
Expand All @@ -661,6 +665,10 @@ async def get_all_user_threads(
value=step_feedback["feedback_value"],
comment=step_feedback.get("feedback_comment"),
)
# SQLite returns JSON as string, we most convert it.
step_metadata = step_feedback.get("step_metadata", {})
if isinstance(step_metadata, str):
step_metadata = json.loads(step_metadata)
step_dict = StepDict(
id=step_feedback["step_id"],
name=step_feedback["step_name"],
Expand Down

0 comments on commit 58dc338

Please sign in to comment.