diff --git a/main.wasp b/main.wasp index 83f1ed8..2c81180 100644 --- a/main.wasp +++ b/main.wasp @@ -121,6 +121,10 @@ entity Chat {=psl id Int @id @default(autoincrement()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + team_id Int? + team_name String? + team_status String? + showLoader Boolean @default(false) user User? @relation(fields: [userId], references: [id]) userId Int? name String? @@ -133,10 +137,6 @@ entity Conversation {=psl updatedAt DateTime @updatedAt message String role String - team_id Int? - team_name String? - team_status String? - is_question_from_agent Boolean @default(false) chat Chat? @relation(fields: [chatId], references: [id]) chatId Int? user User? @relation(fields: [userId], references: [id]) @@ -227,9 +227,9 @@ action addNewConversationToChat { entities: [Chat, Conversation] } -action updateExistingConversation { - fn: import { updateExistingConversation } from "@server/actions.js", - entities: [Chat, Conversation] +action updateExistingChat { + fn: import { updateExistingChat } from "@server/actions.js", + entities: [Chat] } action getAgentResponse { @@ -259,6 +259,11 @@ query getChats { entities: [Chat] } +query getChat { + fn: import { getChat } from "@server/queries.js", + entities: [Chat] +} + query getConversations { fn: import { getConversations } from "@server/queries.js", entities: [Conversation] diff --git a/migrations/20231218010807_move_team_related_columns_to_chat_model/migration.sql b/migrations/20231218010807_move_team_related_columns_to_chat_model/migration.sql new file mode 100644 index 0000000..ad5e1c2 --- /dev/null +++ b/migrations/20231218010807_move_team_related_columns_to_chat_model/migration.sql @@ -0,0 +1,19 @@ +/* + Warnings: + + - You are about to drop the column `is_question_from_agent` on the `Conversation` table. All the data in the column will be lost. + - You are about to drop the column `team_id` on the `Conversation` table. All the data in the column will be lost. + - You are about to drop the column `team_name` on the `Conversation` table. All the data in the column will be lost. + - You are about to drop the column `team_status` on the `Conversation` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "Chat" ADD COLUMN "team_id" INTEGER, +ADD COLUMN "team_name" TEXT, +ADD COLUMN "team_status" TEXT; + +-- AlterTable +ALTER TABLE "Conversation" DROP COLUMN "is_question_from_agent", +DROP COLUMN "team_id", +DROP COLUMN "team_name", +DROP COLUMN "team_status"; diff --git a/migrations/20231218111917_add_show_loader_column_to_chat_model/migration.sql b/migrations/20231218111917_add_show_loader_column_to_chat_model/migration.sql new file mode 100644 index 0000000..be19786 --- /dev/null +++ b/migrations/20231218111917_add_show_loader_column_to_chat_model/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Chat" ADD COLUMN "showLoader" BOOLEAN NOT NULL DEFAULT false; diff --git a/src/client/chatConversationHelper.tsx b/src/client/chatConversationHelper.tsx index 4bdfa95..6e8a27d 100644 --- a/src/client/chatConversationHelper.tsx +++ b/src/client/chatConversationHelper.tsx @@ -1,75 +1,62 @@ import getAgentResponse from "@wasp/actions/getAgentResponse"; import addNewConversationToChat from "@wasp/actions/addNewConversationToChat"; -import updateExistingConversation from "@wasp/actions/updateExistingConversation"; +import updateExistingChat from "@wasp/actions/updateExistingChat"; import { prepareOpenAIRequest } from "./helpers"; export async function addUserMessageToConversation( chat_id: number, - userQuery: string, - conv_id?: number, - team_name?: string, - team_id?: number + userQuery: string ) { let userMessage = userQuery; - let isAnswerToAgentQuestion = false; - let user_answer_to_team_id = null; - if (team_id) { - if (conv_id) { - const payload = { - chat_id: chat_id, - conv_id: conv_id, - is_question_from_agent: false, - team_status: null, - }; - await updateExistingConversation(payload); - } - userMessage = `
Replying to ${team_name}: