From 8324e9a38d33181964b3b96075876b0699efd66d Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sat, 9 Mar 2024 10:46:36 +0200 Subject: [PATCH 01/18] can_be_split --- docs/REVIEW.md | 1 - pr_agent/algo/utils.py | 37 +++++++++++++++++++++- pr_agent/git_providers/git_provider.py | 7 ++++ pr_agent/git_providers/github_provider.py | 5 +++ pr_agent/settings/configuration.toml | 2 +- pr_agent/settings/pr_reviewer_prompts.toml | 30 ++++++++++++------ pr_agent/tools/pr_reviewer.py | 3 +- 7 files changed, 71 insertions(+), 14 deletions(-) diff --git a/docs/REVIEW.md b/docs/REVIEW.md index 00b3c8ac..98afb085 100644 --- a/docs/REVIEW.md +++ b/docs/REVIEW.md @@ -41,7 +41,6 @@ To edit [configurations](./../pr_agent/settings/configuration.toml#L19) related - `persistent_comment`: if set to true, the review comment will be persistent, meaning that every new review request will edit the previous one. Default is true. #### Enable\\disable features -- `require_focused_review`: if set to true, the tool will add a section - 'is the PR a focused one'. Default is false. - `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_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. diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 6932d7bd..3a467416 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -70,6 +70,7 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool = True) -> str: """ emojis = { + "Can be split": "๐Ÿ”€", "Possible issues": "๐Ÿ”", "Score": "๐Ÿ…", "Relevant tests": "๐Ÿงช", @@ -90,7 +91,8 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool = True) -> str: for key, value in output_data['review'].items(): if value is None or value == '' or value == {} or value == []: - continue + if key.lower() != 'can_be_split': + continue key_nice = key.replace('_', ' ').capitalize() emoji = emojis.get(key_nice, "") if gfm_supported: @@ -99,6 +101,8 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool = True) -> str: if 'security concerns' in key_nice.lower(): value = emphasize_header(value.strip()) markdown_text += f" {emoji} {key_nice}\n\n{value}\n\n\n" + elif 'can be split' in key_nice.lower(): + markdown_text += process_can_be_split(emoji, value) elif 'possible issues' in key_nice.lower(): value = value.strip() issues = value.split('\n- ') @@ -150,6 +154,37 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool = True) -> str: return markdown_text +def process_can_be_split(emoji, value): + key_nice = "Can this PR be split?" + markdown_text = "" + if not value or isinstance(value, list) and len(value) == 1: + value = "No" + markdown_text += f" {emoji} {key_nice}\n\n{value}\n\n\n" + else: + number_of_splits = len(value) + markdown_text += f" {emoji} {key_nice}\n" + for i, split in enumerate(value): + title = split.get('title', '') + relevant_files = split.get('relevant_files', []) + if i == 0: + markdown_text += f"
\nSub PR theme: {title}\n\n" + markdown_text += f"
\n" + markdown_text += f"Relevant files:\n" + markdown_text += f"\n\n
\n" + else: + markdown_text += f"\n
\nSub PR theme: {title}\n\n" + markdown_text += f"
\n" + markdown_text += f"Relevant files:\n" + markdown_text += f"\n\n
\n" + return markdown_text + + def parse_code_suggestion(code_suggestion: dict, i: int = 0, gfm_supported: bool = True) -> str: """ Convert a dictionary of data into markdown format. diff --git a/pr_agent/git_providers/git_provider.py b/pr_agent/git_providers/git_provider.py index e8a78b4b..a2bd7deb 100644 --- a/pr_agent/git_providers/git_provider.py +++ b/pr_agent/git_providers/git_provider.py @@ -197,6 +197,12 @@ class GitProvider(ABC): def calc_pr_statistics(self, pull_request_data: dict): return {} + def get_num_of_files(self): + try: + return len(self.get_diff_files()) + except Exception as e: + return -1 + def get_main_pr_language(languages, files) -> str: """ @@ -266,6 +272,7 @@ def get_main_pr_language(languages, files) -> str: return main_language_str + class IncrementalPR: def __init__(self, is_incremental: bool = False): self.is_incremental = is_incremental diff --git a/pr_agent/git_providers/github_provider.py b/pr_agent/git_providers/github_provider.py index fab4fd5b..e29c077e 100644 --- a/pr_agent/git_providers/github_provider.py +++ b/pr_agent/git_providers/github_provider.py @@ -112,6 +112,11 @@ class GithubProvider(GitProvider): self.git_files = self.pr.get_files() return self.git_files + def get_num_of_files(self): + if self.git_files: + return self.git_files.totalCount + else: + return -1 @retry(exceptions=RateLimitExceeded, tries=get_settings().github.ratelimit_retries, delay=2, backoff=2, jitter=(1, 3)) diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index b5a0dab1..3038f3df 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -22,10 +22,10 @@ ai_disclaimer="" # Pro feature, full text for the AI disclaimer [pr_reviewer] # /review # # enable/disable features -require_focused_review=false require_score_review=false require_tests_review=true require_estimate_effort_to_review=true +require_can_be_split_review=false # soc2 require_soc2_ticket=false soc2_ticket_prompt="Does the PR description include a link to ticket in a project management system (e.g., Jira, Asana, Trello, etc.) ?" diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index 62068647..326bfb47 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -49,7 +49,13 @@ Extra instructions from the user: The output must be a YAML object equivalent to type $PRReview, according to the following Pydantic definitions: ===== -class Review(BaseModel) +{%- if require_can_be_split_review %} +class SubPR(BaseModel): + title: str = Field(description="short and concise title for a sub-PR composed only from the relevant files") + relevant_files: List[str] = Field(description="the relevant files of the sub-PR") +{%- endif %} + +class Review(BaseModel): {%- if require_estimate_effort_to_review %} estimated_effort_to_review_[1-5]: str = Field(description="Estimate, on a scale of 1-5 (inclusive), the time and effort required to review this PR by an experienced and knowledgeable developer. 1 means short and easy review , 5 means long and hard review. Take into account the size, complexity, quality, and the needed changes of the PR code diff. Explain your answer in a short and concise manner.") {%- endif %} @@ -61,15 +67,15 @@ class Review(BaseModel) {%- endif %} {%- if question_str %} insights_from_user_answers: str = Field(description="shortly summarize the insights you gained from the user's answers to the questions") -{%- endif %} -{%- if require_focused %} - focused_pr: str = Field(description="Is this a focused PR, in the sense that all the PR code diff changes are united under a single focused theme ? If the theme is too broad, or the PR code diff changes are too scattered, then the PR is not focused. Explain your answer shortly.") {%- endif %} possible_issues: str = Field(description="Does this PR code introduce clear issues, bugs, or major performance concerns? If there are no apparent issues, respond with 'No'. If there are any issues, describe them briefly. Use bullet points if more than one issue. Be specific, and provide examples if possible. Start each bullet point with a short specific header, such as: "- Possible Bug: ...", etc.") security_concerns: str = Field(description="does this PR code introduce possible vulnerabilities such as exposure of sensitive information (e.g., API keys, secrets, passwords), or security concerns like SQL injection, XSS, CSRF, and others ? Answer 'No' if there are no possible issues. If there are security concerns or issues, start your answer with a short header, such as: 'Sensitive information exposure: ...', 'SQL injection: ...' etc. Explain your answer. Be specific and give examples if possible") +{%- if require_can_be_split_review %} + can_be_split: List[SubPR] = Field(description="Can this PR, with its {{ num_pr_files }} changed files, be clearly split into smaller sub-PRs, that can be reviewed and merged independently, regardless of the order ? If yes, provide a title and list the relevant files for each sub-PR. Make sure that the sub-PRs are indeed independent, without any code dependencies between them. Try not to create too many sub-PRs. For example, logic changes and corresponding documentation should be grouped together. Output empty list if the PR cannot be split.") +{%- endif %} {%- if num_code_suggestions > 0 %} -class CodeSuggestion(BaseModel) +class CodeSuggestion(BaseModel): relevant_file: str = Field(description="the relevant file full path") language: str = Field(description="the language of the relevant file") suggestion: str = Field(description="a concrete suggestion for meaningfully improving the new PR code. Also describe how, specifically, the suggestion can be applied to new PR code. Add tags with importance measure that matches each suggestion ('important' or 'medium'). Do not make suggestions for updating or adding docstrings, renaming PR title and description, or linter like.") @@ -77,7 +83,7 @@ class CodeSuggestion(BaseModel) {%- endif %} {%- if num_code_suggestions > 0 %} -class PRReview(BaseModel) +class PRReview(BaseModel): review: Review code_feedback: List[CodeSuggestion] {%- else %} @@ -100,14 +106,18 @@ review: {%- endif %} relevant_tests: | No -{%- if require_focused %} - focused_pr: | - no, because ... -{%- endif %} possible_issues: | No security_concerns: | No +{%- if require_can_be_split_review %} + can_be_split: | + title: | + ... + - relevant_files: + - ... + - ... +{%- endif %} {%- if num_code_suggestions > 0 %} code_feedback - relevant_file: | diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 39eb904e..6d1eb5b9 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -56,10 +56,11 @@ class PRReviewer: "description": self.git_provider.get_pr_description(), "language": self.main_language, "diff": "", # empty diff for initial calculation + "num_pr_files": self.git_provider.get_num_of_files(), "require_score": get_settings().pr_reviewer.require_score_review, "require_tests": get_settings().pr_reviewer.require_tests_review, - "require_focused": get_settings().pr_reviewer.require_focused_review, "require_estimate_effort_to_review": get_settings().pr_reviewer.require_estimate_effort_to_review, + 'require_can_be_split_review': get_settings().pr_reviewer.require_can_be_split_review, 'num_code_suggestions': get_settings().pr_reviewer.num_code_suggestions, 'question_str': question_str, 'answer_str': answer_str, From 4810b8549bab578b1f1be715eb39a8f472c6856c Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 10 Mar 2024 16:59:37 +0200 Subject: [PATCH 02/18] docs --- docs/docs/tools/review.md | 1 + pr_agent/servers/help.py | 2 +- pr_agent/settings/pr_reviewer_prompts.toml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/docs/tools/review.md b/docs/docs/tools/review.md index c0190587..e467c2c4 100644 --- a/docs/docs/tools/review.md +++ b/docs/docs/tools/review.md @@ -28,6 +28,7 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen - `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_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. +- `require_can_be_split_review`: if set to true, the tool will add a section that checks if the PR can be split into smaller PRs. Default is false. #### SOC2 ticket compliance ๐Ÿ’Ž > This feature is available only in PR-Agent Pro diff --git a/pr_agent/servers/help.py b/pr_agent/servers/help.py index d93a6791..89487b4d 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`, and more. +`require_score_review`, `require_soc2_ticket`, `require_can_be_split_review`, and more. """ output += "\n\n\n\n" diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index 326bfb47..d8b1e1d4 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -88,7 +88,7 @@ class PRReview(BaseModel): code_feedback: List[CodeSuggestion] {%- else %} -class PRReview(BaseModel) +class PRReview(BaseModel): review: Review {%- endif %} ===== From c876f271a48dbf30bec62dbe51bfe64e8caa6866 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 10 Mar 2024 17:13:40 +0200 Subject: [PATCH 03/18] contains several themes --- docs/docs/tools/review.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/tools/review.md b/docs/docs/tools/review.md index e467c2c4..ce00a6fe 100644 --- a/docs/docs/tools/review.md +++ b/docs/docs/tools/review.md @@ -28,7 +28,7 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen - `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_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. -- `require_can_be_split_review`: if set to true, the tool will add a section that checks if the PR can be split into smaller PRs. Default is false. +- `require_can_be_split_review`: if set to true, the tool will add a section that checks if the PR contains several themes, and can be split into smaller PRs. Default is false. #### SOC2 ticket compliance ๐Ÿ’Ž > This feature is available only in PR-Agent Pro From 3f66a1f0c970c39bd92d362f757206eb10fcac2d Mon Sep 17 00:00:00 2001 From: koid Date: Wed, 13 Mar 2024 11:10:19 +0900 Subject: [PATCH 04/18] update litellm --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4d6daa93..6646b2e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ GitPython==3.1.32 google-cloud-aiplatform==1.35.0 google-cloud-storage==2.10.0 Jinja2==3.1.2 -litellm==1.29.1 +litellm==1.29.7 loguru==0.7.2 msrest==0.7.1 openai==1.13.3 From d62796ac681684fae8407222a6f5b26a5c5990ef Mon Sep 17 00:00:00 2001 From: koid Date: Wed, 13 Mar 2024 11:14:04 +0900 Subject: [PATCH 05/18] update max_tokens --- pr_agent/algo/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pr_agent/algo/__init__.py b/pr_agent/algo/__init__.py index 7c537e3a..cd535416 100644 --- a/pr_agent/algo/__init__.py +++ b/pr_agent/algo/__init__.py @@ -23,4 +23,8 @@ MAX_TOKENS = { 'anthropic.claude-v1': 100000, 'anthropic.claude-v2': 100000, 'anthropic/claude-3-opus-20240229': 100000, + 'bedrock/anthropic.claude-instant-v1': 100000, + 'bedrock/anthropic.claude-v2': 100000, + 'bedrock/anthropic.claude-v2:1': 100000, + 'bedrock/anthropic.claude-3-sonnet-20240229-v1:0': 100000, } From 1ed2cd064ab364fa758567528d9933cc175c2402 Mon Sep 17 00:00:00 2001 From: koid Date: Wed, 13 Mar 2024 11:20:02 +0900 Subject: [PATCH 06/18] add config litellm.drop_params --- pr_agent/algo/ai_handlers/litellm_ai_handler.py | 2 ++ pr_agent/settings/configuration.toml | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pr_agent/algo/ai_handlers/litellm_ai_handler.py b/pr_agent/algo/ai_handlers/litellm_ai_handler.py index 51f72960..5107c74b 100644 --- a/pr_agent/algo/ai_handlers/litellm_ai_handler.py +++ b/pr_agent/algo/ai_handlers/litellm_ai_handler.py @@ -36,6 +36,8 @@ class LiteLLMAIHandler(BaseAiHandler): assert litellm_token, "LITELLM_TOKEN is required" os.environ["LITELLM_TOKEN"] = litellm_token litellm.use_client = True + if get_settings().get("LITELLM.DROP_PARAMS", None): + litellm.drop_params = get_settings().litellm.drop_params if get_settings().get("OPENAI.ORG", None): litellm.organization = get_settings().openai.org if get_settings().get("OPENAI.API_TYPE", None): diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index b5a0dab1..c3861bb0 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -192,7 +192,8 @@ pr_commands = [ url = "" [litellm] -#use_client = false +# use_client = false +# drop_params = false [pr_similar_issue] skip_comments = false From f94a0fd7046fa36836958ddb6de86b167259fd4e Mon Sep 17 00:00:00 2001 From: koid Date: Wed, 13 Mar 2024 11:24:51 +0900 Subject: [PATCH 07/18] add Claude3Config --- pr_agent/algo/ai_handlers/litellm_ai_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pr_agent/algo/ai_handlers/litellm_ai_handler.py b/pr_agent/algo/ai_handlers/litellm_ai_handler.py index 5107c74b..1c78c09d 100644 --- a/pr_agent/algo/ai_handlers/litellm_ai_handler.py +++ b/pr_agent/algo/ai_handlers/litellm_ai_handler.py @@ -70,6 +70,7 @@ class LiteLLMAIHandler(BaseAiHandler): ) if get_settings().get("AWS.BEDROCK_REGION", None): litellm.AmazonAnthropicConfig.max_tokens_to_sample = 2000 + litellm.AmazonAnthropicClaude3Config.max_tokens = 2000 self.aws_bedrock_client = boto3.client( service_name="bedrock-runtime", region_name=get_settings().aws.bedrock_region, From 33d2d78bbca5a2640ccdbd82a8606db6c72eb0d8 Mon Sep 17 00:00:00 2001 From: koid Date: Wed, 13 Mar 2024 11:34:54 +0900 Subject: [PATCH 08/18] update docs --- docs/docs/usage-guide/additional_configurations.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/docs/usage-guide/additional_configurations.md b/docs/docs/usage-guide/additional_configurations.md index 4a6224bd..dbdd1ed4 100644 --- a/docs/docs/usage-guide/additional_configurations.md +++ b/docs/docs/usage-guide/additional_configurations.md @@ -162,8 +162,9 @@ To use Amazon Bedrock and its foundational models, add the below configuration: ``` [config] # in configuration.toml -model = "anthropic.claude-v2" -fallback_models="anthropic.claude-instant-v1" +model="bedrock/anthropic.claude-3-sonnet-20240229-v1:0" +model_turbo="bedrock/anthropic.claude-3-sonnet-20240229-v1:0" +fallback_models=["bedrock/anthropic.claude-v2:1"] [aws] # in .secrets.toml bedrock_region = "us-east-1" From 0cdd3bf43694df98a227e24aaefe779f636c3113 Mon Sep 17 00:00:00 2001 From: koid Date: Wed, 13 Mar 2024 14:23:57 +0900 Subject: [PATCH 09/18] update docs --- docs/docs/usage-guide/additional_configurations.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/docs/usage-guide/additional_configurations.md b/docs/docs/usage-guide/additional_configurations.md index dbdd1ed4..1a756252 100644 --- a/docs/docs/usage-guide/additional_configurations.md +++ b/docs/docs/usage-guide/additional_configurations.md @@ -172,6 +172,12 @@ bedrock_region = "us-east-1" Note that you have to add access to foundational models before using them. Please refer to [this document](https://docs.aws.amazon.com/bedrock/latest/userguide/setting-up.html) for more details. +If you are using the claude-3 model, please configure the following settings as there are parameters incompatible with claude-3. +``` +[litellm] +drop_params = true +``` + AWS session is automatically authenticated from your environment, but you can also explicitly set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. From 3bae515e39b886194ff48e15897c07a691440997 Mon Sep 17 00:00:00 2001 From: koid Date: Thu, 14 Mar 2024 16:58:44 +0900 Subject: [PATCH 10/18] add claude-3-haiku --- pr_agent/algo/__init__.py | 1 + requirements.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pr_agent/algo/__init__.py b/pr_agent/algo/__init__.py index cd535416..9e05ed9f 100644 --- a/pr_agent/algo/__init__.py +++ b/pr_agent/algo/__init__.py @@ -27,4 +27,5 @@ MAX_TOKENS = { 'bedrock/anthropic.claude-v2': 100000, 'bedrock/anthropic.claude-v2:1': 100000, 'bedrock/anthropic.claude-3-sonnet-20240229-v1:0': 100000, + 'bedrock/anthropic.claude-3-haiku-20240307-v1:0': 100000, } diff --git a/requirements.txt b/requirements.txt index 6646b2e5..97df2f93 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ GitPython==3.1.32 google-cloud-aiplatform==1.35.0 google-cloud-storage==2.10.0 Jinja2==3.1.2 -litellm==1.29.7 +litellm==1.31.10 loguru==0.7.2 msrest==0.7.1 openai==1.13.3 From 44386573eb95e695dc06b1a97e5772639ce761f8 Mon Sep 17 00:00:00 2001 From: Tom Brews Views Date: Fri, 15 Mar 2024 12:04:07 +0100 Subject: [PATCH 11/18] ad dcorect size logo to the header and adjust title spacing --- docs/docs/assets/logo.svg | 140 ++++++++++++++++++++++++++++++++++++++ docs/docs/css/custom.css | 88 ++---------------------- docs/mkdocs.yml | 2 +- 3 files changed, 145 insertions(+), 85 deletions(-) create mode 100644 docs/docs/assets/logo.svg diff --git a/docs/docs/assets/logo.svg b/docs/docs/assets/logo.svg new file mode 100644 index 00000000..5de22677 --- /dev/null +++ b/docs/docs/assets/logo.svg @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/docs/css/custom.css b/docs/docs/css/custom.css index 0e9b26fe..2f963ccd 100644 --- a/docs/docs/css/custom.css +++ b/docs/docs/css/custom.css @@ -5,94 +5,14 @@ --md-accent-fg-color: #AEA1F1; } .md-nav__title, .md-nav__link { - font-size: 16px; /* Adjust the font size as needed */ + font-size: 16px; } .md-tabs__link { - font-size: 16px; /* Adjust the font size as needed */ + font-size: 16px; } .md-header__title { - font-size: 20px; /* Adjust the font size as needed */ + font-size: 20px; + margin-left: 0px !important; } - -/* -@media (prefers-color-scheme: light) { - body { - --md-primary-fg-color: #00ffee !important; - --md-primary-bg-color: #ff0000 !important; - } - - body, .md-main, .md-content { - background-color: #4312f5 !important; - } -} - -@media (prefers-color-scheme: dark) { - body { - --md-primary-fg-color: #171518 !important; - --md-primary-bg-color: #171518 !important; - } - - body, .md-main, .md-content { - background-color: #171518 !important; - } - - .md-header__title { - color: #ffffff !important; - } - - .md-tabs .md-tabs__link { - color: #ffffff !important; - } - - .md-tabs .md-tabs__link:hover, - .md-tabs .md-tabs__link:focus { - color: #ffffff !important; - } - - .md-header__button { - color: #ffffff !important; - } - - .md-header__button svg { - fill: currentColor !important; - } - - .md-header__button:hover, - .md-header__button:focus { - color: #ffffff !important; - } - - .md-header__button:hover svg, - .md-header__button:focus svg { - fill: currentColor !important; - } - - .md-search__icon svg { - fill: #ffffff !important; - } - - .md-search__input { - color: #ffffff !important; - } - - .md-nav__item--active > .md-nav__link--active, - .md-nav__link--active { - color: #AEA1F1 !important; - } - - .md-nav--secondary .md-nav__title { - background: #171518; - box-shadow: 0 0 0.4rem 0.4rem #171518; - } - - .md-nav--lifted>.md-nav__list>.md-nav__item--active>.md-nav__link { - background: #171518; - box-shadow: 0 0 0.4rem 0.4rem #171518; - } - - .md-content a { - color: #AEA1F1 !important; - } -} */ \ No newline at end of file diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 0a76acf1..8da53d48 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -35,7 +35,7 @@ nav: - Core Abilities: 'core-abilities/index.md' theme: - logo: assets/logo.png + logo: assets/logo.svg favicon: assets/favicon.ico name: material features: From 6d39773a17473e399129da794621bef70cac447e Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 17 Mar 2024 09:12:49 +0200 Subject: [PATCH 12/18] prompt --- pr_agent/algo/utils.py | 5 +++-- pr_agent/settings/pr_reviewer_prompts.toml | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index d9365546..2530e064 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -159,7 +159,8 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool = True, increment def process_can_be_split(emoji, value): - key_nice = "Can this PR be split?" + # key_nice = "Can this PR be split?" + key_nice = "Multiple PR themes" markdown_text = "" if not value or isinstance(value, list) and len(value) == 1: value = "No" @@ -171,7 +172,7 @@ def process_can_be_split(emoji, value): title = split.get('title', '') relevant_files = split.get('relevant_files', []) if i == 0: - markdown_text += f"
\nSub PR theme: {title}\n\n" + markdown_text += f"
\nSub-PR theme: {title}\n\n" markdown_text += f"
\n" markdown_text += f"Relevant files:\n" markdown_text += f"
    \n" diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index d8b1e1d4..aeeef5f8 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -51,8 +51,8 @@ The output must be a YAML object equivalent to type $PRReview, according to the ===== {%- if require_can_be_split_review %} class SubPR(BaseModel): - title: str = Field(description="short and concise title for a sub-PR composed only from the relevant files") - relevant_files: List[str] = Field(description="the relevant files of the sub-PR") + relevant_files: List[str] = Field(description="The relevant files of the sub-PR") + title: str = Field(description="Short and concise title for an independent and meaningful sub-PR, composed only from the relevant files") {%- endif %} class Review(BaseModel): @@ -71,7 +71,7 @@ class Review(BaseModel): possible_issues: str = Field(description="Does this PR code introduce clear issues, bugs, or major performance concerns? If there are no apparent issues, respond with 'No'. If there are any issues, describe them briefly. Use bullet points if more than one issue. Be specific, and provide examples if possible. Start each bullet point with a short specific header, such as: "- Possible Bug: ...", etc.") security_concerns: str = Field(description="does this PR code introduce possible vulnerabilities such as exposure of sensitive information (e.g., API keys, secrets, passwords), or security concerns like SQL injection, XSS, CSRF, and others ? Answer 'No' if there are no possible issues. If there are security concerns or issues, start your answer with a short header, such as: 'Sensitive information exposure: ...', 'SQL injection: ...' etc. Explain your answer. Be specific and give examples if possible") {%- if require_can_be_split_review %} - can_be_split: List[SubPR] = Field(description="Can this PR, with its {{ num_pr_files }} changed files, be clearly split into smaller sub-PRs, that can be reviewed and merged independently, regardless of the order ? If yes, provide a title and list the relevant files for each sub-PR. Make sure that the sub-PRs are indeed independent, without any code dependencies between them. Try not to create too many sub-PRs. For example, logic changes and corresponding documentation should be grouped together. Output empty list if the PR cannot be split.") + can_be_split: List[SubPR] = Field(min_items=0, max_items=3, description="Can this PR, which contains {{ num_pr_files }} changed files in total, be divided into smaller sub-PRs with distinct tasks that can be reviewed and merged independently, regardless of the order ? Make sure that the sub-PRs are indeed independent, with no code dependencies between them, and that each sub-PR represent a meaningfull independent task. Output an empty list if the PR code does not needd to be split.") {%- endif %} {%- if num_code_suggestions > 0 %} @@ -112,11 +112,11 @@ review: No {%- if require_can_be_split_review %} can_be_split: | - title: | - ... - relevant_files: - ... - ... + title: ... + - ... {%- endif %} {%- if num_code_suggestions > 0 %} code_feedback From 498b4cb34e2f889f5c636d6f6f6adf192122d125 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 17 Mar 2024 09:59:55 +0200 Subject: [PATCH 13/18] readme --- README.md | 5 +++++ pr_agent/algo/utils.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da5159c4..a49077c7 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,11 @@ Making pull requests less painful with an AI agent ## News and Updates +### Jan 17, 2024 +- A new feature is not available for the review tool: [`require_can_be_split_review`](https://pr-agent-docs.codium.ai/tools/review/#enabledisable-features). If set to true, the tool will add a section that checks if the PR contains several themes, and can be split into smaller PRs. + + + ### Jan 10, 2024 - A new [knowledge-base website](https://pr-agent-docs.codium.ai/) for PR-Agent is now available. It includes detailed information about the different tools, usage guides and more, in an accessible and organized format. diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 2530e064..c2b6323c 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -180,7 +180,7 @@ def process_can_be_split(emoji, value): markdown_text += f"
  • {file}
  • \n" markdown_text += f"
\n\n
\n" else: - markdown_text += f"\n
\nSub PR theme: {title}\n\n" + markdown_text += f"\n
\nSub-PR theme: {title}\n\n" markdown_text += f"
\n" markdown_text += f"Relevant files:\n" markdown_text += f"