2024-03-06 21:52:11 +02:00
## Overview
2025-04-18 02:03:47 +08:00
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:
2025-04-18 02:03:47 +08:00
2023-10-28 00:45:59 +03:00
```
2023-10-29 10:43:04 +02:00
/generate_labels
2023-10-28 00:45:59 +03:00
```
2024-04-18 10:04:38 +03:00
## Example usage
2023-10-28 00:45:59 +03:00
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:
2024-03-26 23:00:57 +02:00
{width=768}
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:
2024-03-06 21:52:11 +02:00
2024-03-26 23:00:57 +02:00
{width=768}
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
2025-04-18 02:03:47 +08:00
2023-12-18 13:41:50 +02:00
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)
2025-04-18 02:03:47 +08:00
2024-03-06 21:52:11 +02:00
When working from CLI, you need to apply the [configuration changes ](#configuration-options ) to the [custom_labels file ](https://github.com/Codium-ai/pr-agent/blob/main/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
2025-04-18 02:03:47 +08:00
2024-10-23 20:13:45 +05:30
To enable custom labels, you need to apply the [configuration changes ](#configuration-options ) to the local `.pr_agent.toml` file in your repository.
2023-10-29 13:02:07 +02:00
2024-03-06 21:52:11 +02:00
#### 3. Handle custom labels from the Repo's labels page 💎
2025-04-18 02:03:47 +08:00
2025-01-22 21:18:08 +02:00
> This feature is available only in Qodo Merge
2024-03-06 21:52:11 +02:00
2023-12-18 13:41:50 +02:00
* 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:
2025-04-18 02:03:47 +08:00
2023-12-18 10:04:05 +02:00
* 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.
2024-03-26 23:00:57 +02:00
{width=880}
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
2024-03-06 21:52:11 +02:00
> This feature is supported in GitHub and GitLab.
2023-12-18 10:04:05 +02:00
2024-03-06 21:52:11 +02:00
## Configuration options
2025-04-18 02:03:47 +08: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.
* 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"
2024-10-23 20:13:45 +05:30
```