From 4f6490b17caf47252303ca06b4d47b19c8cf3aee Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 12 May 2024 16:17:47 +0300 Subject: [PATCH 1/2] Integrate self-reflection feature in PR-Agent, enhancing code suggestions with scoring and sorting, and update documentation accordingly --- README.md | 9 +++++++++ docs/docs/tools/improve.md | 4 ++++ pr_agent/tools/pr_code_suggestions.py | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 097eb37b..3dca2fa2 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,15 @@ CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by p ## News and Updates +### May 12, 2024 +Inspired by [AlphaCodium](https://github.com/Codium-ai/AlphaCodium) flow engineering scheme, PR-Agent now performs **self-reflection** on the code suggestions it provides, +enabling to remove invalid suggestions, and score the valid ones. The suggestions will be presented sorted by their score, enabling to focus on the most important ones first. + + + + + + ### May 2, 2024 Check out the new [PR-Agent Chrome Extension](https://chromewebstore.google.com/detail/pr-agent-chrome-extension/ephlnjeghhogofkifjloamocljapahnl) 🚀🚀🚀 diff --git a/docs/docs/tools/improve.md b/docs/docs/tools/improve.md index 96001490..e8b4dd6f 100644 --- a/docs/docs/tools/improve.md +++ b/docs/docs/tools/improve.md @@ -86,6 +86,10 @@ Hence, the total number of suggestions is proportional to the number of chunks, persistent_comment If set to true, the improve comment will be persistent, meaning that every new improve request will edit the previous one. Default is false. + + self_reflect_on_suggestions + If set to true, the improve tool will calculate an importance score for each suggestion [1-10], and sort the suggestion labels group based on this score. Default is true. + enable_help_text If set to true, the tool will display a help text in the comment. Default is true. diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 1d828fa5..77a4280e 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -351,7 +351,8 @@ class PRCodeSuggestions: if score > 0: data["code_suggestions"].append(prediction) else: - get_logger().info(f"Skipping suggestions from call {i + 1}, because score is {score}") + get_logger().info(f"Removing suggestions {i}, because score is {score}", + artifact={"prediction": prediction}) else: get_logger().error(f"Error getting PR diff, no code suggestions found in call {i + 1}") except Exception as e: From 61ba015a5597b3358c474853a84b319d6b06d3c4 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 12 May 2024 16:22:40 +0300 Subject: [PATCH 2/2] artifact --- pr_agent/tools/pr_code_suggestions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 77a4280e..a192e80d 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -352,7 +352,7 @@ class PRCodeSuggestions: data["code_suggestions"].append(prediction) else: get_logger().info(f"Removing suggestions {i}, because score is {score}", - artifact={"prediction": prediction}) + artifact=prediction) else: get_logger().error(f"Error getting PR diff, no code suggestions found in call {i + 1}") except Exception as e: