From 6d91f446343d2f3163ab5d8eaa1dfc0b4f02fc2a Mon Sep 17 00:00:00 2001 From: zmeir Date: Tue, 18 Jul 2023 16:32:49 +0300 Subject: [PATCH] Added configuration option to control publishing review progress This can be useful in a few situations: 1. To reduce the number of GitHub API calls (thus avoiding hitting the rate limit) 2. When the trigger for the agent is an external process (e.g. some external CI job), so there is no need to publish a message like "preparing review..." because it's not a part of a natual conversation with the user --- pr_agent/git_providers/github_provider.py | 5 ++++- pr_agent/settings/configuration.toml | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pr_agent/git_providers/github_provider.py b/pr_agent/git_providers/github_provider.py index fea1ae69..52f7fb83 100644 --- a/pr_agent/git_providers/github_provider.py +++ b/pr_agent/git_providers/github_provider.py @@ -50,6 +50,9 @@ class GithubProvider(GitProvider): # self.pr.create_issue_comment(pr_comment) def publish_comment(self, pr_comment: str, is_temporary: bool = False): + if is_temporary and not settings.config.publish_output_progress: + logging.debug(f"Skipping publish_comment for temporary comment: {pr_comment}") + return response = self.pr.create_issue_comment(pr_comment) if hasattr(response, "user") and hasattr(response.user, "login"): self.github_user_id = response.user.login @@ -140,7 +143,7 @@ class GithubProvider(GitProvider): def remove_initial_comment(self): try: - for comment in self.pr.comments_list: + for comment in getattr(self.pr, 'comments_list', []): if comment.is_temporary: comment.delete() except Exception as e: diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index fc2fa2b8..4cb6055f 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -2,6 +2,7 @@ model="gpt-4-0613" git_provider="github" publish_output=true +publish_output_progress=true verbosity_level=0 # 0,1,2 [pr_reviewer]