mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 11:50:37 +08:00
s1
This commit is contained in:
@ -341,7 +341,7 @@ def set_custom_labels(variables):
|
|||||||
# final_labels += f" - {k} ({v['description']})\n"
|
# final_labels += f" - {k} ({v['description']})\n"
|
||||||
#variables["custom_labels"] = final_labels
|
#variables["custom_labels"] = final_labels
|
||||||
#variables["custom_labels_examples"] = f" - {list(labels.keys())[0]}"
|
#variables["custom_labels_examples"] = f" - {list(labels.keys())[0]}"
|
||||||
variables["custom_labels_class"] = "class Labels(Enum):"
|
variables["custom_labels_class"] = "class Label(Enum):"
|
||||||
for k, v in labels.items():
|
for k, v in labels.items():
|
||||||
variables["custom_labels_class"] += f"\n {k.lower().replace(' ','_')} = '{k}' # {v['description']}"
|
variables["custom_labels_class"] += f"\n {k.lower().replace(' ','_')} = '{k}' # {v['description']}"
|
||||||
|
|
||||||
|
@ -21,18 +21,22 @@ For example:
|
|||||||
- cli.py --issue_url=... similar_issue
|
- cli.py --issue_url=... similar_issue
|
||||||
|
|
||||||
Supported commands:
|
Supported commands:
|
||||||
-review / review_pr - Add a review that includes a summary of the PR and specific suggestions for improvement.
|
- review / review_pr - Add a review that includes a summary of the PR and specific suggestions for improvement.
|
||||||
|
|
||||||
-ask / ask_question [question] - Ask a question about the PR.
|
- ask / ask_question [question] - Ask a question about the PR.
|
||||||
|
|
||||||
-describe / describe_pr - Modify the PR title and description based on the PR's contents.
|
- describe / describe_pr - Modify the PR title and description based on the PR's contents.
|
||||||
|
|
||||||
-improve / improve_code - Suggest improvements to the code in the PR as pull request comments ready to commit.
|
- improve / improve_code - Suggest improvements to the code in the PR as pull request comments ready to commit.
|
||||||
Extended mode ('improve --extended') employs several calls, and provides a more thorough feedback
|
Extended mode ('improve --extended') employs several calls, and provides a more thorough feedback
|
||||||
|
|
||||||
-reflect - Ask the PR author questions about the PR.
|
- reflect - Ask the PR author questions about the PR.
|
||||||
|
|
||||||
-update_changelog - Update the changelog based on the PR's contents.
|
- update_changelog - Update the changelog based on the PR's contents.
|
||||||
|
|
||||||
|
- add_docs
|
||||||
|
|
||||||
|
- generate_labels
|
||||||
|
|
||||||
|
|
||||||
Configuration:
|
Configuration:
|
||||||
|
@ -11,38 +11,35 @@ Extra instructions from the user:
|
|||||||
'
|
'
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
You must use the following YAML schema to format your answer:
|
The output must be a YAML object equivalent to type $Labels, according to the following Pydantic definitions:
|
||||||
```yaml
|
'
|
||||||
PR Type:
|
|
||||||
type: array
|
|
||||||
{%- if enable_custom_labels %}
|
{%- if enable_custom_labels %}
|
||||||
description: One or more labels that describe the PR type. Don't output the description in the parentheses.
|
|
||||||
{%- endif %}
|
{{ custom_labels_class }}
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
{%- if enable_custom_labels %}
|
|
||||||
{{ custom_labels }}
|
|
||||||
{%- else %}
|
{%- else %}
|
||||||
- Bug fix
|
class Label(Enum):
|
||||||
- Tests
|
bug_fix = "Bug fix"
|
||||||
- Refactoring
|
tests = "Tests"
|
||||||
- Enhancement
|
refactoring = "Refactoring"
|
||||||
- Documentation
|
enhancement = "Enhancement"
|
||||||
- Other
|
documentation = "Documentation"
|
||||||
|
other = "Other"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
class Labels(BaseModel):
|
||||||
|
labels: List[Label]
|
||||||
|
'
|
||||||
|
|
||||||
|
|
||||||
Example output:
|
Example output:
|
||||||
```yaml
|
```yaml
|
||||||
PR Type:
|
labels:
|
||||||
{%- if enable_custom_labels %}
|
- ...
|
||||||
{{ custom_labels_examples }}
|
- ...
|
||||||
{%- else %}
|
|
||||||
- Bug fix
|
|
||||||
{%- endif %}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure to output a valid YAML. Don't repeat the prompt in the answer, and avoid outputting the 'type' and 'description' fields.
|
Answer should be a valid YAML, and nothing else.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
user="""PR Info:
|
user="""PR Info:
|
||||||
|
@ -38,7 +38,7 @@ Class PRDescription(BaseModel):
|
|||||||
type: List[PRType] = Field(description="one or more types that describe the PR type")
|
type: List[PRType] = Field(description="one or more types that describe the PR type")
|
||||||
description: str = Field(description="an informative and concise description of the PR. {%- if use_bullet_points %} Use bullet points. {% endif %}")
|
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[Labels] = Field(description="one or more custom labels that describe the PR")
|
labels: List[Label] = Field(description="one or more custom labels that describe the PR")
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
main_files_walkthrough: List[FileWalkthrough] = Field(max_items=10)
|
main_files_walkthrough: List[FileWalkthrough] = Field(max_items=10)
|
||||||
'
|
'
|
||||||
|
@ -44,7 +44,7 @@ class PRDescription:
|
|||||||
"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,
|
||||||
"custom_labels_class": "", # will be filled if necessary in 'set_custom_labels'
|
"custom_labels_class": "", # will be filled if necessary in 'set_custom_labels' function
|
||||||
}
|
}
|
||||||
|
|
||||||
self.user_description = self.git_provider.get_user_description()
|
self.user_description = self.git_provider.get_user_description()
|
||||||
|
@ -43,9 +43,8 @@ class PRGenerateLabels:
|
|||||||
"use_bullet_points": get_settings().pr_description.use_bullet_points,
|
"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(),
|
||||||
"custom_labels": "",
|
|
||||||
"custom_labels_examples": "",
|
|
||||||
"enable_custom_labels": get_settings().config.enable_custom_labels,
|
"enable_custom_labels": get_settings().config.enable_custom_labels,
|
||||||
|
"custom_labels_class": "", # will be filled if necessary in 'set_custom_labels' function
|
||||||
}
|
}
|
||||||
|
|
||||||
# Initialize the token handler
|
# Initialize the token handler
|
||||||
@ -159,11 +158,11 @@ class PRGenerateLabels:
|
|||||||
def _prepare_labels(self) -> List[str]:
|
def _prepare_labels(self) -> List[str]:
|
||||||
pr_types = []
|
pr_types = []
|
||||||
|
|
||||||
# If the 'PR Type' key is present in the dictionary, split its value by comma and assign it to 'pr_types'
|
# If the 'labels' key is present in the dictionary, split its value by comma and assign it to 'pr_types'
|
||||||
if 'PR Type' in self.data:
|
if 'labels' in self.data:
|
||||||
if type(self.data['PR Type']) == list:
|
if type(self.data['labels']) == list:
|
||||||
pr_types = self.data['PR Type']
|
pr_types = self.data['labels']
|
||||||
elif type(self.data['PR Type']) == str:
|
elif type(self.data['labels']) == str:
|
||||||
pr_types = self.data['PR Type'].split(',')
|
pr_types = self.data['labels'].split(',')
|
||||||
|
|
||||||
return pr_types
|
return pr_types
|
||||||
|
Reference in New Issue
Block a user