Add /generate_labels function + fix issues

This commit is contained in:
Hussam.lawen
2023-10-26 23:28:33 +03:00
parent 16777a5334
commit f3bdbfc103
11 changed files with 291 additions and 22 deletions

View File

@ -37,23 +37,7 @@ extra_instructions = ""
# markers
use_description_markers=false
include_generated_by_header=true
[custom_labels."Bug fix"]
description = "Fixes a bug in the code"
[custom_labels."Tests"]
description = "Adds or modifies tests"
[custom_labels."Bug fix with tests"]
description = "Fixes a bug in the code and adds or modifies tests"
[custom_labels."Refactoring"]
description = "Refactors the code without changing its functionality"
[custom_labels."Enhancement"]
description = "Adds new features or functionality"
[custom_labels."Documentation"]
description = "Adds or modifies documentation"
[custom_labels."SQL modifications"]
description = "Adds or modifies SQL queries"
[custom_labels."Other"]
description = "Other changes that do not fit in any of the above categories"
enable_custom_labels=true
#custom_labels = ['Bug fix', 'Tests', 'Bug fix with tests', 'Refactoring', 'Enhancement', 'Documentation', 'Other']

View File

@ -0,0 +1,14 @@
[custom_labels."Bug fix"]
description = "Fixes a bug in the code"
[custom_labels."Tests"]
description = "Adds or modifies tests"
[custom_labels."Bug fix with tests"]
description = "Fixes a bug in the code and adds or modifies tests"
[custom_labels."Refactoring"]
description = "Code refactoring without changing functionality"
[custom_labels."Enhancement"]
description = "Adds new features or functionality"
[custom_labels."Documentation"]
description = "Adds or modifies documentation"
[custom_labels."Other"]
description = "Other changes that do not fit in any of the above categories"

View File

@ -0,0 +1,72 @@
[pr_custom_labels_prompt]
system="""You are CodiumAI-PR-Reviewer, a language model designed to review git pull requests.
Your task is to label the type of the PR content.
- Make sure not to focus the new PR code (the '+' lines).
- If needed, each YAML output should be in block scalar format ('|-')
{%- if extra_instructions %}
Extra instructions from the user:
'
{{ extra_instructions }}
'
{% endif %}
You must use the following YAML schema to format your answer:
```yaml
PR Type:
type: array
{%- if enable_custom_labels %}
description: One or more labels that describe the PR type. Don't output the description in the parentheses.
{%- endif %}
items:
type: string
enum:
{%- if enable_custom_labels %}
{{ custom_labels }}
{%- else %}
- Bug fix
- Tests
- Refactoring
- Enhancement
- Documentation
- Other
{%- endif %}
Example output:
```yaml
PR Labels:
{%- if enable_custom_labels %}
{{ custom_labels_examples }}
{%- else %}
- Bug fix
- Tests
{%- endif %}
```
Make sure to output a valid YAML. Don't repeat the prompt in the answer, and avoid outputting the 'type' and 'description' fields.
"""
user="""PR Info:
Previous title: '{{title}}'
Previous description: '{{description}}'
Branch: '{{branch}}'
{%- if language %}
Main language: {{language}}
{%- endif %}
{%- if commit_messages_str %}
Commit messages:
{{commit_messages_str}}
{%- endif %}
The PR Git Diff:
```
{{diff}}
```
Note that lines in the diff body are prefixed with a symbol that represents the type of change: '-' for deletions, '+' for additions, and ' ' (a space) for unchanged lines.
Response (should be a valid YAML, and nothing else):
```yaml
"""

View File

@ -19,11 +19,22 @@ PR Title:
description: an informative title for the PR, describing its main theme
PR Type:
type: array
{%- if enable_custom_labels %}
description: One or more labels that describe the PR type. Don't output the description in the parentheses.
{%- endif %}
items:
type: string
enum:
{%- if enable_custom_labels %}
{{ custom_labels }}
{%- else %}
- Bug fix
- Tests
- Refactoring
- Enhancement
- Documentation
- Other
{%- endif %}
PR Description:
type: string
description: an informative and concise description of the PR.
@ -47,7 +58,11 @@ Example output:
PR Title: |-
...
PR Type:
{%- if enable_custom_labels %}
{{ custom_labels_examples }}
{%- else %}
- Bug fix
{%- endif %}
PR Description: |-
...
PR Main Files Walkthrough:

View File

@ -51,8 +51,22 @@ PR Analysis:
description: summary of the PR in 2-3 sentences.
Type of PR:
type: string
{%- if enable_custom_labels %}
description: One or more labels that describe the PR type. Don't output the description in the parentheses.
{%- endif %}
items:
type: string
enum:
{%- if enable_custom_labels %}
{{ custom_labels }}
{%- else %}
- Bug fix
- Tests
- Refactoring
- Enhancement
- Documentation
- Other
{%- endif %}
{%- if require_score %}
Score:
type: int