Skip to content

Commit

Permalink
chore: removed log
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Oct 11, 2024
1 parent 4d23b81 commit f9554d2
Showing 1 changed file with 24 additions and 38 deletions.
62 changes: 24 additions & 38 deletions src/parser/content-evaluator-module.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { Value } from "@sinclair/typebox/value";
import Decimal from "decimal.js";
import { encodingForModel } from "js-tiktoken";
import OpenAI from "openai";
import { commentEnum, CommentKind, CommentType } from "../configuration/comment-types";
import configuration from "../configuration/config-reader";
import { OPENAI_API_KEY } from "../configuration/constants";
import {
ContentEvaluatorConfiguration,
contentEvaluatorConfigurationType,
} from "../configuration/content-evaluator-config";
import { IssueActivity } from "../issue-activity";
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 { IssueActivity } from "../issue-activity";
import {
AllComments,
CommentToEvaluate,
openAiRelevanceResponseSchema,
PrCommentToEvaluate,
Relevances,
} from "../types/content-evaluator-module-type";
import { encodingForModel } from "js-tiktoken";
import { GithubCommentScore, Module, Result } from "./processor";

/**
* Evaluates and rates comments.
Expand Down Expand Up @@ -183,40 +183,26 @@ export class ContentEvaluatorModule implements Module {
allComments: AllComments,
prComments: PrCommentToEvaluate[]
): Promise<Relevances> {
// let commentRelevances: Relevances = {};
// let prCommentRelevances: Relevances = {};

console.log("+++ mocking AI +++");
return Promise.resolve(
(() => {
const relevance: { [k: string]: number } = {};
comments.forEach((comment) => {
relevance[`${comment.id}`] = 0.8;
});
prComments.forEach((comment) => {
relevance[`${comment.id}`] = 0.7;
});
return relevance;
})()
);
let commentRelevances: Relevances = {};
let prCommentRelevances: Relevances = {};

if (comments.length) {
const dummyResponse = JSON.stringify(this._generateDummyResponse(comments), null, 2);
const maxTokens = this._calculateMaxTokens(dummyResponse);

const promptForComments = this._generatePromptForComments(specification, comments, allComments);
commentRelevances = await this._submitPrompt(promptForComments, maxTokens);
}

if (prComments.length) {
const dummyResponse = JSON.stringify(this._generateDummyResponse(prComments), null, 2);
const maxTokens = this._calculateMaxTokens(dummyResponse);

const promptForPrComments = this._generatePromptForPrComments(specification, prComments);
prCommentRelevances = await this._submitPrompt(promptForPrComments, maxTokens);
}

// if (comments.length) {
// const dummyResponse = JSON.stringify(this._generateDummyResponse(comments), null, 2);
// const maxTokens = this._calculateMaxTokens(dummyResponse);
//
// const promptForComments = this._generatePromptForComments(specification, comments, allComments);
// commentRelevances = await this._submitPrompt(promptForComments, maxTokens);
// }
//
// if (prComments.length) {
// const dummyResponse = JSON.stringify(this._generateDummyResponse(prComments), null, 2);
// const maxTokens = this._calculateMaxTokens(dummyResponse);
//
// const promptForPrComments = this._generatePromptForPrComments(specification, prComments);
// prCommentRelevances = await this._submitPrompt(promptForPrComments, maxTokens);
// }
//
// return { ...commentRelevances, ...prCommentRelevances };
return { ...commentRelevances, ...prCommentRelevances };
}

async _submitPrompt(prompt: string, maxTokens: number): Promise<Relevances> {
Expand Down

0 comments on commit f9554d2

Please sign in to comment.