mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-03 04:10:49 +08:00
feat: Refactor semantic labels in PR description and improve clarity in pr_description.py and pr_description_prompts.toml
This commit is contained in:
@ -38,9 +38,9 @@ class FileWalkthrough(BaseModel):
|
||||
{%- endif %}
|
||||
|
||||
{%- if enable_semantic_files_types %}
|
||||
class SemanticLabel(BaseModel):
|
||||
label: Any(PRType, str) = Field(description="a semantic label that represents a type of code changes that occurred in the PR. You can use a label from the $PRType enum, or use additional custom labels that you define.")
|
||||
files: List[str] = Field(description="a list of file names related to the semantic label. A file may appear in multiple labels. Present the file full path, and nothing else.")
|
||||
class SemanticFileLabels(BaseModel):
|
||||
label: str = Field(description="a semantic label that represents a type of code changes that occurred in the PR. Possible values (partial list): 'bug fix', 'tests', 'enhancement', 'documentation', 'error handling', 'configuration', 'logging', 'dependencies', 'new feature', ...")
|
||||
files: List[str] = Field(description="a list of file names related to the chosen semantic label. A file may appear in multiple labels. Present the file full path, and nothing else.")
|
||||
{%- endif %}
|
||||
|
||||
Class PRDescription(BaseModel):
|
||||
@ -54,7 +54,7 @@ Class PRDescription(BaseModel):
|
||||
main_files_walkthrough: List[FileWalkthrough] = Field(max_items=10)
|
||||
{%- endif %}
|
||||
{%- if enable_semantic_files_types %}
|
||||
pr_files_labels[List[SemanticLabel]] = Field(min_items=3, description="A list of semantic labels that describe the type of changes in the PR files.")
|
||||
pr_files_labels[List[SemanticFileLabels]] = Field(min_items=3, description="A list of semantic labels that describe the type of changes in the PR files.")
|
||||
{%- endif %}
|
||||
=====
|
||||
|
||||
|
@ -261,7 +261,7 @@ class PRDescription:
|
||||
for idx, (key, value) in enumerate(self.data.items()):
|
||||
key_publish = key.rstrip(':').replace("_", " ").capitalize()
|
||||
if key == 'pr_files_labels':
|
||||
key_publish = 'PR Files Labels'
|
||||
key_publish = 'PR Changes Analysis'
|
||||
pr_body += f"## {key_publish}\n"
|
||||
if 'walkthrough' in key.lower():
|
||||
# for filename, description in value.items():
|
||||
@ -279,9 +279,10 @@ class PRDescription:
|
||||
pr_body += """|\n|-----------|-------------|\n"""
|
||||
for semantic_label in value:
|
||||
# for filename, description in value.items():
|
||||
s_label = semantic_label['label'].strip("'").strip('"')
|
||||
if self.git_provider.is_supported("gfm_markdown"):
|
||||
# pr_body += f"<details> <summary>{semantic_label['label']}</summary>\n\n"
|
||||
pr_body += f"| **{semantic_label['label']}** | <details><summary>files:</summary><ul>"
|
||||
pr_body += f"| **{s_label}** | <details><summary>files:</summary><ul>"
|
||||
|
||||
for file in semantic_label['files']:
|
||||
filename = file.replace("'", "`")
|
||||
@ -290,6 +291,7 @@ class PRDescription:
|
||||
|
||||
# try to add line numbers link to code suggestions
|
||||
if hasattr(self.git_provider, 'get_line_link'):
|
||||
filename = filename.strip()
|
||||
link = self.git_provider.get_line_link(filename, relevant_line_start=-1)
|
||||
if link:
|
||||
filename = f"[{filename}]({link})"
|
||||
|
Reference in New Issue
Block a user