Skip to content

Commit

Permalink
Add status column to conversation table
Browse files Browse the repository at this point in the history
  • Loading branch information
harishmohanraj committed Nov 23, 2023
1 parent ba8d61e commit dde0206
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions main.wasp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ entity Conversation {=psl
conversation Json
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
status String?
chat Chat? @relation(fields: [chatId], references: [id])
chatId Int?
user User? @relation(fields: [userId], references: [id])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Conversation" ADD COLUMN "status" TEXT;
1 change: 1 addition & 0 deletions src/client/components/ConversationWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export default function ConversationWrapper() {
// @ts-ignore
...[{ role: "assistant", content: response.content }],
],
status: response.team_status,
};
await updateConversation(openAIPayload);
setIsLoading(false);
Expand Down
6 changes: 4 additions & 2 deletions src/server/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export const createChat: CreateChat<void, Conversation> = async (
type UpdateConversationPayload = {
conversation_id: number;
conversations: any;
status: string;
};

export const updateConversation: UpdateConversation<
Expand All @@ -215,6 +216,7 @@ export const updateConversation: UpdateConversation<
where: { id: args.conversation_id },
data: {
conversation: args.conversations,
status: args.status,
},
});
};
Expand Down Expand Up @@ -248,7 +250,7 @@ export const getAgentResponse: GetAgentResponse<AgentPayload> = async (
body: JSON.stringify(payload),
});

const json = (await response.json()) as { detail?: string }; // Parse JSON once
const json: any = (await response.json()) as { detail?: string }; // Parse JSON once

if (!response.ok) {
const errorMsg =
Expand All @@ -257,7 +259,7 @@ export const getAgentResponse: GetAgentResponse<AgentPayload> = async (
throw new Error(errorMsg);
}

return { content: json };
return { content: json["content"], team_status: json["team_status"] };
} catch (error: any) {
throw new HttpError(500, "Something went wrong. Please try again later");
}
Expand Down

0 comments on commit dde0206

Please sign in to comment.