Skip to content

Commit

Permalink
Merge pull request #222 from gentlementlegen/fix/relevance-multiplier
Browse files Browse the repository at this point in the history
fix: set relevance to multiply the whole result (revert 8c4fe1b)
  • Loading branch information
gentlementlegen authored Dec 20, 2024
2 parents 85029f0 + 696958a commit 3f2fea1
Show file tree
Hide file tree
Showing 10 changed files with 281 additions and 295 deletions.
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

0 comments on commit 3f2fea1

Please sign in to comment.