Merge pull request #1514 from qodo-ai/tr/improve_impact

feat: improve code suggestions table with impact levels and styling
This commit is contained in:
Tal
2025-02-05 11:20:16 +02:00
committed by GitHub
2 changed files with 24 additions and 6 deletions

View File

@ -121,6 +121,9 @@ max_history_len=4
apply_suggestions_checkbox=true
# suggestions scoring
suggestions_score_threshold=0 # [0-10]| recommend not to set this value above 8, since above it may clip highly relevant suggestions
new_score_mechanism=true
new_score_mechanism_th_high=9
new_score_mechanism_th_medium=7
# params for '/improve --extended' mode
auto_extended_mode=true
num_code_suggestions_per_chunk=4

View File

@ -720,7 +720,7 @@ class PRCodeSuggestions:
header = f"Suggestion"
delta = 66
header += "  " * delta
pr_body += f"""<thead><tr><td>Category</td><td align=left>{header}</td><td align=center>Score</td></tr>"""
pr_body += f"""<thead><tr><td><strong>Category</strong></td><td align=left><strong>{header}</strong></td><td align=center><strong>Impact</strong></td></tr>"""
pr_body += """<tbody>"""
suggestions_labels = dict()
# add all suggestions related to each label
@ -740,7 +740,7 @@ class PRCodeSuggestions:
counter_suggestions = 0
for label, suggestions in suggestions_labels.items():
num_suggestions = len(suggestions)
pr_body += f"""<tr><td rowspan={num_suggestions}><strong>{label.capitalize()}</strong></td>\n"""
pr_body += f"""<tr><td rowspan={num_suggestions}>{label.capitalize()}</td>\n"""
for i, suggestion in enumerate(suggestions):
relevant_file = suggestion['relevant_file'].strip()
@ -794,14 +794,19 @@ class PRCodeSuggestions:
{example_code.rstrip()}
"""
pr_body += f"<details><summary>Suggestion importance[1-10]: {suggestion['score']}</summary>\n\n"
pr_body += f"Why: {suggestion['score_why']}\n\n"
pr_body += f"</details>"
if suggestion.get('score_why'):
pr_body += f"<details><summary>Suggestion importance[1-10]: {suggestion['score']}</summary>\n\n"
pr_body += f"__\n\nWhy: {suggestion['score_why']}\n\n"
pr_body += f"</details>"
pr_body += f"</details>"
# # add another column for 'score'
pr_body += f"</td><td align=center>{suggestion['score']}\n\n"
score_int = int(suggestion.get('score', 0))
score_str = f"{score_int}"
if get_settings().pr_code_suggestions.new_score_mechanism:
score_str = self.get_score_str(score_int)
pr_body += f"</td><td align=center>{score_str}\n\n"
pr_body += f"</td></tr>"
counter_suggestions += 1
@ -814,6 +819,16 @@ class PRCodeSuggestions:
get_logger().info(f"Failed to publish summarized code suggestions, error: {e}")
return ""
def get_score_str(self, score: int) -> str:
th_high = get_settings().pr_code_suggestions.get('new_score_mechanism_th_high', 9)
th_medium = get_settings().pr_code_suggestions.get('new_score_mechanism_th_medium', 7)
if score >= th_high:
return "High"
elif score >= th_medium:
return "Medium"
else: # score < 7
return "Low"
async def self_reflect_on_suggestions(self,
suggestion_list: List,
patches_diff: str,