mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 04:40:38 +08:00
readme
This commit is contained in:
@ -69,22 +69,6 @@ If you prefer to have the file summaries appear in the "Files changed" tab on ev
|
|||||||
**Note**: that this feature is currently available only for GitHub.
|
**Note**: that this feature is currently available only for GitHub.
|
||||||
|
|
||||||
|
|
||||||
### Handle custom labels from the Repo's labels page 💎
|
|
||||||
|
|
||||||
You can control the custom labels that will be suggested by the `describe` tool, from the repo's labels page:
|
|
||||||
|
|
||||||
* GitHub : go to `https://github.com/{owner}/{repo}/labels` (or click on the "Labels" tab in the issues or PRs page)
|
|
||||||
* GitLab : go to `https://gitlab.com/{owner}/{repo}/-/labels` (or click on "Manage" -> "Labels" on the left menu)
|
|
||||||
|
|
||||||
Now add/edit the custom labels. they should be formatted as follows:
|
|
||||||
|
|
||||||
* Label name: The name of the custom label.
|
|
||||||
* Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.<br>
|
|
||||||
|
|
||||||
The description should be comprehensive and detailed, indicating when to add the desired label. For example:
|
|
||||||
{width=768}
|
|
||||||
|
|
||||||
|
|
||||||
### Markers template
|
### Markers template
|
||||||
|
|
||||||
To enable markers, set `pr_description.use_description_markers=true`.
|
To enable markers, set `pr_description.use_description_markers=true`.
|
||||||
@ -117,6 +101,43 @@ The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary`
|
|||||||
- `use_description_markers`: if set to true, the tool will use markers template. It replaces every marker of the form `pr_agent:marker_name` with the relevant content. Default is false.
|
- `use_description_markers`: if set to true, the tool will use markers template. It replaces every marker of the form `pr_agent:marker_name` with the relevant content. Default is false.
|
||||||
- `include_generated_by_header`: if set to true, the tool will add a dedicated header: 'Generated by PR Agent at ...' to any automatic content. Default is true.
|
- `include_generated_by_header`: if set to true, the tool will add a dedicated header: 'Generated by PR Agent at ...' to any automatic content. Default is true.
|
||||||
|
|
||||||
|
## Custom labels
|
||||||
|
|
||||||
|
The default labels of the describe tool are quite generic, since they are meant to be used in any repo: [`Bug fix`, `Tests`, `Enhancement`, `Documentation`, `Other`].
|
||||||
|
|
||||||
|
You can define custom labels that are relevant for your repo and use cases.
|
||||||
|
Custom labels can be defined in a [configuration file](https://pr-agent-docs.codium.ai/tools/custom_labels/#configuration-options), or directly in the repo's [labels page](#handle-custom-labels-from-the-repos-labels-page).
|
||||||
|
|
||||||
|
Examples for custom labels:
|
||||||
|
|
||||||
|
- `Main topic:performance` - pr_agent:The main topic of this PR is performance
|
||||||
|
- `New endpoint` - pr_agent:A new endpoint was added in this PR
|
||||||
|
- `SQL query` - pr_agent:A new SQL query was added in this PR
|
||||||
|
- `Dockerfile changes` - pr_agent:The PR contains changes in the Dockerfile
|
||||||
|
- ...
|
||||||
|
|
||||||
|
The list above is eclectic, and aims to give an idea of different possibilities. Define custom labels that are relevant for your repo and use cases.
|
||||||
|
Note that Labels are not mutually exclusive, so you can add multiple label categories.
|
||||||
|
<br>
|
||||||
|
Make sure to provide proper title, and a detailed and well-phrased description for each label, so the tool will know when to suggest it.
|
||||||
|
Each label description should be a **conditional statement**, that indicates if to add the label to the PR or not, according to the PR content.
|
||||||
|
|
||||||
|
|
||||||
|
### Handle custom labels from the Repo's labels page 💎
|
||||||
|
|
||||||
|
You can control the custom labels that will be suggested by the `describe` tool, from the repo's labels page:
|
||||||
|
|
||||||
|
* GitHub : go to `https://github.com/{owner}/{repo}/labels` (or click on the "Labels" tab in the issues or PRs page)
|
||||||
|
* GitLab : go to `https://gitlab.com/{owner}/{repo}/-/labels` (or click on "Manage" -> "Labels" on the left menu)
|
||||||
|
|
||||||
|
Now add/edit the custom labels. they should be formatted as follows:
|
||||||
|
|
||||||
|
* Label name: The name of the custom label.
|
||||||
|
* Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.<br>
|
||||||
|
|
||||||
|
The description should be comprehensive and detailed, indicating when to add the desired label. For example:
|
||||||
|
{width=768}
|
||||||
|
|
||||||
|
|
||||||
## Usage Tips
|
## Usage Tips
|
||||||
|
|
||||||
@ -145,20 +166,3 @@ The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary`
|
|||||||
* `walkthrough`: the PR walkthrough.
|
* `walkthrough`: the PR walkthrough.
|
||||||
|
|
||||||
- Note that when markers are enabled, if the original PR description does not contain any markers, the tool will not alter the description at all.
|
- Note that when markers are enabled, if the original PR description does not contain any markers, the tool will not alter the description at all.
|
||||||
|
|
||||||
!!! tip "Custom labels"
|
|
||||||
|
|
||||||
The default labels of the describe tool are quite generic, since they are meant to be used in any repo: [`Bug fix`, `Tests`, `Enhancement`, `Documentation`, `Other`].
|
|
||||||
|
|
||||||
If you specify [custom labels](#handle-custom-labels-from-the-repos-labels-page) in the repo's labels page, you can get tailored labels for your use cases.
|
|
||||||
Examples for custom labels:
|
|
||||||
|
|
||||||
- `Main topic:performance` - pr_agent:The main topic of this PR is performance
|
|
||||||
- `New endpoint` - pr_agent:A new endpoint was added in this PR
|
|
||||||
- `SQL query` - pr_agent:A new SQL query was added in this PR
|
|
||||||
- `Dockerfile changes` - pr_agent:The PR contains changes in the Dockerfile
|
|
||||||
- ...
|
|
||||||
|
|
||||||
The list above is eclectic, and aims to give an idea of different possibilities. Define custom labels that are relevant for your repo and use cases.
|
|
||||||
Note that Labels are not mutually exclusive, so you can add multiple label categories.
|
|
||||||
<br>Make sure to provide proper title, and a detailed and well-phrased description for each label, so the tool will know when to suggest it.
|
|
||||||
|
@ -196,6 +196,7 @@ class PRCodeSuggestions:
|
|||||||
suggestion_list = []
|
suggestion_list = []
|
||||||
one_sentence_summary_list = []
|
one_sentence_summary_list = []
|
||||||
for i, suggestion in enumerate(data['code_suggestions']):
|
for i, suggestion in enumerate(data['code_suggestions']):
|
||||||
|
try:
|
||||||
if get_settings().pr_code_suggestions.summarize:
|
if get_settings().pr_code_suggestions.summarize:
|
||||||
if not suggestion or 'one_sentence_summary' not in suggestion or 'label' not in suggestion or 'relevant_file' not in suggestion:
|
if not suggestion or 'one_sentence_summary' not in suggestion or 'label' not in suggestion or 'relevant_file' not in suggestion:
|
||||||
get_logger().debug(f"Skipping suggestion {i + 1}, because it is invalid: {suggestion}")
|
get_logger().debug(f"Skipping suggestion {i + 1}, because it is invalid: {suggestion}")
|
||||||
@ -205,6 +206,10 @@ class PRCodeSuggestions:
|
|||||||
get_logger().debug(f"Skipping suggestion {i + 1}, because it is a duplicate: {suggestion}")
|
get_logger().debug(f"Skipping suggestion {i + 1}, because it is a duplicate: {suggestion}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if 'const' in suggestion['suggestion_content'] and 'instead' in suggestion['suggestion_content'] and 'let' in suggestion['suggestion_content']:
|
||||||
|
get_logger().debug(f"Skipping suggestion {i + 1}, because it uses 'const instead let': {suggestion}")
|
||||||
|
continue
|
||||||
|
|
||||||
if ('existing_code' in suggestion) and ('improved_code' in suggestion) and (
|
if ('existing_code' in suggestion) and ('improved_code' in suggestion) and (
|
||||||
suggestion['existing_code'] != suggestion['improved_code']):
|
suggestion['existing_code'] != suggestion['improved_code']):
|
||||||
suggestion = self._truncate_if_needed(suggestion)
|
suggestion = self._truncate_if_needed(suggestion)
|
||||||
@ -214,6 +219,8 @@ class PRCodeSuggestions:
|
|||||||
else:
|
else:
|
||||||
get_logger().debug(
|
get_logger().debug(
|
||||||
f"Skipping suggestion {i + 1}, because existing code is equal to improved code {suggestion['existing_code']}")
|
f"Skipping suggestion {i + 1}, because existing code is equal to improved code {suggestion['existing_code']}")
|
||||||
|
except Exception as e:
|
||||||
|
get_logger().error(f"Error processing suggestion {i + 1}: {suggestion}, error: {e}")
|
||||||
data['code_suggestions'] = suggestion_list
|
data['code_suggestions'] = suggestion_list
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
Reference in New Issue
Block a user