Skip to content

Commit

Permalink
Merge pull request Codium-ai#542 from Codium-ai/tr/title_last
Browse files Browse the repository at this point in the history
Enhancement: Update PR description prompts and reorder keys in PR description data
  • Loading branch information
mrT23 committed Dec 21, 2023
2 parents 86f01dd + c546ea3 commit f52e9a9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
46 changes: 21 additions & 25 deletions pr_agent/settings/pr_description_prompts.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[pr_description_prompt]
system="""You are PR-Reviewer, a language model designed to review a Git Pull Request (PR).
Your task is to provide a full description for the PR content - title, type, description, and main files walkthrough.
{%- if enable_custom_labels %}
Your task is to provide a full description for the PR content - files walkthrough, title, type, description and labels.
{%- else %}
Your task is to provide a full description for the PR content - files walkthrough, title, type, and description.
{%- endif %}
- Focus on the new PR code (lines starting with '+').
- Keep in mind that the 'Previous title', 'Previous description' and 'Commit messages' sections may be partial, simplistic, non-informative or out of date. Hence, compare them to the PR diff code, and use them only as a reference.
- The generated title and description should prioritize the most significant changes.
Expand Down Expand Up @@ -46,43 +50,24 @@ Class FileDescription(BaseModel):
{%- endif %}
Class PRDescription(BaseModel):
type: List[PRType] = Field(description="one or more types that describe the PR content. Return the label value, not the name.")
{%- if enable_semantic_files_types %}
pr_files[List[FileDescription]] = Field(max_items=15, description="a list of the files in the PR, and their changes summary.")
{%- endif %}
description: str = Field(description="an informative and concise description of the PR. Use bullet points. Display first the most significant changes.")
title: str = Field(description="an informative title for the PR, describing its main theme")
type: List[PRType] = Field(description="one or more types that describe the PR type. Return the label value, not the name.")
description: str = Field(description="an informative and concise description of the PR. {%- if use_bullet_points %} Use bullet points.{% endif %}")
{%- if enable_custom_labels %}
labels: List[Label] = Field(min_items=0, description="choose the relevant custom labels that describe the PR content, and return their keys. Use the value field of the Label object to better understand the label meaning.")
{%- endif %}
{%- if enable_file_walkthrough %}
main_files_walkthrough: List[FileWalkthrough] = Field(max_items=10)
{%- endif %}
{%- if enable_semantic_files_types %}
pr_files[List[FileDescription]] = Field(max_items=15")
{%- endif %}
=====
Example output:
```yaml
title: |-
...
type:
- ...
- ...
{%- if enable_custom_labels %}
labels:
- |
...
- |
...
{%- endif %}
description: |-
...
{%- if enable_file_walkthrough %}
main_files_walkthrough:
- ...
- ...
{%- endif %}
{%- if enable_semantic_files_types %}
pr_files:
- filename: |
Expand All @@ -93,6 +78,17 @@ pr_files:
...
...
{%- endif %}
description: |-
...
title: |-
...
{%- if enable_custom_labels %}
labels:
- |
...
- |
...
{%- endif %}
```
Answer should be a valid YAML, and nothing else. Each YAML output MUST be after a newline, with proper indent, and block scalar indicator ('|-')
Expand Down
13 changes: 12 additions & 1 deletion pr_agent/tools/pr_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __init__(self, pr_url: str, args: list = None,
"description": self.git_provider.get_pr_description(full=False),
"language": self.main_pr_language,
"diff": "", # empty diff for initial calculation
"use_bullet_points": get_settings().pr_description.use_bullet_points,
"extra_instructions": get_settings().pr_description.extra_instructions,
"commit_messages_str": self.git_provider.get_commit_messages(),
"enable_custom_labels": get_settings().config.enable_custom_labels,
Expand Down Expand Up @@ -187,6 +186,18 @@ def _prepare_data(self):
# Load the AI prediction data into a dictionary
self.data = load_yaml(self.prediction.strip())

# re-order keys
if 'title' in self.data:
self.data['title'] = self.data.pop('title')
if 'type' in self.data:
self.data['type'] = self.data.pop('type')
if 'labels' in self.data:
self.data['labels'] = self.data.pop('labels')
if 'description' in self.data:
self.data['description'] = self.data.pop('description')
if 'pr_files' in self.data:
self.data['pr_files'] = self.data.pop('pr_files')

if get_settings().pr_description.add_original_user_description and self.user_description:
self.data["User Description"] = self.user_description

Expand Down
1 change: 0 additions & 1 deletion pr_agent/tools/pr_generate_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(self, pr_url: str, args: list = None,
"description": self.git_provider.get_pr_description(full=False),
"language": self.main_pr_language,
"diff": "", # empty diff for initial calculation
"use_bullet_points": get_settings().pr_description.use_bullet_points,
"extra_instructions": get_settings().pr_description.extra_instructions,
"commit_messages_str": self.git_provider.get_commit_messages(),
"enable_custom_labels": get_settings().config.enable_custom_labels,
Expand Down

0 comments on commit f52e9a9

Please sign in to comment.