From ddb89a7474e784978ba64454b104548551a63532 Mon Sep 17 00:00:00 2001 From: "Hussam.lawen" Date: Thu, 8 Feb 2024 14:26:14 +0200 Subject: [PATCH] New PR Reviewer with Table view --- pr_agent/algo/utils.py | 10 ++++-- pr_agent/settings/pr_reviewer_prompts.toml | 37 ++++------------------ 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 9a150864..44e411b8 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -52,8 +52,13 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str: if value is None or value == '' or value == {} or value == []: continue if isinstance(value, dict): - markdown_text += f"## {key}\n\n" + if key.lower() == 'pr review': + markdown_text += f"## {key}\n\n" + markdown_text += "\n\n" + markdown_text += """""" + markdown_text += convert_to_markdown(value, gfm_supported) + markdown_text += "\n
     feedback                                          
\n" elif isinstance(value, list): emoji = emojis.get(key, "") if key.lower() == 'code feedback': @@ -82,7 +87,8 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str: else: markdown_text += f"{emoji} **General suggestions:** {value}\n" else: - markdown_text += f"- {emoji} **{key}:** {value}\n" + markdown_text += f" {emoji} {key} {value}\n" + return markdown_text diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index 736fb247..6705efea 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -46,21 +46,7 @@ Extra instructions from the user: You must use the following YAML schema to format your answer: ```yaml -PR Analysis: - Main theme: - type: string - description: a short explanation of the PR - PR summary: - type: string - description: summary of the PR in 2-3 sentences. - Type of PR: - type: string - enum: - - Bug fix - - Tests - - Enhancement - - Documentation - - Other +PR Review: {%- if require_score %} Score: type: int @@ -98,14 +84,9 @@ PR Analysis: Take into account the size, complexity, quality, and the needed changes of the PR code diff. Explain your answer shortly (1-2 sentences). Use the format: '1, because ...' {%- endif %} +{%- if num_code_suggestions > 0 or require_security %} PR Feedback: - General suggestions: - type: string - description: |- - General suggestions and feedback for the contributors and maintainers of this PR. - May include important suggestions for the overall structure, - primary purpose, best practices, critical bugs, and other aspects of the PR. - Don't address PR title and description, or lack of tests. Explain your suggestions. +{% endif %} {%- if num_code_suggestions > 0 %} Code feedback: type: array @@ -140,13 +121,7 @@ PR Feedback: Example output: ```yaml -PR Analysis: - Main theme: |- - xxx - PR summary: |- - xxx - Type of PR: |- - ... +PR Review: {%- if require_score %} Score: 89 {%- endif %} @@ -159,9 +134,9 @@ PR Analysis: Estimated effort to review [1-5]: |- 3, because ... {%- endif %} +{%- if num_code_suggestions > 0 or require_security %} PR Feedback: - General PR suggestions: |- - ... +{% endif %} {%- if num_code_suggestions > 0 %} Code feedback: - relevant file: |-