New PR Reviewer with Table view

This commit is contained in:
Hussam.lawen
2024-02-08 14:26:14 +02:00
parent cc03f7f615
commit ddb89a7474
2 changed files with 14 additions and 33 deletions

View File

@ -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 == []: if value is None or value == '' or value == {} or value == []:
continue continue
if isinstance(value, dict): if isinstance(value, dict):
if key.lower() == 'pr review':
markdown_text += f"## {key}\n\n" markdown_text += f"## {key}\n\n"
markdown_text += "<table>\n<tr>\n"
markdown_text += """<td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>feedback</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td> <td></td></tr>"""
markdown_text += convert_to_markdown(value, gfm_supported) markdown_text += convert_to_markdown(value, gfm_supported)
markdown_text += "\n</table>\n"
elif isinstance(value, list): elif isinstance(value, list):
emoji = emojis.get(key, "") emoji = emojis.get(key, "")
if key.lower() == 'code feedback': if key.lower() == 'code feedback':
@ -82,7 +87,8 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool=True) -> str:
else: else:
markdown_text += f"{emoji} **General suggestions:** {value}\n" markdown_text += f"{emoji} **General suggestions:** {value}\n"
else: else:
markdown_text += f"- {emoji} **{key}:** {value}\n" markdown_text += f"<tr><td> {emoji} {key}</td><td> {value}</td></tr>\n"
return markdown_text return markdown_text

View File

@ -46,21 +46,7 @@ Extra instructions from the user:
You must use the following YAML schema to format your answer: You must use the following YAML schema to format your answer:
```yaml ```yaml
PR Analysis: PR Review:
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
{%- if require_score %} {%- if require_score %}
Score: Score:
type: int type: int
@ -98,14 +84,9 @@ PR Analysis:
Take into account the size, complexity, quality, and the needed changes of the PR code diff. 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 ...' Explain your answer shortly (1-2 sentences). Use the format: '1, because ...'
{%- endif %} {%- endif %}
{%- if num_code_suggestions > 0 or require_security %}
PR Feedback: PR Feedback:
General suggestions: {% endif %}
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.
{%- if num_code_suggestions > 0 %} {%- if num_code_suggestions > 0 %}
Code feedback: Code feedback:
type: array type: array
@ -140,13 +121,7 @@ PR Feedback:
Example output: Example output:
```yaml ```yaml
PR Analysis: PR Review:
Main theme: |-
xxx
PR summary: |-
xxx
Type of PR: |-
...
{%- if require_score %} {%- if require_score %}
Score: 89 Score: 89
{%- endif %} {%- endif %}
@ -159,9 +134,9 @@ PR Analysis:
Estimated effort to review [1-5]: |- Estimated effort to review [1-5]: |-
3, because ... 3, because ...
{%- endif %} {%- endif %}
{%- if num_code_suggestions > 0 or require_security %}
PR Feedback: PR Feedback:
General PR suggestions: |- {% endif %}
...
{%- if num_code_suggestions > 0 %} {%- if num_code_suggestions > 0 %}
Code feedback: Code feedback:
- relevant file: |- - relevant file: |-