Chainlit / chainlit

Build Conversational AI in minutes ⚡️
https://docs.chainlit.io
Apache License 2.0
6.28k stars 802 forks source link

missing "threadId" column in "feedbacks" table from example script used in SQL alchemy data layer #1068

Open matteo-stat opened 1 month ago

matteo-stat commented 1 month ago

Describe the bug The current example SQL script in the documentation that creates all the tables for the SQL alchemy data layer it's missing the ""threadId" column in the "feedbacks" table

To Reproduce Steps to reproduce the behavior:

  1. follow the procedure described at https://docs.chainlit.io/data-persistence/custom
  2. create a new chat
  3. type a message
  4. try to give a feedback
  5. you will get this error and feedback won't be saved
    2024-06-12 12:29:30 - An error occurred: (sqlalchemy.dialects.postgresql.asyncpg.ProgrammingError) <class 'asyncpg.exceptions.UndefinedColumnError'>: la colonna "threadId" della relazione "feedbacks" non esiste
    [SQL:
            INSERT INTO feedbacks ("forId", "threadId", "value", "id", "comment")
            VALUES ($1, $2, $3, $4, $5)
            ON CONFLICT (id) DO UPDATE
            SET "forId" = $1, "threadId" = $2, "value" = $3, "comment" = $5;
        ]
    [parameters: ('626fbced-fc21-43c0-82b9-baddbda06cb3', 'a0eb5eec-7c1c-4c5f-ab77-e48c448c5827', 0, '257ba504-0b12-4314-a15b-17bcbaf78f58', 'tdhdth')]
    (Background on this error at: https://sqlalche.me/e/20/f405)

Expected behavior The feedback should be saved

Desktop (please complete the following information):

Additional context I fixed the problem updating the SQL example script, that i'll post below

matteo-stat commented 1 month ago

the current SQL example script in the doc that creates the "feedbacks" table looks like this

CREATE TABLE IF NOT EXISTS feedbacks (
    "id" UUID PRIMARY KEY,
    "forId" UUID NOT NULL,
    "value" INT NOT NULL,
    "comment" TEXT
);

the updated SQL code that creates "feedbacks" table with the required "threadId" column and will fix the error above looks like this

CREATE TABLE IF NOT EXISTS feedbacks (
    "id" UUID PRIMARY KEY,
    "forId" UUID NOT NULL,
    "threadId" UUID NOT NULL,
    "value" INT NOT NULL,
    "comment" TEXT
);

maybe just updating the documentation page with this SQL code will fix the issue 😄

IngLP commented 6 days ago

I had the same problem!