From f4037e0dfa7d19b9c1e43ff17ac5976218442cec Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 24 Jan 2024 19:40:58 +0200 Subject: [PATCH 1/4] feat: Add LanceDB support for similar_issue tool and refactor SOC2 compliance feature name --- README.md | 3 +++ docs/REVIEW.md | 4 ++-- pr_agent/servers/help.py | 2 +- pr_agent/tools/pr_similar_issue.py | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c66ec2cd..84c72e5c 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,9 @@ pr_commands = [ Meaning that by default, for each PR the `describe`, `review`, and `improve` tools will be triggered automatically, and the `improve` tool will present the suggestions in a single comment. You can of course overwrite these defaults by adding a `.pr_agent.toml` file to your repo. See [here](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-app). +### Jan 10, 2024 +[LanceDB](https://lancedb.com/) is now supported as a locally hosted VectorDB for the `similar_issue` tool. See [here](./docs/SIMILAR_ISSUE.md) for more details. + ## Overview
diff --git a/docs/REVIEW.md b/docs/REVIEW.md index 83616a61..4d997e2b 100644 --- a/docs/REVIEW.md +++ b/docs/REVIEW.md @@ -45,7 +45,7 @@ To edit [configurations](./../pr_agent/settings/configuration.toml#L19) related - `require_estimate_effort_to_review`: if set to true, the tool will add a section that estimates thed effort needed to review the PR. Default is true. #### SOC2 ticket compliance 💎 This sub-tool checks if the PR description properly contains a ticket to a project management system (e.g., Jira, Asana, Trello, etc.), as required by SOC2 compliance. If not, it will add a label to the PR: "Missing SOC2 ticket". -- `require_soc2_review`: If set to true, the SOC2 ticket checker sub-tool will be enabled. Default is false. +- `require_soc2_ticket`: If set to true, the SOC2 ticket checker sub-tool will be enabled. Default is false. - `soc2_ticket_prompt`: The prompt for the SOC2 ticket review. Default is: `Does the PR description include a link to ticket in a project management system (e.g., Jira, Asana, Trello, etc.) ?`. Edit this field if your compliance requirements are different. #### Adding PR labels - `enable_review_labels_security`: if set to true, the tool will publish a 'possible security issue' label if it detects a security issue. Default is true. @@ -103,7 +103,7 @@ The `review` tool provides a collection of possible feedbacks about a PR. It is recommended to review the [Configuration options](#configuration-options) section, and choose the relevant options for your use case. Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example: -`require_score_review`, `require_soc2_review`, `enable_review_labels_effort`, and more. +`require_score_review`, `require_soc2_ticket`, `enable_review_labels_effort`, and more. On the other hand, if you find one of the enabled features to be irrelevant for your use case, disable it. No default configuration can fit all use cases. diff --git a/pr_agent/servers/help.py b/pr_agent/servers/help.py index 505016c2..ce0da4e8 100644 --- a/pr_agent/servers/help.py +++ b/pr_agent/servers/help.py @@ -95,7 +95,7 @@ The `review` tool can auto-generate two specific types of labels for a PR: The `review` tool provides a collection of possible feedbacks about a PR. It is recommended to review the [possible options](https://github.com/Codium-ai/pr-agent/blob/main/docs/REVIEW.md#enabledisable-features), and choose the ones relevant for your use case. Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example: -`require_score_review`, `require_soc2_review`, `enable_review_labels_effort`, and more. +`require_score_review`, `require_soc2_ticket`, `enable_review_labels_effort`, and more. """ output += "\n\n\n\n" diff --git a/pr_agent/tools/pr_similar_issue.py b/pr_agent/tools/pr_similar_issue.py index a38cb13d..485331c0 100644 --- a/pr_agent/tools/pr_similar_issue.py +++ b/pr_agent/tools/pr_similar_issue.py @@ -5,7 +5,6 @@ from typing import List import openai import pandas as pd import pinecone -import lancedb from pinecone_datasets import Dataset, DatasetMetadata from pydantic import BaseModel, Field @@ -108,6 +107,7 @@ class PRSimilarIssue: get_logger().info('No new issues to update') elif get_settings().pr_similar_issue.vectordb == "lancedb": + import lancedb # import lancedb only if needed self.db = lancedb.connect(get_settings().lancedb.uri) self.table = None From d8465ea9f9db8a525f22fbccd70e48ef2b0e20a7 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 24 Jan 2024 19:47:30 +0200 Subject: [PATCH 2/4] removed include_improved_code --- docs/IMPROVE.md | 1 - pr_agent/settings/configuration.toml | 3 +-- pr_agent/tools/pr_code_suggestions.py | 24 ++++-------------------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/docs/IMPROVE.md b/docs/IMPROVE.md index 60a01de3..dc7f9d6f 100644 --- a/docs/IMPROVE.md +++ b/docs/IMPROVE.md @@ -51,7 +51,6 @@ To edit [configurations](./../pr_agent/settings/configuration.toml#L66) related - `num_code_suggestions`: number of code suggestions provided by the 'improve' tool. Default is 4. - `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...". - `rank_suggestions`: if set to true, the tool will rank the suggestions, based on importance. Default is false. -- `include_improved_code`: if set to true, the tool will include an improved code implementation in the suggestion. Default is true. - `summarize`: if set to true, the tool will display the suggestions in a single comment. Default is false. - `enable_help_text`: if set to true, the tool will display a help text in the comment. Default is true. #### params for '/improve --extended' mode diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 66cd48bc..8c37ac8e 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -69,8 +69,7 @@ enable_help_text=true [pr_code_suggestions] # /improve # num_code_suggestions=4 -summarize = false -include_improved_code = true +summarize = true extra_instructions = "" rank_suggestions = false enable_help_text=true diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 2070a621..97c183f2 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -169,35 +169,19 @@ class PRCodeSuggestions: if new_code_snippet: new_code_snippet = self.dedent_code(relevant_file, relevant_lines_start, new_code_snippet) - if get_settings().pr_code_suggestions.include_improved_code: - body = f"**Suggestion:** {content} [{label}]\n```suggestion\n" + new_code_snippet + "\n```" - code_suggestions.append({'body': body, 'relevant_file': relevant_file, + body = f"**Suggestion:** {content} [{label}]\n```suggestion\n" + new_code_snippet + "\n```" + code_suggestions.append({'body': body, 'relevant_file': relevant_file, 'relevant_lines_start': relevant_lines_start, 'relevant_lines_end': relevant_lines_end}) - else: - if self.git_provider.is_supported("create_inline_comment"): - body = f"**Suggestion:** {content} [{label}]" - comment = self.git_provider.create_inline_comment(body, relevant_file, "", - absolute_position=relevant_lines_end) - if comment: - code_suggestions.append(comment) - else: - get_logger().error("Inline comments are not supported by the git provider") except Exception: if get_settings().config.verbosity_level >= 2: get_logger().info(f"Could not parse suggestion: {d}") - if get_settings().pr_code_suggestions.include_improved_code: - is_successful = self.git_provider.publish_code_suggestions(code_suggestions) - else: - is_successful = self.git_provider.publish_inline_comments(code_suggestions) + is_successful = self.git_provider.publish_code_suggestions(code_suggestions) if not is_successful: get_logger().info("Failed to publish code suggestions, trying to publish each suggestion separately") for code_suggestion in code_suggestions: - if get_settings().pr_code_suggestions.include_improved_code: - self.git_provider.publish_code_suggestions([code_suggestion]) - else: - self.git_provider.publish_inline_comments([code_suggestion]) + self.git_provider.publish_code_suggestions([code_suggestion]) def dedent_code(self, relevant_file, relevant_lines_start, new_code_snippet): try: # dedent code snippet From 4077c5556d7fdca19cd67dc7bc048c3e92b312a7 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 24 Jan 2024 19:49:43 +0200 Subject: [PATCH 3/4] enable_review_labels_effort set to true by default --- docs/REVIEW.md | 4 ++-- pr_agent/servers/help.py | 2 +- pr_agent/settings/configuration.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/REVIEW.md b/docs/REVIEW.md index 4d997e2b..e052a668 100644 --- a/docs/REVIEW.md +++ b/docs/REVIEW.md @@ -49,7 +49,7 @@ This sub-tool checks if the PR description properly contains a ticket to a proje - `soc2_ticket_prompt`: The prompt for the SOC2 ticket review. Default is: `Does the PR description include a link to ticket in a project management system (e.g., Jira, Asana, Trello, etc.) ?`. Edit this field if your compliance requirements are different. #### Adding PR labels - `enable_review_labels_security`: if set to true, the tool will publish a 'possible security issue' label if it detects a security issue. Default is true. -- `enable_review_labels_effort`: if set to true, the tool will publish a 'Review effort [1-5]: x' label. Default is false. +- `enable_review_labels_effort`: if set to true, the tool will publish a 'Review effort [1-5]: x' label. Default is true. ### Incremental Mode Incremental review only considers changes since the last PR-Agent review. This can be useful when working on the PR in an iterative manner, and you want to focus on the changes since the last review instead of reviewing the entire PR again. @@ -103,7 +103,7 @@ The `review` tool provides a collection of possible feedbacks about a PR. It is recommended to review the [Configuration options](#configuration-options) section, and choose the relevant options for your use case. Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example: -`require_score_review`, `require_soc2_ticket`, `enable_review_labels_effort`, and more. +`require_score_review`, `require_soc2_ticket`, and more. On the other hand, if you find one of the enabled features to be irrelevant for your use case, disable it. No default configuration can fit all use cases. diff --git a/pr_agent/servers/help.py b/pr_agent/servers/help.py index ce0da4e8..376475fe 100644 --- a/pr_agent/servers/help.py +++ b/pr_agent/servers/help.py @@ -95,7 +95,7 @@ The `review` tool can auto-generate two specific types of labels for a PR: The `review` tool provides a collection of possible feedbacks about a PR. It is recommended to review the [possible options](https://github.com/Codium-ai/pr-agent/blob/main/docs/REVIEW.md#enabledisable-features), and choose the ones relevant for your use case. Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example: -`require_score_review`, `require_soc2_ticket`, `enable_review_labels_effort`, and more. +`require_score_review`, `require_soc2_ticket`, and more. """ output += "\n\n\n\n" diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 8c37ac8e..5d9a84ab 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -36,7 +36,7 @@ persistent_comment=true extra_instructions = "" # review labels enable_review_labels_security=true -enable_review_labels_effort=false +enable_review_labels_effort=true # specific configurations for incremental review (/review -i) require_all_thresholds_for_incremental_review=false minimal_commits_for_incremental_review=0 From e056cd59888b205a8e9678b6e5dd57f4f6e74036 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 24 Jan 2024 19:55:33 +0200 Subject: [PATCH 4/4] type --- docs/REVIEW.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/REVIEW.md b/docs/REVIEW.md index e052a668..5a35d8b9 100644 --- a/docs/REVIEW.md +++ b/docs/REVIEW.md @@ -42,7 +42,7 @@ To edit [configurations](./../pr_agent/settings/configuration.toml#L19) related - `require_score_review`: if set to true, the tool will add a section that scores the PR. Default is false. - `require_tests_review`: if set to true, the tool will add a section that checks if the PR contains tests. Default is true. - `require_security_review`: if set to true, the tool will add a section that checks if the PR contains security issues. Default is true. -- `require_estimate_effort_to_review`: if set to true, the tool will add a section that estimates thed effort needed to review the PR. Default is true. +- `require_estimate_effort_to_review`: if set to true, the tool will add a section that estimates the effort needed to review the PR. Default is true. #### SOC2 ticket compliance 💎 This sub-tool checks if the PR description properly contains a ticket to a project management system (e.g., Jira, Asana, Trello, etc.), as required by SOC2 compliance. If not, it will add a label to the PR: "Missing SOC2 ticket". - `require_soc2_ticket`: If set to true, the SOC2 ticket checker sub-tool will be enabled. Default is false.