diff --git a/pr_agent/settings/pr_code_suggestions_reflect_prompts.toml b/pr_agent/settings/pr_code_suggestions_reflect_prompts.toml index b0e163b3..96e0ea1c 100644 --- a/pr_agent/settings/pr_code_suggestions_reflect_prompts.toml +++ b/pr_agent/settings/pr_code_suggestions_reflect_prompts.toml @@ -9,6 +9,7 @@ Specific instructions: - Carefully review both the suggestion content, and the related PR code diff. Mistakes in the suggestions can occur. Make sure the suggestions are correct, and properly derived from the PR code diff. - In addition to the exact code lines mentioned in each suggestion, review the code around them, to ensure that the suggestions are contextually accurate. - Also check that the 'existing_code' and 'improved_code' fields correctly reflect the suggested changes. +- Make sure the suggestions focus on new code introduced in the PR, and not on existing code that was not changed. - High scores (8 to 10) should be given to correct suggestions that address major bugs and issues, or security concerns. Lower scores (3 to 7) should be for correct suggestions addressing minor issues, code style, code readability, maintainability, etc. Don't give high scores to suggestions that are not crucial, and bring only small improvement or optimization. - Order the feedback the same way the suggestions are ordered in the input. diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 908bce3a..46d74d9f 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -86,8 +86,10 @@ class PRCodeSuggestions: data = await retry_with_fallback_models(self._prepare_prediction, ModelType.TURBO) else: data = await retry_with_fallback_models(self._prepare_prediction_extended, ModelType.TURBO) + if not data: + data = {"code_suggestions": []} - if not data or not data.get('code_suggestions'): + if data is None or 'code_suggestions' not in data or not data['code_suggestions']: get_logger().error('No code suggestions found for PR.') pr_body = "## PR Code Suggestions ✨\n\nNo code suggestions found for PR." get_logger().debug(f"PR output", artifact=pr_body) @@ -423,10 +425,10 @@ class PRCodeSuggestions: pr_body += "" header = f"Suggestion" - delta = 68 + delta = 64 header += "  " * delta if get_settings().pr_code_suggestions.self_reflect_on_suggestions: - pr_body += f"""""" + pr_body += f"""""" else: pr_body += f"""""" pr_body += """""" @@ -441,6 +443,9 @@ class PRCodeSuggestions: # sort suggestions_labels by the suggestion with the highest score if get_settings().pr_code_suggestions.self_reflect_on_suggestions: suggestions_labels = dict(sorted(suggestions_labels.items(), key=lambda x: max([s['score'] for s in x[1]]), reverse=True)) + # sort the suggestions inside each label group by score + for label, suggestions in suggestions_labels.items(): + suggestions_labels[label] = sorted(suggestions, key=lambda x: x['score'], reverse=True) for label, suggestions in suggestions_labels.items():
Category{header}Importance
Category{header}Score
Category{header}