mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 13:20:39 +08:00
Refactor pr_code_suggestions logic and update prompts for clarity and consistency
This commit is contained in:
@ -347,22 +347,22 @@ class PRCodeSuggestions:
|
|||||||
prediction = await self._get_prediction(model, patches_diff)
|
prediction = await self._get_prediction(model, patches_diff)
|
||||||
prediction_list.append(prediction)
|
prediction_list.append(prediction)
|
||||||
|
|
||||||
|
|
||||||
data = {"code_suggestions": []}
|
data = {"code_suggestions": []}
|
||||||
for predictions in enumerate(prediction_list):
|
for j, predictions in enumerate(prediction_list): # each call adds an element to the list
|
||||||
if "code_suggestions" in enumerate(predictions):
|
if "code_suggestions" in predictions:
|
||||||
score_threshold = max(1,get_settings().pr_code_suggestions.suggestions_score_threshold)
|
score_threshold = max(1, get_settings().pr_code_suggestions.suggestions_score_threshold)
|
||||||
for i, prediction in predictions["code_suggestions"]:
|
for i, prediction in enumerate(predictions["code_suggestions"]):
|
||||||
try:
|
try:
|
||||||
if get_settings().pr_code_suggestions.self_reflect_on_suggestions:
|
if get_settings().pr_code_suggestions.self_reflect_on_suggestions:
|
||||||
score = int(prediction["score"])
|
score = int(prediction["score"])
|
||||||
if score >= score_threshold:
|
if score >= score_threshold:
|
||||||
data["code_suggestions"].append(prediction)
|
data["code_suggestions"].append(prediction)
|
||||||
else:
|
else:
|
||||||
get_logger().info(f"Removing suggestions {i}, because score is {score}, and score_threshold is {score_threshold}",
|
get_logger().info(
|
||||||
|
f"Removing suggestions {i} from call {j}, because score is {score}, and score_threshold is {score_threshold}",
|
||||||
artifact=prediction)
|
artifact=prediction)
|
||||||
else:
|
else:
|
||||||
get_logger().error(f"Error getting PR diff, no code suggestions found in call {i + 1}")
|
data["code_suggestions"].append(prediction)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
get_logger().error(f"Error getting PR diff, error: {e}")
|
get_logger().error(f"Error getting PR diff, error: {e}")
|
||||||
self.data = data
|
self.data = data
|
||||||
|
Reference in New Issue
Block a user