From bc09330a44c5b11860b4cd2ea9865078ada9e879 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 17 Jun 2024 20:26:09 +0300 Subject: [PATCH] Add self-review checkbox functionality to improve tool and update documentation --- README.md | 15 ++++++--------- docs/docs/tools/improve.md | 24 ++++++++++++++++++++++++ pr_agent/settings/configuration.toml | 4 ++++ pr_agent/tools/pr_code_suggestions.py | 7 +++++++ 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 02e9b884..7d18fa31 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,12 @@ CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by p ## News and Updates +### June 17, 2024 + +New option for a self-review checkbox is now available for the `/improve` tool, along with the option to demand self-review (💎). See more [here](https://pr-agent-docs.codium.ai/tools/improve/#self-review) + + + ### June 6, 2024 New option now available (💎) - **apply suggestions**: @@ -58,15 +64,6 @@ New option now available (💎) - **apply suggestions**: Check out the new [**PR-Agent Code Fine-tuning Benchmark**](https://pr-agent-docs.codium.ai/finetuning_benchmark/) -### May 23, 2024 - -We released a new version of [PR-Agent Chrome extension](https://chromewebstore.google.com/detail/pr-agent-chrome-extension/ephlnjeghhogofkifjloamocljapahnl), with two new features: - -- PR-Agent filters 🎨 -- Code suggestions interactions 🔗 - -See more [here](https://www.youtube.com/watch?v=v9bJ1frtPcg) - ## Overview
diff --git a/docs/docs/tools/improve.md b/docs/docs/tools/improve.md index 21ea6058..146d709a 100644 --- a/docs/docs/tools/improve.md +++ b/docs/docs/tools/improve.md @@ -59,6 +59,30 @@ auto_extended_mode=true Note that the extended mode divides the PR code changes into chunks, up to the token limits, where each chunk is handled separately (might use multiple calls to GPT-4 for large PRs). Hence, the total number of suggestions is proportional to the number of chunks, i.e., the size of the PR. +### Self-review +if you set in a configuration file: +``` +[pr_code_suggestions] +demand_code_suggestions_self_review = true +``` +The `improve` tool will add a checkbox below the suggestions, asking the user to confirm that they have reviewed the suggestions. +You can control the content of the checkbox text by setting: +``` +[pr_code_suggestions] +code_suggestions_self_review_text = "... (your text here) ..." +``` +![self_review_1](https://codium.ai/images/pr_agent/self_review_1.png){width=512} + +In addition, a configuration flag of: +``` +[pr_code_suggestions] +approve_pr_on_self_review = true +``` +enables the tool to automatically approve the PR when the user checks the self-review checkbox. + +!!! tip "Demanding self-review from the PR author" + If you set the number of required reviewers for a PR to 2, this effectively means that the PR author must click the self-review checkbox before the PR can be merged (in addition to a human reviewer). + ![self_review_2](https://codium.ai/images/pr_agent/self_review_2.png){width=512} ## Configuration options diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 0fa85013..74dcc142 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -100,6 +100,10 @@ max_number_of_calls = 3 parallel_calls = true rank_extended_suggestions = false final_clip_factor = 0.8 +# self-review checkbox +demand_code_suggestions_self_review=false # add a checkbox for the author to self-review the code suggestions +code_suggestions_self_review_text= "**Author self-review**: I have reviewed the PR code suggestions, and addressed the relevant ones." +approve_pr_on_self_review=false # Pro feature. if true, the PR will be auto-approved after the author clicks on the self-review checkbox [pr_add_docs] # /add_docs # extra_instructions = "" diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 358f2992..c92859c0 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -112,6 +112,13 @@ class PRCodeSuggestions: pr_body = self.generate_summarized_suggestions(data) get_logger().debug(f"PR output", artifact=pr_body) + # require self-review + if get_settings().pr_code_suggestions.demand_code_suggestions_self_review: + text= get_settings().pr_code_suggestions.code_suggestions_self_review_text + pr_body += f"\n\n- [ ] {text}" + if get_settings().pr_code_suggestions.approve_pr_on_self_review: + pr_body += ' ' + # add usage guide if get_settings().pr_code_suggestions.enable_help_text: pr_body += "
\n\n
💡 Tool usage guide:
\n\n"