From 0c654b3b64a917ab5f01401f76a3c69bae1fc497 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 28 Feb 2024 08:41:25 +0200 Subject: [PATCH 1/4] handle unsupported platforms for update changelog --- pr_agent/tools/pr_update_changelog.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pr_agent/tools/pr_update_changelog.py b/pr_agent/tools/pr_update_changelog.py index dc9d72e4..3d2ad2c7 100644 --- a/pr_agent/tools/pr_update_changelog.py +++ b/pr_agent/tools/pr_update_changelog.py @@ -9,7 +9,7 @@ from pr_agent.algo.ai_handlers.litellm_ai_handler import LiteLLMAIHandler from pr_agent.algo.pr_processing import get_pr_diff, retry_with_fallback_models from pr_agent.algo.token_handler import TokenHandler from pr_agent.config_loader import get_settings -from pr_agent.git_providers import get_git_provider +from pr_agent.git_providers import get_git_provider, GithubProvider from pr_agent.git_providers.git_provider import get_main_pr_language from pr_agent.log import get_logger @@ -46,12 +46,19 @@ class PRUpdateChangelog: get_settings().pr_update_changelog_prompt.user) async def run(self): - # assert type(self.git_provider) == GithubProvider, "Currently only Github is supported" - get_logger().info('Updating the changelog...') relevant_configs = {'pr_update_changelog': dict(get_settings().pr_update_changelog), 'config': dict(get_settings().config)} get_logger().debug("Relevant configs", artifacts=relevant_configs) + + # currently only GitHub is supported for pushing changelog changes + if get_settings().pr_update_changelog.push_changelog_changes and type(self.git_provider) != GithubProvider: + get_logger().error("Pushing changelog changes is not currently supported for this code platform") + if get_settings().config.publish_output: + self.git_provider.publish_comment( + "Pushing changelog changes is not currently supported for this code platform") + return + if get_settings().config.publish_output: self.git_provider.publish_comment("Preparing changelog updates...", is_temporary=True) From 39538c5356c202af49ac9aa24fb1119b8c7c80b8 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 28 Feb 2024 09:01:39 +0200 Subject: [PATCH 2/4] cleaning --- pr_agent/tools/pr_generate_labels.py | 7 ------- pr_agent/tools/pr_reviewer.py | 1 - 2 files changed, 8 deletions(-) diff --git a/pr_agent/tools/pr_generate_labels.py b/pr_agent/tools/pr_generate_labels.py index a606ab4a..1d91d5e0 100644 --- a/pr_agent/tools/pr_generate_labels.py +++ b/pr_agent/tools/pr_generate_labels.py @@ -139,10 +139,6 @@ class PRGenerateLabels: system_prompt = environment.from_string(get_settings().pr_custom_labels_prompt.system).render(variables) user_prompt = environment.from_string(get_settings().pr_custom_labels_prompt.user).render(variables) - if get_settings().config.verbosity_level >= 2: - get_logger().info(f"\nSystem prompt:\n{system_prompt}") - get_logger().info(f"\nUser prompt:\n{user_prompt}") - response, finish_reason = await self.ai_handler.chat_completion( model=model, temperature=0.2, @@ -150,9 +146,6 @@ class PRGenerateLabels: user=user_prompt ) - if get_settings().config.verbosity_level >= 2: - get_logger().info(f"\nAI response:\n{response}") - return response def _prepare_data(self): diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 960b0149..0eabc59b 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -170,7 +170,6 @@ class PRReviewer: user=user_prompt ) - get_logger().debug(f"\nAI response:\n{response}") return response def _prepare_pr_review(self) -> str: From 07f507c442d591595eab14fb3610a2bac8c23fd2 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 28 Feb 2024 09:08:48 +0200 Subject: [PATCH 3/4] remove_initial_comment --- pr_agent/tools/pr_code_suggestions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index a6a12a3a..b10f1367 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -124,6 +124,12 @@ class PRCodeSuggestions: get_logger().error(f"Failed to generate code suggestions for PR, error: {e}") if self.progress_response: self.progress_response.delete() + else: + try: + self.git_provider.remove_initial_comment() + self.git_provider.publish_comment(f"Failed to generate code suggestions for PR") + except Exception as e: + pass async def _prepare_prediction(self, model: str): self.patches_diff = get_pr_diff(self.git_provider, From 047c3706838cb0f0c88159f757deaae543a00e62 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 28 Feb 2024 09:20:14 +0200 Subject: [PATCH 4/4] Update README.md and add gfm markdown support check in pr_help_message.py --- README.md | 4 ++-- pr_agent/tools/pr_help_message.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dcd6e583..78eff3bd 100644 --- a/README.md +++ b/README.md @@ -74,11 +74,11 @@ CodiumAI PR-Agent is an open-source tool to help efficiently review and handle p | | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | ⮑ [Ask on code lines](./docs/ASK.md#ask-lines) | :white_check_mark: | :white_check_mark: | | | | | [Custom Suggestions](https://github.com/Codium-ai/pr-agent/blob/main/docs/CUSTOM_SUGGESTIONS.md) 💎 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | [Test](https://github.com/Codium-ai/pr-agent/blob/main/docs/TEST.md) 💎 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | [Test](https://github.com/Codium-ai/pr-agent/blob/main/docs/TEST.md) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | Reflect and Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | Update CHANGELOG.md | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | Find Similar Issue | :white_check_mark: | | | | -| | [Add PR Documentation](https://github.com/Codium-ai/pr-agent/blob/main/docs/ADD_DOCUMENTATION.md) 💎 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | [Add PR Documentation](https://github.com/Codium-ai/pr-agent/blob/main/docs/ADD_DOCUMENTATION.md) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | [Custom Labels](https://github.com/Codium-ai/pr-agent/blob/main/docs/DESCRIBE.md#handle-custom-labels-from-the-repos-labels-page-gem) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | [Analyze](https://github.com/Codium-ai/pr-agent/blob/main/docs/Analyze.md) 💎 | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | [CI Feedback](https://github.com/Codium-ai/pr-agent/blob/main/docs/CI_FEEDBACK.md) 💎 | :white_check_mark: | | | | diff --git a/pr_agent/tools/pr_help_message.py b/pr_agent/tools/pr_help_message.py index 9095a8f1..357a9112 100644 --- a/pr_agent/tools/pr_help_message.py +++ b/pr_agent/tools/pr_help_message.py @@ -9,6 +9,11 @@ class PRHelpMessage: async def run(self): try: + if not self.git_provider.is_supported("gfm_markdown"): + self.git_provider.publish_comment( + "The `Help` tool requires gfm markdown, which is not supported by your code platform.") + return + get_logger().info('Getting PR Help Message...') relevant_configs = {'pr_help': dict(get_settings().pr_help), 'config': dict(get_settings().config)}