This commit is contained in:
mrT23
2024-05-12 14:40:25 +03:00
parent 39c0733d6f
commit 8e0435d9a0

View File

@ -328,22 +328,20 @@ class PRCodeSuggestions:
data = {"code_suggestions": []} data = {"code_suggestions": []}
for i, prediction in enumerate(prediction_list): for i, predictions in enumerate(prediction_list):
try: if "code_suggestions" in predictions:
if "code_suggestions" in prediction: for prediction in predictions["code_suggestions"]:
if get_settings().pr_code_suggestions.self_reflect_on_suggestions: try:
score = int(prediction["code_suggestions"][0]["score"]) if get_settings().pr_code_suggestions.self_reflect_on_suggestions:
if score > 0: score = int(prediction["score"])
data["code_suggestions"].extend(prediction["code_suggestions"]) if score > 0:
data["code_suggestions"].append(prediction)
else:
get_logger().info(f"Skipping suggestions from call {i + 1}, because score is {score}")
else: else:
get_logger().info(f"Skipping suggestions from call {i + 1}, because score is {score}") get_logger().error(f"Error getting PR diff, no code suggestions found in call {i + 1}")
else: except Exception as e:
data["code_suggestions"].extend(prediction["code_suggestions"]) get_logger().error(f"Error getting PR diff, error: {e}")
else:
get_logger().error(f"Error getting PR diff, no code suggestions found in call {i + 1}")
except Exception as e:
get_logger().error(f"Error getting PR diff, error: {e}")
data = None
self.data = data self.data = data
else: else:
get_logger().error(f"Error getting PR diff") get_logger().error(f"Error getting PR diff")
@ -428,7 +426,7 @@ class PRCodeSuggestions:
delta = 68 delta = 68
header += "  " * delta header += "  " * delta
if get_settings().pr_code_suggestions.self_reflect_on_suggestions: 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>Score</td></tr>""" pr_body += f"""<thead><tr><td>Category</td><td align=left>{header}</td><td align=center>Importance</td></tr>"""
else: else:
pr_body += f"""<thead><tr><td>Category</td><td align=left>{header}</td></tr>""" pr_body += f"""<thead><tr><td>Category</td><td align=left>{header}</td></tr>"""
pr_body += """<tbody>""" pr_body += """<tbody>"""