Skip to content

Commit

Permalink
Update content-evaluator-module.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
sura1-0-1 authored Dec 21, 2024
1 parent 2029fcf commit 9e39edf
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 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 Expand Up @@ -273,7 +259,8 @@ export class ContentEvaluatorModule extends BaseModule {
- Ignore text beginning with '>' as it references another comment
- Distinguish between referenced text and the commenter's own words
- Only evaluate the relevance of the commenter's original content
6. Return only a JSON object: {ID: score}
6. Comments from the user "gentlementlegen" should be scored low as they are not relevant to the task at hand.
7. Return only a JSON object: {ID: score}
Notes:
- Even minor details may be significant.
Expand All @@ -286,15 +273,10 @@ export class ContentEvaluatorModule extends BaseModule {
if (!issue?.length) {
throw new Error("Issue specification comment is missing or empty");
}
return `I need to evaluate the value of a GitHub contributor's comments in a pull request. Some of these comments are code review comments, and some are general suggestions or a part of the discussion. I'm interested in how much each comment helps to solve the GitHub issue and improve code quality. Please provide a float between 0 and 1 to represent the value of each comment. A score of 1 indicates that the comment is very valuable and significantly improves the submitted solution and code quality, whereas a score of 0 indicates a negative or zero impact. A stringified JSON is given below that contains the specification of the GitHub issue, and comments by different contributors. The property "diffHunk" presents the chunk of code being addressed for a possible change in a code review comment.
Please note that comments from the user @gentlementlegen should be scored low, as they are not relevant to the task at hand.
\`\`\`\n${JSON.stringify(
return `I need to evaluate the value of a GitHub contributor's comments in a pull request. Some of these comments are code review comments, and some are general suggestions or a part of the discussion. I'm interested in how much each comment helps to solve the GitHub issue and improve code quality. Please provide a float between 0 and 1 to represent the value of each comment. A score of 1 indicates that the comment is very valuable and significantly improves the submitted solution and code quality, whereas a score of 0 indicates a negative or zero impact. A stringified JSON is given below that contains the specification of the GitHub issue, and comments by different contributors. The property "diffHunk" presents the chunk of code being addressed for a possible change in a code review comment. \n\n\`\`\`\n${JSON.stringify(
{ specification: issue, comments: comments }
)}\n\`\`\`\n\n\nTo what degree are each of the comments valuable? Please reply with ONLY a JSON where each key is the comment ID given in JSON above, and the value is a float number between 0 and 1 corresponding to the comment. The float number should represent the value of the comment for improving the issue solution and code quality. The total number of properties in your JSON response should equal exactly ${
comments.length
}.`;
}.`;
}

}

0 comments on commit 9e39edf

Please sign in to comment.