Skip to content

Commit

Permalink
fix: set relevance to multiply the whole result (revert 8c4fe1b)
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Dec 18, 2024
1 parent 85029f0 commit d5838e6
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 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
);
// eslint-disable-next-line sonarjs/prefer-nullish-coalescing
const currentReward = new Decimal(currentComment.score?.reward || 0);

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

Expand Down

0 comments on commit d5838e6

Please sign in to comment.