mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 12:20:38 +08:00
s
This commit is contained in:
@ -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.
|
||||
|
||||
|
@ -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 += "<table>"
|
||||
header = f"Suggestion"
|
||||
delta = 68
|
||||
delta = 64
|
||||
header += " " * delta
|
||||
if get_settings().pr_code_suggestions.self_reflect_on_suggestions:
|
||||
pr_body += f"""<thead><tr><td>Category</td><td align=left>{header}</td><td align=center>Importance</td></tr>"""
|
||||
pr_body += f"""<thead><tr><td>Category</td><td align=left>{header}</td><td align=center>Score</td></tr>"""
|
||||
else:
|
||||
pr_body += f"""<thead><tr><td>Category</td><td align=left>{header}</td></tr>"""
|
||||
pr_body += """<tbody>"""
|
||||
@ -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():
|
||||
|
Reference in New Issue
Block a user