Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Eyes Reaction to Comments #182

Merged
merged 3 commits into from
Aug 7, 2023
Merged

Add Eyes Reaction to Comments #182

merged 3 commits into from
Aug 7, 2023

Conversation

okotek
Copy link
Contributor

@okotek okotek commented Aug 7, 2023

PR Type:

Enhancement


PR Description:

This pull request introduces two main enhancements. Firstly, it adds the ability to add and remove an 'eyes' reaction to comments in GitHub, Bitbucket, and GitLab. This is done through the addition of two new methods in the GitProvider class and its subclasses: 'add_eyes_reaction' and 'remove_reaction'. Secondly, it makes the AI timeout configurable, with a default value of 180 seconds. This is achieved by adding a new 'ai_timeout' configuration option in the 'configuration.toml' file and using this value when calling the 'chat_completion' method in the 'AiHandler' class.


PR Main Files Walkthrough:

-pr_agent/algo/ai_handler.py: Updated the 'chat_completion' method to use the new 'ai_timeout' configuration option.
-pr_agent/git_providers/git_provider.py: Added the 'add_eyes_reaction' and 'remove_reaction' abstract methods.
-pr_agent/git_providers/github_provider.py: Implemented the 'add_eyes_reaction' and 'remove_reaction' methods for GitHub.
-pr_agent/git_providers/bitbucket_provider.py and pr_agent/git_providers/gitlab_provider.py: Implemented the 'add_eyes_reaction' and 'remove_reaction' methods for Bitbucket and GitLab, respectively.
-pr_agent/servers/github_action_runner.py, pr_agent/servers/github_app.py, and pr_agent/servers/github_polling.py: Updated to add an 'eyes' reaction to a comment when it is processed and remove it afterwards.
-pr_agent/settings/configuration.toml: Added the 'ai_timeout' configuration option.

@okotek
Copy link
Contributor Author

okotek commented Aug 7, 2023

/describe

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2023

PR Analysis

  • 🎯 Main theme: Adding reaction functionality to comments and adjusting AI timeout
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: No
  • Focused PR: Yes, all changes are related to adding reaction functionality to comments and adjusting AI timeout
  • 🔒 Security concerns: No

PR Feedback

  • General suggestions: The PR is generally well-structured and follows good coding practices. However, it lacks tests for the new functionality. It is recommended to add tests to ensure the new functionality works as expected and does not break in the future.

  • 🤖 Code feedback:

How to use

To invoke the PR-Agent, add a comment using one of the following commands:
/review [-i]: Request a review of your Pull Request. For an incremental review, which only considers changes since the last review, include the '-i' option.
/describe: Modify the PR title and description based on the contents of the PR.
/improve: Suggest improvements to the code in the PR.
/ask <QUESTION>: Pose a question about the PR.

To edit any configuration parameter from 'configuration.toml', add --config_path=new_value
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, use the /config command.

@github-actions github-actions bot changed the title Ok/add eyes reaction Add Eyes Reaction to Comments and Configure AI Timeout Aug 7, 2023
@github-actions github-actions bot added the enhancement New feature or request label Aug 7, 2023
@okotek
Copy link
Contributor Author

okotek commented Aug 7, 2023

/ask Is this PR complete?

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2023

Question: is this pr complete?

Answer:
Yes, this pull request appears to be complete. It successfully introduces two main enhancements as described in the PR description.

  1. It adds the ability to add and remove an 'eyes' reaction to comments in GitHub, Bitbucket, and GitLab. This is achieved by adding two new methods 'add_eyes_reaction' and 'remove_reaction' in the GitProvider class and its subclasses.

  2. It makes the AI timeout configurable, with a default value of 180 seconds. This is done by adding a new 'ai_timeout' configuration option in the 'configuration.toml' file and using this value when calling the 'chat_completion' method in the 'AiHandler' class.

The changes have been made across multiple files to ensure the functionality is implemented correctly and consistently. The PR also includes error handling for potential issues that might arise during the execution of these new features.

However, it's important to note that the actual implementation of the 'add_eyes_reaction' and 'remove_reaction' methods for Bitbucket and GitLab in the respective provider files are placeholders returning True, and do not actually perform the intended actions. This might be a point to consider for further development.

@okotek okotek merged commit 2012e25 into main Aug 7, 2023
1 check passed
@okotek okotek deleted the ok/add_eyes_reaction branch August 7, 2023 13:28
@@ -80,8 +81,12 @@ async def handle_request(body: Dict[str, Any]):
return {}
pull_request = body["issue"]["pull_request"]
api_url = pull_request.get("url")
comment_id = body.get("comment", {}).get("id")
provider = get_git_provider()(pr_url=api_url)
provider.add_eyes_reaction(comment_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okotek won't that add the reaction to every comment? Even if it's not even directed towards the PRAgent? Maybe this can move to PRAgent.handle_request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@okotek okotek changed the title Add Eyes Reaction to Comments and Configure AI Timeout Add Eyes Reaction to Comments Aug 7, 2023
@okotek
Copy link
Contributor Author

okotek commented Aug 7, 2023

test

@okotek
Copy link
Contributor Author

okotek commented Aug 7, 2023

/improve

@okotek
Copy link
Contributor Author

okotek commented Aug 7, 2023

@CodiumAI-Agent

@okotek
Copy link
Contributor Author

okotek commented Aug 7, 2023

@CodiumAI-Agent /review

@CodiumAI-Agent
Copy link

PR Analysis

  • 🎯 Main theme: Adding 'eyes' reaction to comments and making AI timeout configurable
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: No
  • Focused PR: Yes, the PR is focused as it introduces two main enhancements related to reactions to comments and AI timeout configuration.
  • 🔒 Security concerns: No, the PR does not introduce any apparent security concerns.

PR Feedback

  • General suggestions: The PR introduces new functionalities which are well implemented. However, it lacks tests for the new functionalities. It's important to add tests to ensure the new features work as expected and to prevent potential regressions in the future.

  • 🤖 Code feedback:

    • relevant file: pr_agent/git_providers/github_provider.py
      suggestion: Consider handling specific exceptions in the 'add_eyes_reaction' and 'remove_reaction' methods. Catching a general exception can make debugging difficult if an unexpected error occurs. [important]
      relevant line: except Exception as e:

    • relevant file: pr_agent/algo/ai_handler.py
      suggestion: The 'force_timeout' parameter in the 'acompletion' function call is set to 'get_settings().config.ai_timeout'. Consider storing the result of 'get_settings().config.ai_timeout' in a variable before using it in the function call. This will make the code cleaner and more efficient, as the 'get_settings' function won't need to be called each time 'force_timeout' is used. [medium]
      relevant line: force_timeout=get_settings().config.ai_timeout

    • relevant file: pr_agent/git_providers/bitbucket_provider.py
      suggestion: The 'add_eyes_reaction' and 'remove_reaction' methods in the BitbucketProvider class are currently returning True without performing any operation. Consider implementing these methods to actually add and remove reactions in Bitbucket, or raise a NotImplementedError if these operations are not supported. [important]
      relevant line: def add_eyes_reaction(self, issue_comment_id: int) -> Optional[int]:

How to use

Tag me in a comment '@CodiumAI-Agent' and add one of the following commands:
/review [-i]: Request a review of your Pull Request. For an incremental review, which only considers changes since the last review, include the '-i' option.
/describe: Modify the PR title and description based on the contents of the PR.
/improve: Suggest improvements to the code in the PR.
/ask <QUESTION>: Pose a question about the PR.

To edit any configuration parameter from 'configuration.toml', add --config_path=new_value
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, use the /config command.

@mrT23
Copy link
Collaborator

mrT23 commented Aug 9, 2023

PR Analysis

  • 🎯 Main theme: Adding 'eyes' reaction to comments and making AI timeout configurable
  • 📌 Type of PR: Enhancement
  • Focused PR: Yes, the PR is focused on adding a new feature and enhancing an existing one.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • General suggestions: The PR seems to be well-structured and the changes are clearly explained. However, it would be beneficial to add tests to ensure the new functionality works as expected and does not break any existing features.

  • 🤖 Code feedback:

    • relevant file: pr_agent/algo/ai_handler.py
      suggestion: It would be better to handle the case where the 'ai_timeout' configuration option is not set in the 'configuration.toml' file. You can use a default value if the option is not set. [important]
      relevant line: force_timeout=get_settings().config.ai_timeout

    • relevant file: pr_agent/git_providers/github_provider.py
      suggestion: It would be better to handle the case where the 'add_eyes_reaction' and 'remove_reaction' methods fail due to API rate limits or other issues. You can use a retry mechanism to handle these cases. [medium]
      relevant line: reaction = self.pr.get_issue_comment(issue_comment_id).create_reaction("eyes")

    • relevant file: pr_agent/servers/github_action_runner.py
      suggestion: It would be better to handle the case where the 'add_eyes_reaction' method fails. You can use a try-except block to handle this case. [medium]
      relevant line: provider.add_eyes_reaction(comment_id)

@okotek okotek restored the ok/add_eyes_reaction branch January 7, 2024 11:50
yochail pushed a commit to yochail/pr-agent that referenced this pull request Feb 11, 2024
Add Eyes Reaction to Comments and Configure AI Timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants