mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 12:50:38 +08:00
feat: Reorder keys in PR description data and update PRDescription model in toml file
This commit is contained in:
@ -50,12 +50,12 @@ Class FileDescription(BaseModel):
|
|||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
Class PRDescription(BaseModel):
|
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 %}
|
{%- 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.")
|
pr_files[List[FileDescription]] = Field(max_items=15, description="a list of the files in the PR, and their changes summary.")
|
||||||
{%- endif %}
|
{%- 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")
|
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 %}
|
{%- 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.")
|
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 %}
|
{%- endif %}
|
||||||
@ -65,6 +65,9 @@ Class PRDescription(BaseModel):
|
|||||||
Example output:
|
Example output:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
type:
|
||||||
|
- ...
|
||||||
|
- ...
|
||||||
{%- if enable_semantic_files_types %}
|
{%- if enable_semantic_files_types %}
|
||||||
pr_files:
|
pr_files:
|
||||||
- filename: |
|
- filename: |
|
||||||
@ -75,11 +78,10 @@ pr_files:
|
|||||||
...
|
...
|
||||||
...
|
...
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
description: |-
|
||||||
|
...
|
||||||
title: |-
|
title: |-
|
||||||
...
|
...
|
||||||
type:
|
|
||||||
- ...
|
|
||||||
- ...
|
|
||||||
{%- if enable_custom_labels %}
|
{%- if enable_custom_labels %}
|
||||||
labels:
|
labels:
|
||||||
- |
|
- |
|
||||||
@ -87,8 +89,6 @@ labels:
|
|||||||
- |
|
- |
|
||||||
...
|
...
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
description: |-
|
|
||||||
...
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Answer should be a valid YAML, and nothing else. Each YAML output MUST be after a newline, with proper indent, and block scalar indicator ('|-')
|
Answer should be a valid YAML, and nothing else. Each YAML output MUST be after a newline, with proper indent, and block scalar indicator ('|-')
|
||||||
|
@ -48,7 +48,6 @@ class PRDescription:
|
|||||||
"description": self.git_provider.get_pr_description(full=False),
|
"description": self.git_provider.get_pr_description(full=False),
|
||||||
"language": self.main_pr_language,
|
"language": self.main_pr_language,
|
||||||
"diff": "", # empty diff for initial calculation
|
"diff": "", # empty diff for initial calculation
|
||||||
"use_bullet_points": get_settings().pr_description.use_bullet_points,
|
|
||||||
"extra_instructions": get_settings().pr_description.extra_instructions,
|
"extra_instructions": get_settings().pr_description.extra_instructions,
|
||||||
"commit_messages_str": self.git_provider.get_commit_messages(),
|
"commit_messages_str": self.git_provider.get_commit_messages(),
|
||||||
"enable_custom_labels": get_settings().config.enable_custom_labels,
|
"enable_custom_labels": get_settings().config.enable_custom_labels,
|
||||||
@ -187,6 +186,18 @@ class PRDescription:
|
|||||||
# Load the AI prediction data into a dictionary
|
# Load the AI prediction data into a dictionary
|
||||||
self.data = load_yaml(self.prediction.strip())
|
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:
|
if get_settings().pr_description.add_original_user_description and self.user_description:
|
||||||
self.data["User Description"] = self.user_description
|
self.data["User Description"] = self.user_description
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ class PRGenerateLabels:
|
|||||||
"description": self.git_provider.get_pr_description(full=False),
|
"description": self.git_provider.get_pr_description(full=False),
|
||||||
"language": self.main_pr_language,
|
"language": self.main_pr_language,
|
||||||
"diff": "", # empty diff for initial calculation
|
"diff": "", # empty diff for initial calculation
|
||||||
"use_bullet_points": get_settings().pr_description.use_bullet_points,
|
|
||||||
"extra_instructions": get_settings().pr_description.extra_instructions,
|
"extra_instructions": get_settings().pr_description.extra_instructions,
|
||||||
"commit_messages_str": self.git_provider.get_commit_messages(),
|
"commit_messages_str": self.git_provider.get_commit_messages(),
|
||||||
"enable_custom_labels": get_settings().config.enable_custom_labels,
|
"enable_custom_labels": get_settings().config.enable_custom_labels,
|
||||||
|
Reference in New Issue
Block a user