From f89bfddf79ad28516386291b6fc5c987c4642365 Mon Sep 17 00:00:00 2001 From: Emanuel Braz Date: Wed, 8 Nov 2023 19:51:30 -0300 Subject: [PATCH] feat: testing different prompts --- .github/workflows/code-review.yaml | 5 +++-- code-review/action.js | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/code-review.yaml b/.github/workflows/code-review.yaml index faeea9c..72a2bf3 100644 --- a/.github/workflows/code-review.yaml +++ b/.github/workflows/code-review.yaml @@ -24,5 +24,6 @@ jobs: max_tokens: 900 exclude: "**/*.json, **/*.md, **/*.g.dart" append_prompt: | - - Give a minimum of 0 suggestions and a maximum of 5 suggestions. - - Translate the comment in all "reviewComment" properties to portuguese (pt-br). \ No newline at end of file + - Give a maximum of 4 suggestions + - Do not suggest code formatting issues. + - Do not suggest imports issues. \ No newline at end of file diff --git a/code-review/action.js b/code-review/action.js index 7ed435b..bdb1d2b 100644 --- a/code-review/action.js +++ b/code-review/action.js @@ -62,6 +62,7 @@ async function analyzeCode(parsedDiff, prDetails) { for (const file of parsedDiff) { if (file.to === "/dev/null") continue; // Ignore deleted files for (const chunk of file.chunks) { + logger.log(`Analyzing chunk: ${chunk.changes}\n------------------`); const messages = createMessages(file, chunk, prDetails); const aiResponse = await getAIResponse(messages); if (aiResponse) { @@ -79,13 +80,12 @@ function createMessages(file, chunk, prDetails) { const instructionJsonFormat = `- Always provide the response in following JSON format: [{"lineNumber": , "reviewComment": ""}]`; var contentSystemMessage = `You are a senior software engineer and your task is to review pull requests for possible bugs or bad development practices. Follow the instructions below: -- You should never give positive comments or compliments. -- You should never suggest removing empty line. -- You should not suggest adding a new line at the end of the file. -- You should never suggest to remove trailing or leading whitespace. -- You should never suggest adding comment to code. -- Avoid giving an excessive amount of suggestions for a single file. Prioritize the most important suggestions. - You will provide suggestions only if there is possible issues or bugs in the code, otherwise return an empty array. +- Do not give positive comments or compliments. +- Don't suggest removing empty line or adding line to end of file +- Don't suggest to remove trailing or leading whitespace. +- Don't suggest to remove the spaces. +- Don't suggest adding comment to code. - Do use the given pull request title and description only for the overall context and only comment the code.`; if (overridePrompt) {