mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 11:50:37 +08:00
refactor: moved diagram logic to 'changes_diagram' in PRDescription and updated prompt for clarity
This commit is contained in:
@ -44,11 +44,14 @@ class FileDescription(BaseModel):
|
||||
|
||||
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. {% if add_diagram %} Also, generate a Mermaid sequence diagram that focuses on the main function call flow between classes or components. {% endif %}")
|
||||
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 %}
|
||||
=====
|
||||
|
||||
|
||||
@ -60,14 +63,6 @@ type:
|
||||
- ...
|
||||
description: |
|
||||
...
|
||||
{%- if add_diagram %}
|
||||
diagram: |
|
||||
sequenceDiagram
|
||||
participant A as ComponentA
|
||||
participant B as ComponentB
|
||||
A->>B: functionCall()
|
||||
B-->>A: response
|
||||
{%- endif %}
|
||||
title: |
|
||||
...
|
||||
{%- if enable_semantic_files_types %}
|
||||
@ -84,6 +79,12 @@ 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 ('|')
|
||||
@ -149,14 +150,6 @@ type:
|
||||
- ...
|
||||
description: |
|
||||
...
|
||||
{%- if add_diagram %}
|
||||
diagram: |
|
||||
sequenceDiagram
|
||||
participant A as ComponentA
|
||||
participant B as ComponentB
|
||||
A->>B: functionCall()
|
||||
B-->>A: response
|
||||
{%- endif %}
|
||||
title: |
|
||||
...
|
||||
{%- if enable_semantic_files_types %}
|
||||
@ -173,6 +166,12 @@ pr_files:
|
||||
label_key_1
|
||||
...
|
||||
{%- endif %}
|
||||
{%- if enable_pr_diagram %}
|
||||
changes_diagram: |
|
||||
```mermaid
|
||||
...
|
||||
```
|
||||
{%- endif %}
|
||||
```
|
||||
(replace '...' with the actual values)
|
||||
{%- endif %}
|
||||
@ -180,4 +179,4 @@ pr_files:
|
||||
|
||||
Response (should be a valid YAML, and nothing else):
|
||||
```yaml
|
||||
"""
|
||||
"""
|
@ -73,7 +73,7 @@ class PRDescription:
|
||||
"related_tickets": "",
|
||||
"include_file_summary_changes": len(self.git_provider.get_diff_files()) <= self.COLLAPSIBLE_FILE_LIST_THRESHOLD,
|
||||
"duplicate_prompt_examples": get_settings().config.get("duplicate_prompt_examples", False),
|
||||
"add_diagram": get_settings().config.get('pr_description.add_diagram', False),
|
||||
"enable_pr_diagram": get_settings().pr_description.get("enable_pr_diagram", False),
|
||||
}
|
||||
|
||||
self.user_description = self.git_provider.get_user_description()
|
||||
@ -457,6 +457,10 @@ class PRDescription:
|
||||
self.data['labels'] = self.data.pop('labels')
|
||||
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
|
||||
if 'pr_files' in self.data:
|
||||
self.data['pr_files'] = self.data.pop('pr_files')
|
||||
|
||||
@ -821,4 +825,4 @@ def replace_code_tags(text):
|
||||
parts = text.split('`')
|
||||
for i in range(1, len(parts), 2):
|
||||
parts[i] = '<code>' + parts[i] + '</code>'
|
||||
return ''.join(parts)
|
||||
return ''.join(parts)
|
Reference in New Issue
Block a user