Merge pull request #1827 from qodo-ai/tr/changes_diagram_final_touches

fix: ensure proper formatting of changes_diagram in PR description ou…
This commit is contained in:
Tal
2025-05-25 15:00:23 +03:00
committed by GitHub
2 changed files with 22 additions and 18 deletions

View File

@ -46,12 +46,12 @@ class PRDescription(BaseModel):
type: List[PRType] = Field(description="one or more types that describe the PR content. Return the label member value (e.g. 'Bug fix', not 'bug_fix')") type: List[PRType] = Field(description="one or more types that describe the PR content. Return the label member value (e.g. 'Bug fix', not 'bug_fix')")
description: str = Field(description="summarize the PR changes in up to four bullet points, each up to 8 words. For large PRs, add sub-bullets if needed. Order bullets by importance, with each bullet highlighting a key change group.") description: str = Field(description="summarize the PR changes in up to four bullet points, each up to 8 words. For large PRs, add sub-bullets if needed. Order bullets by importance, with each bullet highlighting a key change group.")
title: str = Field(description="a concise and descriptive title that captures the PR's main theme") title: str = Field(description="a concise and descriptive title that captures the PR's main theme")
{%- if enable_pr_diagram %}
changes_diagram: str = Field(description="a horizontal diagram that represents the main PR changes, in the format of a valid mermaid LR flowchart. The diagram should be concise and easy to read. Leave empty if no diagram is relevant. To create robust Mermaid diagrams, follow this two-step process: (1) Declare first the nodes: nodeID['Node Label']. (2) Then define the links: nodeID1 -- 'link text' --> nodeID2 ")
{%- endif %}
{%- if enable_semantic_files_types %} {%- if enable_semantic_files_types %}
pr_files: List[FileDescription] = Field(max_items=20, description="a list of all the files that were changed in the PR, and summary of their changes. Each file must be analyzed regardless of change size.") pr_files: List[FileDescription] = Field(max_items=20, description="a list of all the files that were changed in the PR, and summary of their changes. Each file must be analyzed regardless of change size.")
{%- endif %} {%- endif %}
{%- if enable_pr_diagram %}
changes_diagram: str = Field(description="a horizontal diagram that represents the main PR changes, in the format of a mermaid flowchart. The diagram should be concise and easy to read. Leave empty if no diagram is relevant.")
{%- endif %}
===== =====
@ -65,6 +65,13 @@ description: |
... ...
title: | title: |
... ...
{%- if enable_pr_diagram %}
changes_diagram: |
```mermaid
flowchart LR
...
```
{%- endif %}
{%- if enable_semantic_files_types %} {%- if enable_semantic_files_types %}
pr_files: pr_files:
- filename: | - filename: |
@ -79,12 +86,6 @@ pr_files:
label_key_1 label_key_1
... ...
{%- endif %} {%- endif %}
{%- if enable_pr_diagram %}
changes_diagram: |
```mermaid
...
```
{%- 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 ('|') Answer should be a valid YAML, and nothing else. Each YAML output MUST be after a newline, with proper indent, and block scalar indicator ('|')
@ -152,6 +153,13 @@ description: |
... ...
title: | title: |
... ...
{%- if enable_pr_diagram %}
changes_diagram: |
```mermaid
flowchart LR
...
```
{%- endif %}
{%- if enable_semantic_files_types %} {%- if enable_semantic_files_types %}
pr_files: pr_files:
- filename: | - filename: |
@ -166,12 +174,6 @@ pr_files:
label_key_1 label_key_1
... ...
{%- endif %} {%- endif %}
{%- if enable_pr_diagram %}
changes_diagram: |
```mermaid
...
```
{%- endif %}
``` ```
(replace '...' with the actual values) (replace '...' with the actual values)
{%- endif %} {%- endif %}

View File

@ -458,9 +458,11 @@ class PRDescription:
if 'description' in self.data: if 'description' in self.data:
self.data['description'] = self.data.pop('description') self.data['description'] = self.data.pop('description')
if 'changes_diagram' in self.data: if 'changes_diagram' in self.data:
changes_diagram = self.data.pop('changes_diagram') changes_diagram = self.data.pop('changes_diagram').strip()
if changes_diagram.strip(): if changes_diagram.startswith('```'):
self.data['changes_diagram'] = changes_diagram if not changes_diagram.endswith('```'): # fallback for missing closing
changes_diagram += '\n```'
self.data['changes_diagram'] = '\n'+ changes_diagram
if 'pr_files' in self.data: if 'pr_files' in self.data:
self.data['pr_files'] = self.data.pop('pr_files') self.data['pr_files'] = self.data.pop('pr_files')