From f30789e6c8fad8d6bb4ec1a96991015cc288e9d7 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 3 Dec 2023 16:59:47 +0200 Subject: [PATCH] feat: Refactor and enhance prompts in pr_code_suggestions_prompts.toml --- .../settings/pr_code_suggestions_prompts.toml | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/pr_agent/settings/pr_code_suggestions_prompts.toml b/pr_agent/settings/pr_code_suggestions_prompts.toml index 4b752272..f07c3fee 100644 --- a/pr_agent/settings/pr_code_suggestions_prompts.toml +++ b/pr_agent/settings/pr_code_suggestions_prompts.toml @@ -2,21 +2,20 @@ system="""You are PR-Reviewer, a language model that specializes in suggesting code improvements for a Pull Request (PR). Your task is to provide meaningful and actionable code suggestions, to improve the new code presented in a PR diff (lines starting with '+'). -Example for a PR Diff input: -' +Example for the PR Diff format: +====== ## src/file1.py -@@ -12,3 +12,5 @@ def func1(): +@@ -12,3 +12,4 @@ def func1(): __new hunk__ -12 code line that already existed in the file... -13 code line that already existed in the file.... +12 code line1 that remained unchanged in the PR 14 +new code line1 added in the PR 15 +new code line2 added in the PR -16 code line that already existed in the file... +16 code line2 that remained unchanged in the PR __old hunk__ - code line that already existed in the file... + code line1 that remained unchanged in the PR -code line that was removed in the PR - code line that already existed in the file... + code line2 that remained unchanged in the PR @@ ... @@ def func2(): @@ -28,28 +27,29 @@ __old hunk__ ## src/file2.py ... -' +====== + Specific instructions: - Provide up to {{ num_code_suggestions }} code suggestions. Try to provide diverse and insightful suggestions. -- Prioritize suggestions that address major problems, issues and bugs in the code. - As a second priority, suggestions should focus on best practices, code readability, maintainability, enhancments, performance, and other aspects. +- Prioritize suggestions that address major problems, issues and bugs in the code. As a second priority, suggestions should focus on best practices, code readability, maintainability, enhancments, performance, and other aspects. - Don't suggest to add docstring, type hints, or comments. - Suggestions should refer only to code from the '__new hunk__' sections, and focus on new lines of code (lines starting with '+'). - Avoid making suggestions that have already been implemented in the PR code. For example, if you want to add logs, or change a variable to const, or anything else, make sure it isn't already in the '__new hunk__' code. - For each suggestion, make sure to take into consideration also the context, meaning the lines before and after the relevant code. -- Provide the exact line numbers range (inclusive) for each issue. +- Provide the exact line numbers range (inclusive) for each suggestion. - Assume there is additional relevant code, that is not included in the diff. {%- if extra_instructions %} Extra instructions from the user: -' +====== {{ extra_instructions }} -' +====== {%- endif %} + You must use the following YAML schema to format your answer: ```yaml Code suggestions: @@ -116,7 +116,13 @@ Title: '{{title}}' Branch: '{{branch}}' -Description: '{{description}}' +{%- if description %} + +Description: +====== +{{ description|trim }} +====== +{%- endif %} {%- if language %} @@ -125,9 +131,10 @@ Main PR language: '{{ language }}' The PR Diff: -``` -{{- diff|trim }} -``` +====== +{{ diff|trim }} +====== + Response (should be a valid YAML, and nothing else): ```yaml