Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set relevance to multiply the whole result (revert 8c4fe1b5) #222

2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

22 changes: 4 additions & 18 deletions src/parser/content-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,6 @@ export class ContentEvaluatorModule extends BaseModule {
return result;
}

_getRewardForComment(comment: GithubCommentScore, relevance: number) {
let reward = new Decimal(comment?.score?.reward ?? 0);

if (comment?.score?.formatting && comment.score.multiplier && comment.score.words) {
let totalRegexReward = new Decimal(0);
totalRegexReward = totalRegexReward.add(comment.score.words.result);
totalRegexReward = totalRegexReward.mul(comment.score.multiplier);
const totalRegexRewardWithRelevance = totalRegexReward.mul(relevance);
reward = reward.sub(totalRegexReward).add(totalRegexRewardWithRelevance);
}
return reward;
}

async _processComment(comments: Readonly<GithubCommentScore>[], specificationBody: string, allComments: AllComments) {
const commentsWithScore: GithubCommentScore[] = [...comments];
const { commentsToEvaluate, prCommentsToEvaluate } = this._splitCommentsByPrompt(commentsWithScore);
Expand Down Expand Up @@ -124,15 +111,14 @@ export class ContentEvaluatorModule extends BaseModule {
currentRelevance = relevancesByAi[currentComment.id];
}

const currentReward = this._getRewardForComment(currentComment, currentRelevance).mul(
currentComment.score?.priority ?? 1
);
const currentReward = new Decimal(currentComment.score?.reward ?? 0);
const priority = currentComment.score?.priority ?? 1;

currentComment.score = {
...(currentComment.score || { multiplier: 0 }),
relevance: new Decimal(currentRelevance).toNumber(),
priority: currentComment.score?.priority ?? 1,
reward: currentReward.toNumber(),
priority: priority,
reward: currentReward.mul(currentRelevance).mul(priority).toDecimalPlaces(3).toNumber(),
};
}

Expand Down
Loading