Skip to content

Commit

Permalink
fix: set specs relevance as 1
Browse files Browse the repository at this point in the history
  • Loading branch information
EresDev committed Jul 11, 2024
1 parent cd752b7 commit 101d176
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/parser/content-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,34 @@ export class ContentEvaluatorModule implements Module {

async _processComment(comments: Readonly<GithubCommentScore>[], specificationBody: string) {
const commentsWithScore: GithubCommentScore[] = [...comments];
const commentsBody = commentsWithScore.map((comment) => comment.content);

const specificationCommentIndex = commentsWithScore.findIndex((commentWithScore) => {
return !commentWithScore.url.includes("#issuecomment-");
});
let commentsToEvaluate = commentsWithScore;
if (specificationCommentIndex !== -1) {
commentsToEvaluate = commentsWithScore.filter((comment, i) => i != specificationCommentIndex);
}

const commentsBody = commentsToEvaluate.map((comment) => comment.content);
const relevance = await this._evaluateComments(specificationBody, commentsBody);

if (relevance.length !== commentsWithScore.length) {
if (relevance.length !== commentsToEvaluate.length) {
console.error("Relevance / Comment length mismatch! Skipping.");
return [];
}
const relevanceOfAllComments =
specificationCommentIndex === -1
? relevance
: [
...relevance.slice(0, specificationCommentIndex),
new Decimal(1.0),
...relevance.slice(specificationCommentIndex),
];

for (let i = 0; i < relevance.length; i++) {
for (let i = 0; i < relevanceOfAllComments.length; i++) {
const currentComment = commentsWithScore[i];
const currentRelevance = relevance[i];
const currentRelevance = relevanceOfAllComments[i];
const currentReward = new Decimal(currentComment.score?.reward || 0);
currentComment.score = {
...(currentComment.score || {}),
Expand Down Expand Up @@ -106,7 +123,8 @@ export class ContentEvaluatorModule implements Module {
.map((comment) => comment)
.join(
"\n"
)}\n\`\`\`\n\n\nTo what degree are each of the comments in the conversation relevant and valuable to further defining the issue specification? Please reply with ONLY an array of float numbers between 0 and 1, corresponding to each comment in the order they appear. Each float should represent the degree of relevance and added value of the comment to the issue. The total length of the array in your response should equal exactly ${comments.length
} elements.`;
)}\n\`\`\`\n\n\nTo what degree are each of the comments in the conversation relevant and valuable to further defining the issue specification? Please reply with ONLY an array of float numbers between 0 and 1, corresponding to each comment in the order they appear. Each float should represent the degree of relevance and added value of the comment to the issue. The total length of the array in your response should equal exactly ${
comments.length
} elements.`;
}
}

0 comments on commit 101d176

Please sign in to comment.