Skip to content

Commit 8bfd0a1

Browse files
committed
feat: enhance label determination logic in addLabel.ts
- Updated the label determination logic to include a new helper function, `isValidShortResponse`, which checks for valid short responses before categorizing them as 'Spam'. - This change improves the accuracy of label assignment based on the content of the response, ensuring that valid short responses are not incorrectly flagged. These enhancements aim to provide more precise labeling in PR analysis, improving the overall functionality of the application. Signed-off-by: Sky Singh <akashsingh2210670@gmail.com>
1 parent 817708e commit 8bfd0a1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

keploy-github-app-beta/src/addLabel.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,22 @@ export async function determineLabelFromAnalysis(llmResponse: string): Promise<s
2929

3030
if (lowerResponse.includes('lgtm!')) {
3131
return 'LGTM';
32-
} else if (lowerResponse.includes('spam') || lowerResponse.length < 10) {
32+
} else if (lowerResponse.includes('spam') ||
33+
(lowerResponse.length < 10 && !isValidShortResponse(lowerResponse))) {
3334
return 'Spam';
3435
} else {
3536
return 'Needs Changes';
3637
}
3738
}
3839

40+
// Helper function to identify valid short responses
41+
function isValidShortResponse(response: string): boolean {
42+
const validShortResponses = [
43+
'ok', 'yes', 'no', 'good', 'fine', 'nice', 'approved', '+1'
44+
];
45+
return validShortResponses.some(valid => response.includes(valid));
46+
}
47+
3948
export async function addLabelToPR(
4049
context: GithubContext,
4150
prNumber: number,

0 commit comments

Comments
 (0)