Skip to content

Commit

Permalink
refactor: move types to correct file
Browse files Browse the repository at this point in the history
  • Loading branch information
EresDev committed Aug 13, 2024
1 parent b223454 commit 3d32bc9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
16 changes: 9 additions & 7 deletions src/parser/content-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -143,8 +145,8 @@ export class ContentEvaluatorModule implements Module {
specification: string,
comments: CommentToEvaluate[],
reviewComments: ReviewCommentToEvaluate[]
): Promise<RelevancesByOpenAi> {
let combinedRelevances: RelevancesByOpenAi = {};
): Promise<Relevances> {
let combinedRelevances: Relevances = {};

if (comments.length) {
const promptForComments = this._generatePromptForComments(specification, comments);
Expand All @@ -160,7 +162,7 @@ export class ContentEvaluatorModule implements Module {
return combinedRelevances;
}

async _submitPrompt(prompt: string): Promise<RelevancesByOpenAi> {
async _submitPrompt(prompt: string): Promise<Relevances> {
const response: OpenAI.Chat.ChatCompletion = await this._openAi.chat.completions.create({
model: "gpt-4o",
response_format: { type: "json_object" },
Expand Down
9 changes: 9 additions & 0 deletions src/types/content-evaluator-module-type.ts
Original file line number Diff line number Diff line change
@@ -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<typeof openAiRelevanceResponseSchema>;
7 changes: 0 additions & 7 deletions src/types/openai-type.ts

This file was deleted.

0 comments on commit 3d32bc9

Please sign in to comment.