-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
store chat metadata and chat feedback in db
- Loading branch information
1 parent
6ec90ff
commit 0f7334b
Showing
34 changed files
with
312 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
quadratic-api/prisma/migrations/20250110022353_add_analytics_ai_chat/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
-- CreateEnum | ||
CREATE TYPE "AIChatSource" AS ENUM ('ai_assistant', 'ai_analyst', 'ai_researcher', 'get_chat_name', 'get_file_name'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "AnalyticsAIChat" ( | ||
"id" SERIAL NOT NULL, | ||
"user_id" INTEGER NOT NULL, | ||
"file_id" INTEGER NOT NULL, | ||
"chat_id" TEXT NOT NULL, | ||
"source" "AIChatSource" NOT NULL, | ||
"s3_key" TEXT NOT NULL, | ||
"created_date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "AnalyticsAIChat_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "AnalyticsAIChatMessage" ( | ||
"id" SERIAL NOT NULL, | ||
"chat_id" INTEGER NOT NULL, | ||
"model" TEXT NOT NULL, | ||
"message_index" INTEGER NOT NULL, | ||
"like" BOOLEAN, | ||
"undo" BOOLEAN, | ||
"code_run_error" TEXT, | ||
"response_error" TEXT, | ||
"created_date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
||
CONSTRAINT "AnalyticsAIChatMessage_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "AnalyticsAIChat_chat_id_key" ON "AnalyticsAIChat"("chat_id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "AnalyticsAIChat_chat_id_idx" ON "AnalyticsAIChat"("chat_id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "AnalyticsAIChat_user_id_idx" ON "AnalyticsAIChat"("user_id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "AnalyticsAIChat_file_id_idx" ON "AnalyticsAIChat"("file_id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "AnalyticsAIChat_source_idx" ON "AnalyticsAIChat"("source"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "AnalyticsAIChatMessage_chat_id_message_index_idx" ON "AnalyticsAIChatMessage"("chat_id", "message_index"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "AnalyticsAIChatMessage_chat_id_idx" ON "AnalyticsAIChatMessage"("chat_id"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "AnalyticsAIChatMessage_model_idx" ON "AnalyticsAIChatMessage"("model"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "AnalyticsAIChatMessage_chat_id_message_index_key" ON "AnalyticsAIChatMessage"("chat_id", "message_index"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "AnalyticsAIChat" ADD CONSTRAINT "AnalyticsAIChat_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "AnalyticsAIChat" ADD CONSTRAINT "AnalyticsAIChat_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "File"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "AnalyticsAIChatMessage" ADD CONSTRAINT "AnalyticsAIChatMessage_chat_id_fkey" FOREIGN KEY ("chat_id") REFERENCES "AnalyticsAIChat"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import type { Params } from 'express-jwt'; | ||
import { expressjwt } from 'express-jwt'; | ||
import { jwtConfig } from 'quadratic-api/src/auth/auth'; | ||
import { jwtConfig } from '../auth/auth'; | ||
|
||
// based on implementation from https://github.com/auth0-developer-hub/api_express_typescript_hello-world/blob/main/src/middleware/auth0.middleware.ts | ||
export const validateAccessToken = expressjwt(jwtConfig() as Params); |
6 changes: 3 additions & 3 deletions
6
quadratic-api/src/routes/internal/checkpoint.$fileUuid.GET.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
quadratic-api/src/routes/internal/checkpoint.$fileUuid.PUT.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.