Chainlit / chainlit

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

disableFeedback breaks the custom persistence layer #1179

Open smannathan opened 3 months ago

smannathan commented 3 months ago

An error occurred: (sqlalchemy.dialects.postgresql.asyncpg.IntegrityError) <class 'asyncpg.exceptions.NotNullViolationError'>: null value in column "disableFeedback" of relation "steps" violates not-null constraint

CREATE TABLE IF NOT EXISTS steps ( "id" UUID PRIMARY KEY, "name" TEXT NOT NULL, "type" TEXT NOT NULL, "threadId" UUID NOT NULL, "parentId" UUID, "disableFeedback" BOOLEAN NOT NULL, -> Updated this field to NULLABLE to fix this issue "streaming" BOOLEAN NOT NULL, "waitForAnswer" BOOLEAN, "isError" BOOLEAN, "metadata" JSONB, "tags" TEXT[], "input" TEXT, "output" TEXT, "createdAt" TEXT, "start" TEXT, "end" TEXT, "generation" JSONB, "showInput" TEXT, "language" TEXT, "indent" INT );

nvinayvarma189 commented 2 months ago

Facing the same issue with the latest version of chainlit

At the time of writing, this is how the steps table is defined here

CREATE TABLE IF NOT EXISTS steps (
    "id" UUID PRIMARY KEY,
    "name" TEXT NOT NULL,
    "type" TEXT NOT NULL,
    "threadId" UUID NOT NULL,
    "parentId" UUID,
    "disableFeedback" BOOLEAN NOT NULL,
    "streaming" BOOLEAN NOT NULL,
    "waitForAnswer" BOOLEAN,
    "isError" BOOLEAN,
    "metadata" JSONB,
    "tags" TEXT[],
    "input" TEXT,
    "output" TEXT,
    "createdAt" TEXT,
    "start" TEXT,
    "end" TEXT,
    "generation" JSONB,
    "showInput" TEXT,
    "language" TEXT,
    "indent" INT
);

This is not in sync with the StepDict defined in the library code here. The disableFeedback attribute is missing here and instead has a feedback column

AidanShipperley commented 2 months ago

Yes, the community hasn't updated the documentation to reflect this change.

You need to update your Steps table's schema to allow the disableFeedback column to be nullable, or you need to delete the disableFeedback column from your Steps table completely. This column is no longer used anywhere as far as I am aware.

Additionally, if you are using a custom data layer, you need to update your data layer's Python code to remove the collection of the disableFeedback column in the get_all_user_threads() function, as shown here.

In reference to @nvinayvarma189's comment, there is no feedback column you need to add to your Steps table, this was always in the StepDict class. This value is constructed in get_all_user_threads(), where the feedback value is collected through joining the Steps table to the Feedbacks table.

Physium commented 2 weeks ago

whats so hard about making this simple change in the docs? errors like this causes a ton of unnecessary troubleshooting.