From b076c33351c5a622aa73fd54996e710adeff895f Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 17 Apr 2024 15:32:45 +0300 Subject: [PATCH] commitable_code_suggestions --- .pr_agent.toml | 2 +- docs/docs/tools/improve.md | 6 +++--- docs/docs/usage-guide/automations_and_usage.md | 2 +- pr_agent/settings/configuration.toml | 8 ++++---- pr_agent/tools/pr_code_suggestions.py | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.pr_agent.toml b/.pr_agent.toml index 29c5489a..0d1d9914 100644 --- a/.pr_agent.toml +++ b/.pr_agent.toml @@ -4,4 +4,4 @@ enable_auto_approval = true [pr_code_suggestions] -summarize=true +commitable_code_suggestions=false diff --git a/docs/docs/tools/improve.md b/docs/docs/tools/improve.md index b62fd649..2869b180 100644 --- a/docs/docs/tools/improve.md +++ b/docs/docs/tools/improve.md @@ -7,11 +7,11 @@ The tool can be triggered automatically every time a new PR is [opened](../usage ### Summarized vs committable code suggestions -The code suggestions can be presented as a single comment (via `pr_code_suggestions.summarize=true`): +The code suggestions can be presented as a single comment ![code suggestions as comment](https://codium.ai/images/pr_agent/code_suggestions_as_comment.png){width=512} -Or as a separate commitable code comment for each suggestion: +Or as a separate commitable code comment for each suggestion (via `pr_code_suggestions.commitable_code_suggestions=true`):: ![imporove](https://codium.ai/images/pr_agent/improve.png){width=512} @@ -58,7 +58,7 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen - `num_code_suggestions_per_chunk`: number of code suggestions provided by the 'improve' tool, per chunk. Default is 5. - `rank_extended_suggestions`: if set to true, the tool will rank the suggestions, based on importance. Default is true. - `max_number_of_calls`: maximum number of chunks. Default is 5. - - `final_clip_factor`: factor to remove suggestions with low confidence. Default is 0.9. + - `final_clip_factor`: factor to remove suggestions with low confidence. Default is 0.9.; ## Usage Tips diff --git a/docs/docs/usage-guide/automations_and_usage.md b/docs/docs/usage-guide/automations_and_usage.md index 14992611..d7a009e0 100644 --- a/docs/docs/usage-guide/automations_and_usage.md +++ b/docs/docs/usage-guide/automations_and_usage.md @@ -170,7 +170,7 @@ Specifically, set the following values: [bitbucket_app] pr_commands = [ "/review --pr_reviewer.num_code_suggestions=0", - "/improve --pr_code_suggestions.summarize=false", + "/improve --pr_code_suggestions.commitable_code_suggestions=true", ] ``` diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 4ab511c1..01646ff4 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -80,7 +80,7 @@ enable_help_text=true [pr_code_suggestions] # /improve # max_context_tokens=8000 num_code_suggestions=4 -summarize = true +commitable_code_suggestions = false extra_instructions = "" rank_suggestions = false enable_help_text=true @@ -150,7 +150,7 @@ handle_pr_actions = ['opened', 'reopened', 'ready_for_review'] pr_commands = [ "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", "/review --pr_reviewer.num_code_suggestions=0", - "/improve --pr_code_suggestions.summarize=true", + "/improve", ] # settings for "pull_request" event with "synchronize" action - used to detect and handle push triggers for new commits handle_push_trigger = false @@ -171,13 +171,13 @@ url = "https://gitlab.com" # URL to the gitlab service pr_commands = [ "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", "/review --pr_reviewer.num_code_suggestions=0", - "/improve --pr_code_suggestions.summarize=true", + "/improve", ] [bitbucket_app] pr_commands = [ "/review --pr_reviewer.num_code_suggestions=0", - "/improve --pr_code_suggestions.summarize=false", + "/improve --pr_code_suggestions.commitable_code_suggestions=true", ] diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index ed14d225..813ccbfa 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -57,7 +57,7 @@ class PRCodeSuggestions: "language": self.main_language, "diff": "", # empty diff for initial calculation "num_code_suggestions": num_code_suggestions, - "summarize_mode": get_settings().pr_code_suggestions.summarize, + "commitable_code_suggestions_mode": get_settings().pr_code_suggestions.commitable_code_suggestions, "extra_instructions": get_settings().pr_code_suggestions.extra_instructions, "commit_messages_str": self.git_provider.get_commit_messages(), } @@ -105,7 +105,7 @@ class PRCodeSuggestions: if get_settings().config.publish_output: self.git_provider.remove_initial_comment() - if get_settings().pr_code_suggestions.summarize and self.git_provider.is_supported("gfm_markdown"): + if (not get_settings().pr_code_suggestions.commitable_code_suggestions) and self.git_provider.is_supported("gfm_markdown"): # generate summarized suggestions pr_body = self.generate_summarized_suggestions(data) @@ -197,7 +197,7 @@ class PRCodeSuggestions: one_sentence_summary_list = [] for i, suggestion in enumerate(data['code_suggestions']): try: - if get_settings().pr_code_suggestions.summarize: + if not get_settings().pr_code_suggestions.commitable_code_suggestions: if not suggestion or 'one_sentence_summary' not in suggestion or 'label' not in suggestion or 'relevant_file' not in suggestion: get_logger().debug(f"Skipping suggestion {i + 1}, because it is invalid: {suggestion}") continue @@ -213,7 +213,7 @@ class PRCodeSuggestions: if ('existing_code' in suggestion) and ('improved_code' in suggestion) and ( suggestion['existing_code'] != suggestion['improved_code']): suggestion = self._truncate_if_needed(suggestion) - if get_settings().pr_code_suggestions.summarize: + if not get_settings().pr_code_suggestions.commitable_code_suggestions: one_sentence_summary_list.append(suggestion['one_sentence_summary']) suggestion_list.append(suggestion) else: