From 32358678e68c2544787087fc7485133469b80aef Mon Sep 17 00:00:00 2001 From: zmeir Date: Sun, 23 Jul 2023 16:59:08 +0300 Subject: [PATCH 1/3] Reduce the number of GitHub API calls when pushing code suggestions --- pr_agent/git_providers/github_provider.py | 24 ++++++++--------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/pr_agent/git_providers/github_provider.py b/pr_agent/git_providers/github_provider.py index feb168f9..37f8a05f 100644 --- a/pr_agent/git_providers/github_provider.py +++ b/pr_agent/git_providers/github_provider.py @@ -152,10 +152,8 @@ class GithubProvider(GitProvider): def publish_code_suggestions(self, code_suggestions: list): """ Publishes code suggestions as comments on the PR. - In practice current APU enables to send only one code suggestion per comment. Might change in the future. """ post_parameters_list = [] - import github.PullRequestComment for suggestion in code_suggestions: body = suggestion['body'] relevant_file = suggestion['relevant_file'] @@ -178,7 +176,6 @@ class GithubProvider(GitProvider): if relevant_lines_end > relevant_lines_start: post_parameters = { "body": body, - "commit_id": self.last_commit_id._identity, "path": relevant_file, "line": relevant_lines_end, "start_line": relevant_lines_start, @@ -187,24 +184,19 @@ class GithubProvider(GitProvider): else: # API is different for single line comments post_parameters = { "body": body, - "commit_id": self.last_commit_id._identity, "path": relevant_file, "line": relevant_lines_start, "side": "RIGHT", } + post_parameters_list.append(post_parameters) - try: - headers, data = self.pr._requester.requestJsonAndCheck( - "POST", f"{self.pr.url}/comments", input=post_parameters - ) - github.PullRequestComment.PullRequestComment( - self.pr._requester, headers, data, completed=True - ) - return True - except Exception as e: - if settings.config.verbosity_level >= 2: - logging.error(f"Failed to publish code suggestion, error: {e}") - return False + try: + self.pr.create_review(commit=self.last_commit_id, comments=post_parameters_list) + return True + except Exception as e: + if settings.config.verbosity_level >= 2: + logging.error(f"Failed to publish code suggestion, error: {e}") + return False def remove_initial_comment(self): try: From e8aa33fa0b0325d0111d76b2c015abfc02690d9f Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Sun, 23 Jul 2023 17:27:26 +0300 Subject: [PATCH 2/3] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5c3b5346..5ddbd7a4 100644 --- a/README.md +++ b/README.md @@ -30,31 +30,31 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull

/describe:

- +

/review:

- +

-

/reflect and review:

+

/reflect_and_review:

- +

/ask:

- +

/improve:

- +

@@ -106,7 +106,7 @@ In the [configuration](./CONFIGURATION.md) file you can select your git provider Try GPT-4 powered PR-Agent on your public GitHub repository for free. Just mention `@CodiumAI-Agent` and add the desired command in any PR comment! The agent will generate a response based on your command. -![Review generation process](https://www.codium.ai/wp-content/uploads/2023/07/demo.gif) +![Review generation process](https://www.codium.ai/images/demo.gif) To set up your own PR-Agent, see the [Installation](#installation) section From 0412d7aca0d6e47dee679e753d07e677d266d58f Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Sun, 23 Jul 2023 17:38:08 +0300 Subject: [PATCH 3/3] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5ddbd7a4..eeaa4ec9 100644 --- a/README.md +++ b/README.md @@ -30,13 +30,13 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull

/describe:

- +

/review:

- +

/reflect_and_review:

@@ -48,13 +48,13 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull

/ask:

- +

/improve:

- +

@@ -106,7 +106,7 @@ In the [configuration](./CONFIGURATION.md) file you can select your git provider Try GPT-4 powered PR-Agent on your public GitHub repository for free. Just mention `@CodiumAI-Agent` and add the desired command in any PR comment! The agent will generate a response based on your command. -![Review generation process](https://www.codium.ai/images/demo.gif) +![Review generation process](https://www.codium.ai/images/demo-2.gif) To set up your own PR-Agent, see the [Installation](#installation) section