-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(be): create prompt result insertion API (#72)
* feat: create prompt table Co-authored-by: shl0501 <[email protected]> Co-authored-by: 유영재 <[email protected]> Co-authored-by: Choi Jeongmin <[email protected]> * feat: create history insert API Co-authored-by: shl0501 <[email protected]> Co-authored-by: 유영재 <[email protected]> Co-authored-by: Choi Jeongmin <[email protected]> * fix: remove ai test file --------- Co-authored-by: shl0501 <[email protected]> Co-authored-by: 유영재 <[email protected]> Co-authored-by: Choi Jeongmin <[email protected]>
- Loading branch information
1 parent
0f759c8
commit 24b203c
Showing
10 changed files
with
133 additions
and
87 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
apps/server/prisma/migrations/20250210082219_prompt/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,21 @@ | ||
-- CreateTable | ||
CREATE TABLE "Prompt" ( | ||
"name" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Prompt_pkey" PRIMARY KEY ("name") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "PromptHistory" ( | ||
"history_id" SERIAL NOT NULL, | ||
"before" TEXT NOT NULL, | ||
"after" TEXT NOT NULL, | ||
"prompt_name" TEXT NOT NULL, | ||
"result" TEXT NOT NULL, | ||
|
||
CONSTRAINT "PromptHistory_pkey" PRIMARY KEY ("history_id") | ||
); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "PromptHistory" ADD CONSTRAINT "PromptHistory_prompt_name_fkey" FOREIGN KEY ("prompt_name") REFERENCES "Prompt"("name") ON DELETE RESTRICT ON UPDATE CASCADE; |
14 changes: 14 additions & 0 deletions
14
apps/server/prisma/migrations/20250210083749_update_history_column_name/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,14 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `after` on the `PromptHistory` table. All the data in the column will be lost. | ||
- You are about to drop the column `before` on the `PromptHistory` table. All the data in the column will be lost. | ||
- Added the required column `request` to the `PromptHistory` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `response` to the `PromptHistory` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "PromptHistory" DROP COLUMN "after", | ||
DROP COLUMN "before", | ||
ADD COLUMN "request" TEXT NOT NULL, | ||
ADD COLUMN "response" TEXT NOT NULL; |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsIn, IsNotEmpty, IsString } from 'class-validator'; | ||
|
||
export class CreateHistoryDto { | ||
@ApiProperty({ | ||
example: 'IMPROVE_QUESTION', | ||
description: '프롬프트 종류', | ||
required: true, | ||
}) | ||
@IsIn(['IMPROVE_QUESTION', 'SHORTEN_QUESTION'], { | ||
message: 'promptName은 IMPROVE_QUESTION 또는 SHORTEN_QUESTION이어야 합니다.', | ||
}) | ||
@IsNotEmpty() | ||
promptName: string; | ||
|
||
@ApiProperty({ | ||
example: '호날두 VS 메시', | ||
description: 'AI 수정 전의 원본', | ||
required: true, | ||
}) | ||
@IsString() | ||
@IsNotEmpty() | ||
request: string; | ||
|
||
@ApiProperty({ | ||
example: '호날두와 메시 중 누가 더 뛰어난 축구선수인가요?', | ||
description: 'AI 수정 후의 결과', | ||
required: true, | ||
}) | ||
@IsString() | ||
@IsNotEmpty() | ||
response: string; | ||
|
||
@ApiProperty({ | ||
example: 'ACCEPT', | ||
description: '사용자 반응', | ||
required: true, | ||
}) | ||
@IsIn(['ACCEPT', 'REJECT'], { | ||
message: 'result는 ACCEPT 또는 REJECT이어야 합니다.', | ||
}) | ||
@IsNotEmpty() | ||
result: string; | ||
} |
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
import { applyDecorators } from '@nestjs/common'; | ||
import { ApiOperation, ApiResponse } from '@nestjs/swagger'; | ||
|
||
export const CreateHistorySwagger = () => | ||
applyDecorators( | ||
ApiOperation({ summary: 'AI 제안을 사용자가 accept/rejet했는지를 저장합니다.' }), | ||
ApiResponse({ | ||
status: 201, | ||
description: 'history 저장 성공', | ||
}), | ||
); |