From 3d32bc9774383bf824837a0341ebfd876d1ae935 Mon Sep 17 00:00:00 2001 From: EresDev Date: Tue, 13 Aug 2024 16:24:18 +0500 Subject: [PATCH] refactor: move types to correct file --- src/parser/content-evaluator-module.ts | 16 +++++++++------- src/types/content-evaluator-module-type.ts | 9 +++++++++ src/types/openai-type.ts | 7 ------- 3 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 src/types/content-evaluator-module-type.ts delete mode 100644 src/types/openai-type.ts diff --git a/src/parser/content-evaluator-module.ts b/src/parser/content-evaluator-module.ts index 65a15ad9..f6858560 100644 --- a/src/parser/content-evaluator-module.ts +++ b/src/parser/content-evaluator-module.ts @@ -11,10 +11,12 @@ import { GithubCommentScore, Module, Result } from "./processor"; import { Value } from "@sinclair/typebox/value"; import { commentEnum, CommentKind, CommentType } from "../configuration/comment-types"; import logger from "../helpers/logger"; -import openAiRelevanceResponseSchema, { RelevancesByOpenAi } from "../types/openai-type"; - -type CommentToEvaluate = { id: number; comment: string }; -type ReviewCommentToEvaluate = { id: number; comment: string; diff_hunk: string }; +import { + openAiRelevanceResponseSchema, + CommentToEvaluate, + Relevances, + ReviewCommentToEvaluate, +} from "../types/content-evaluator-module-type"; /** * Evaluates and rates comments. @@ -143,8 +145,8 @@ export class ContentEvaluatorModule implements Module { specification: string, comments: CommentToEvaluate[], reviewComments: ReviewCommentToEvaluate[] - ): Promise { - let combinedRelevances: RelevancesByOpenAi = {}; + ): Promise { + let combinedRelevances: Relevances = {}; if (comments.length) { const promptForComments = this._generatePromptForComments(specification, comments); @@ -160,7 +162,7 @@ export class ContentEvaluatorModule implements Module { return combinedRelevances; } - async _submitPrompt(prompt: string): Promise { + async _submitPrompt(prompt: string): Promise { const response: OpenAI.Chat.ChatCompletion = await this._openAi.chat.completions.create({ model: "gpt-4o", response_format: { type: "json_object" }, diff --git a/src/types/content-evaluator-module-type.ts b/src/types/content-evaluator-module-type.ts new file mode 100644 index 00000000..57956800 --- /dev/null +++ b/src/types/content-evaluator-module-type.ts @@ -0,0 +1,9 @@ +import { Type, Static } from "@sinclair/typebox"; + +export type CommentToEvaluate = { id: number; comment: string }; + +export type ReviewCommentToEvaluate = { id: number; comment: string; diff_hunk: string }; + +export const openAiRelevanceResponseSchema = Type.Record(Type.String(), Type.Number({ minimum: 0, maximum: 1 })); + +export type Relevances = Static; diff --git a/src/types/openai-type.ts b/src/types/openai-type.ts deleted file mode 100644 index 58190740..00000000 --- a/src/types/openai-type.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Type, Static } from "@sinclair/typebox"; - -const openAiRelevanceResponseSchema = Type.Record(Type.String(), Type.Number({ minimum: 0, maximum: 1 })); - -export type RelevancesByOpenAi = Static; - -export default openAiRelevanceResponseSchema;