2023-12-24 13:08:13 +02:00
# Generate Custom Labels 💎
2023-10-29 10:43:04 +02:00
The `generate_labels` tool scans the PR code changes, and given a list of labels and their descriptions, it automatically suggests labels that match the PR code changes.
2023-10-28 00:45:59 +03:00
It can be invoked manually by commenting on any PR:
```
2023-10-29 10:43:04 +02:00
/generate_labels
2023-10-28 00:45:59 +03:00
```
For example:
If we wish to add detect changes to SQL queries in a given PR, we can add the following custom label along with its description:
2023-12-03 08:41:09 +02:00
< kbd > < img src = https://codium.ai/images/pr_agent/custom_labels_list.png width = "768" > < / kbd >
2023-10-30 15:20:17 +02:00
2023-10-29 10:43:04 +02:00
When running the `generate_labels` tool on a PR that includes changes in SQL queries, it will automatically suggest the custom label:
2023-12-03 08:41:09 +02:00
< kbd > < img src = https://codium.ai/images/pr_agent/custom_label_published.png width = "768" > < / kbd >
2023-10-28 00:45:59 +03:00
2023-12-18 13:41:50 +02:00
Note that in addition to the dedicated tool `generate_labels` , the custom labels will also be used by the `describe` tool.
2023-10-29 14:43:45 +02:00
2023-12-18 13:41:50 +02:00
### How to enable custom labels
There are 3 ways to enable custom labels:
2023-10-29 14:43:45 +02:00
2023-12-18 13:41:50 +02:00
#### 1. CLI (local configuration file)
When working from CLI, you need to apply the [configuration changes ](#configuration-changes ) to the [custom_labels file ](./../pr_agent/settings/custom_labels.toml ):
2023-10-29 14:43:45 +02:00
2023-12-18 13:41:50 +02:00
#### 2. Repo configuration file
2023-10-29 14:43:45 +02:00
To enable custom labels, you need to apply the [configuration changes ](#configuration-changes ) to the local `.pr_agent.toml` file in you repository.
2023-10-29 13:02:07 +02:00
2023-12-24 13:08:13 +02:00
#### 3. Handle custom labels from the Repo's labels page
2023-12-18 13:41:50 +02:00
> This feature is available only in PR-Agent Pro
* GitHub : `https://github.com/{owner}/{repo}/labels` , or click on the "Labels" tab in the issues or PRs page.
* GitLab : `https://gitlab.com/{owner}/{repo}/-/labels` , or click on "Manage" -> "Labels" on the left menu.
2023-12-18 10:04:05 +02:00
b. Add/edit the custom labels. It should be formatted as follows:
* Label name: The name of the custom label.
2023-12-18 13:41:50 +02:00
* 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.
< kbd > < img src = https://codium.ai/images/pr_agent/add_native_custom_labels.png width = "880" > < / kbd >
2023-12-18 13:44:37 +02:00
2023-12-18 10:04:05 +02:00
c. Now the custom labels will be included in the `generate_labels` tool.
2023-12-18 13:41:50 +02:00
2023-12-18 10:04:05 +02:00
*This feature is supported in GitHub and GitLab.
2023-10-29 13:02:07 +02:00
#### Configuration changes
2023-10-28 00:45:59 +03:00
- Change `enable_custom_labels` to True: This will turn off the default labels and enable the custom labels provided in the custom_labels.toml file.
2023-10-29 13:02:07 +02:00
- Add the custom labels. It should be formatted as follows:
2023-10-29 13:58:01 +02:00
```
2023-10-29 13:02:07 +02:00
[config]
enable_custom_labels=true
2023-10-28 00:45:59 +03:00
[custom_labels."Custom Label Name"]
description = "Description of when AI should suggest this label"
2023-10-29 13:02:07 +02:00
[custom_labels."Custom Label 2"]
description = "Description of when AI should suggest this label 2"
2023-10-28 00:45:59 +03:00
```
2023-10-29 13:02:07 +02:00