feat: improve code suggestions impact levels with configurable thresholds

This commit is contained in:
mrT23
2025-02-05 09:41:01 +02:00
parent 400146985a
commit 69f19f1abd
2 changed files with 12 additions and 6 deletions

View File

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

View File

@ -794,6 +794,7 @@ class PRCodeSuggestions:
{example_code.rstrip()} {example_code.rstrip()}
""" """
if suggestion.get('score_why'):
pr_body += f"<details><summary>Suggestion importance[1-10]: {suggestion['score']}</summary>\n\n" 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"__\n\nWhy: {suggestion['score_why']}\n\n"
pr_body += f"</details>" pr_body += f"</details>"
@ -801,7 +802,7 @@ class PRCodeSuggestions:
pr_body += f"</details>" pr_body += f"</details>"
# # add another column for 'score' # # add another column for 'score'
score_int = int(suggestion['score']) score_int = int(suggestion.get('score', 0))
score_str = f"{score_int}" score_str = f"{score_int}"
if get_settings().pr_code_suggestions.new_score_mechanism: if get_settings().pr_code_suggestions.new_score_mechanism:
score_str = self.get_score_str(score_int) score_str = self.get_score_str(score_int)
@ -819,9 +820,11 @@ class PRCodeSuggestions:
return "" return ""
def get_score_str(self, score: int) -> str: def get_score_str(self, score: int) -> str:
if score >= 9: 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" return "High"
elif score >= 7: elif score >= th_medium:
return "Medium" return "Medium"
else: # score < 7 else: # score < 7
return "Low" return "Low"