diff --git a/pr_agent/settings/pr_description_prompts.toml b/pr_agent/settings/pr_description_prompts.toml index bbe55252..934b30da 100644 --- a/pr_agent/settings/pr_description_prompts.toml +++ b/pr_agent/settings/pr_description_prompts.toml @@ -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')") 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") -{%- 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.") -{%- 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 %} +{%- 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.") +{%- endif %} ===== @@ -65,6 +65,12 @@ description: | ... title: | ... +{%- if enable_pr_diagram %} + changes_diagram: | + ```mermaid + ... + ``` +{%- endif %} {%- if enable_semantic_files_types %} pr_files: - filename: | @@ -79,12 +85,6 @@ pr_files: label_key_1 ... {%- 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 ('|') @@ -152,6 +152,12 @@ description: | ... title: | ... +{%- if enable_pr_diagram %} + changes_diagram: | + ```mermaid + ... + ``` +{%- endif %} {%- if enable_semantic_files_types %} pr_files: - filename: | @@ -166,12 +172,6 @@ pr_files: label_key_1 ... {%- endif %} -{%- if enable_pr_diagram %} - changes_diagram: | - ```mermaid - ... - ``` -{%- endif %} ``` (replace '...' with the actual values) {%- endif %} diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py index 3bd4ecf7..663c5a2d 100644 --- a/pr_agent/tools/pr_description.py +++ b/pr_agent/tools/pr_description.py @@ -458,9 +458,11 @@ class PRDescription: if 'description' in self.data: self.data['description'] = self.data.pop('description') if 'changes_diagram' in self.data: - changes_diagram = self.data.pop('changes_diagram') - if changes_diagram.strip(): - self.data['changes_diagram'] = changes_diagram + changes_diagram = self.data.pop('changes_diagram').strip() + if changes_diagram.startswith('```'): + 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: self.data['pr_files'] = self.data.pop('pr_files')