mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-21 04:50:39 +08:00
Compare commits
33 Commits
hl/flip_2_
...
test-PR-ne
Author | SHA1 | Date | |
---|---|---|---|
254c3e2ed1 | |||
cac450098a | |||
097637d7c0 | |||
e4157d2efc | |||
34ad5f2aa2 | |||
3c76230f61 | |||
92cde2ef99 | |||
0b10f88b84 | |||
3dbe1bbc35 | |||
2e34436589 | |||
fae6cab2a7 | |||
19f239ae3d | |||
d457fa2b9f | |||
d430604dfe | |||
0a53f09a7f | |||
7a9e73702d | |||
e429c5d012 | |||
1c8aeb2b64 | |||
4d6126d2c0 | |||
a9d30c1d10 | |||
ea4d4ab618 | |||
3088c58d5f | |||
0f99db65a9 | |||
f913f02ea6 | |||
7563af08a0 | |||
ad96326832 | |||
003d5728e0 | |||
8242b10d8e | |||
1c296127bd | |||
2f4e40860d | |||
b076c33351 | |||
e2e0bea8fd | |||
e878dcb6b1 |
@ -4,4 +4,4 @@ enable_auto_approval = true
|
|||||||
|
|
||||||
|
|
||||||
[pr_code_suggestions]
|
[pr_code_suggestions]
|
||||||
summarize=true
|
commitable_code_suggestions=false
|
||||||
|
11
README.md
11
README.md
@ -40,6 +40,17 @@ CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by p
|
|||||||
|
|
||||||
## News and Updates
|
## News and Updates
|
||||||
|
|
||||||
|
### May 2, 2024
|
||||||
|
Check out the new [PR-Agent Chrome Extension](https://chromewebstore.google.com/detail/pr-agent-chrome-extension/ephlnjeghhogofkifjloamocljapahnl) 🚀🚀🚀
|
||||||
|
|
||||||
|
This toolbar integrates seamlessly with your GitHub environment, allowing you to access PR-Agent tools [directly from the GitHub interface](https://www.youtube.com/watch?v=gT5tli7X4H4).
|
||||||
|
You can also easily export your chosen configuration, and use it for the automatic commands.
|
||||||
|
|
||||||
|
<kbd><img src="https://codium.ai/images/pr_agent/toolbar1.png" width="512"></kbd>
|
||||||
|
|
||||||
|
<kbd><img src="https://codium.ai/images/pr_agent/toolbar2.png" width="512"></kbd>
|
||||||
|
|
||||||
|
|
||||||
### April 14, 2024
|
### April 14, 2024
|
||||||
You can now ask questions about images that appear in the comment, where the entire PR is considered as the context.
|
You can now ask questions about images that appear in the comment, where the entire PR is considered as the context.
|
||||||
see [here](https://pr-agent-docs.codium.ai/tools/ask/#ask-on-images) for more details.
|
see [here](https://pr-agent-docs.codium.ai/tools/ask/#ask-on-images) for more details.
|
||||||
|
@ -9,6 +9,7 @@ It can be invoked manually by commenting on any PR:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Example usage
|
## Example usage
|
||||||
|
|
||||||
An example result:
|
An example result:
|
||||||
|
|
||||||
{width=750}
|
{width=750}
|
||||||
|
@ -5,7 +5,8 @@ It can be invoked manually by commenting on any PR:
|
|||||||
```
|
```
|
||||||
/ask "..."
|
/ask "..."
|
||||||
```
|
```
|
||||||
For example:
|
|
||||||
|
## Example usage
|
||||||
|
|
||||||
{width=512}
|
{width=512}
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@ The tool analyzes the failed checks and provides several feedbacks:
|
|||||||
- Failure summary
|
- Failure summary
|
||||||
- Relevant error logs
|
- Relevant error logs
|
||||||
|
|
||||||
|
## Example usage
|
||||||
|
|
||||||
{width=768}
|
{width=768}
|
||||||
|
|
||||||
→
|
→
|
||||||
@ -21,6 +23,14 @@ In addition to being automatically triggered, the tool can also be invoked manua
|
|||||||
```
|
```
|
||||||
where `{repo_name}` is the name of the repository, `{run_number}` is the run number of the failed check, and `{job_number}` is the job number of the failed check.
|
where `{repo_name}` is the name of the repository, `{run_number}` is the run number of the failed check, and `{job_number}` is the job number of the failed check.
|
||||||
|
|
||||||
|
## Disabling the tool from running automatically
|
||||||
|
|
||||||
|
If you wish to disable the tool from running automatically, you can do so by adding the following configuration to the configuration file:
|
||||||
|
```
|
||||||
|
[checks]
|
||||||
|
enable_auto_checks_feedback = false
|
||||||
|
```
|
||||||
|
|
||||||
## Configuration options
|
## Configuration options
|
||||||
- `enable_auto_checks_feedback` - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
|
- `enable_auto_checks_feedback` - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
|
||||||
- `excluded_checks_list` - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
|
- `excluded_checks_list` - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
|
||||||
|
@ -5,7 +5,8 @@ It can be invoked manually by commenting on any PR:
|
|||||||
```
|
```
|
||||||
/generate_labels
|
/generate_labels
|
||||||
```
|
```
|
||||||
For example:
|
|
||||||
|
## Example usage
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
## Overview
|
## Overview
|
||||||
The `custom_suggestions` tool scans the PR code changes, and automatically generates custom suggestions for improving the PR code.
|
The `custom_suggestions` tool scans the PR code changes, and automatically generates suggestions for improving the PR code.
|
||||||
It shares similarities with the `improve` tool, but with one main difference: the `custom_suggestions` tool will only propose suggestions that follow specific guidelines defined by the prompt in: `pr_custom_suggestions.prompt` configuration.
|
It shares similarities with the `improve` tool, but with one main difference: the `custom_suggestions` tool will **only propose suggestions that follow specific guidelines defined by the prompt** in: `pr_custom_suggestions.prompt` configuration.
|
||||||
|
|
||||||
The tool can be triggered [automatically](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on a PR.
|
The tool can be triggered [automatically](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on a PR.
|
||||||
|
|
||||||
When commenting, use the following template:
|
When commenting, use the following template:
|
||||||
|
|
||||||
```
|
```
|
||||||
/custom_suggestions --pr_custom_suggestions.prompt="The suggestions should focus only on the following:\n-...\n-...\n-..."
|
/custom_suggestions --pr_custom_suggestions.prompt="
|
||||||
|
The suggestions should focus only on the following:
|
||||||
|
- ...
|
||||||
|
- ...
|
||||||
|
|
||||||
|
"
|
||||||
```
|
```
|
||||||
|
|
||||||
With a [configuration file](../usage-guide/automations_and_usage.md#github-app), use the following template:
|
With a [configuration file](../usage-guide/automations_and_usage.md#github-app), use the following template:
|
||||||
@ -18,17 +23,16 @@ prompt="""\
|
|||||||
The suggestions should focus only on the following:
|
The suggestions should focus only on the following:
|
||||||
-...
|
-...
|
||||||
-...
|
-...
|
||||||
-...
|
|
||||||
"""
|
"""
|
||||||
```
|
```
|
||||||
Using a configuration file is recommended, since it allows to use multi-line instructions.
|
|
||||||
|
|
||||||
Don't forget - with this tool, you are the prompter. Be specific, clear, and concise in the instructions. Specify relevant aspects that you want the model to focus on. \
|
Remember - with this tool, you are the prompter. Be specific, clear, and concise in the instructions. Specify relevant aspects that you want the model to focus on. \
|
||||||
You might benefit from several trial-and-error iterations, until you get the correct prompt for your use case.
|
You might benefit from several trial-and-error iterations, until you get the correct prompt for your use case.
|
||||||
|
|
||||||
## Example usage
|
## Example usage
|
||||||
|
|
||||||
Here is an example of a possible prompt:
|
Here is an example of a possible prompt, defined in the configuration file:
|
||||||
```
|
```
|
||||||
[pr_custom_suggestions]
|
[pr_custom_suggestions]
|
||||||
prompt="""\
|
prompt="""\
|
||||||
@ -39,12 +43,13 @@ The suggestions should focus only on the following:
|
|||||||
"""
|
"""
|
||||||
```
|
```
|
||||||
|
|
||||||
The instructions above are just an example. We want to emphasize that the prompt should be specific and clear, and be tailored to the needs of your project.
|
(The instructions above are just an example. We want to emphasize that the prompt should be specific and clear, and be tailored to the needs of your project)
|
||||||
|
|
||||||
Results obtained with the prompt above:
|
Results obtained with the prompt above:
|
||||||
|
|
||||||
{width=512}
|
[//]: # ({width=512})
|
||||||
→
|
|
||||||
|
[//]: # (→)
|
||||||
{width=768}
|
{width=768}
|
||||||
|
|
||||||
## Configuration options
|
## Configuration options
|
||||||
|
@ -8,7 +8,7 @@ The tool can be triggered automatically every time a new PR is [opened](../usage
|
|||||||
|
|
||||||
## Example usage
|
## Example usage
|
||||||
|
|
||||||
### Manual invocation
|
### Manual triggering
|
||||||
|
|
||||||
Invoke the tool manually by commenting `/describe` on any PR:
|
Invoke the tool manually by commenting `/describe` on any PR:
|
||||||
|
|
||||||
@ -18,12 +18,12 @@ After ~30 seconds, the tool will generate a description for the PR:
|
|||||||
|
|
||||||
{width=512}
|
{width=512}
|
||||||
|
|
||||||
If you want to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L46), add the relevant ones to the command:
|
If you want to edit [configurations](#configuration-options), add the relevant ones to the command:
|
||||||
```
|
```
|
||||||
/describe --pr_description.some_config1=... --pr_description.some_config2=...
|
/describe --pr_description.some_config1=... --pr_description.some_config2=...
|
||||||
```
|
```
|
||||||
|
|
||||||
### Automatic invocation
|
### Automatic triggering
|
||||||
|
|
||||||
To run the `describe` automatically when a PR is opened, define in a [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/#wiki-configuration-file):
|
To run the `describe` automatically when a PR is opened, define in a [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/#wiki-configuration-file):
|
||||||
```
|
```
|
||||||
@ -36,11 +36,10 @@ pr_commands = [
|
|||||||
[pr_description]
|
[pr_description]
|
||||||
publish_labels = ...
|
publish_labels = ...
|
||||||
...
|
...
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- The `pr_commands` lists commands that will be executed on every PR.
|
- The `pr_commands` lists commands that will be executed automatically when a PR is opened.
|
||||||
- The `[pr_description]` section contains the configurations for the `describe` tool you want to edit.
|
- The `[pr_description]` section contains the configurations for the `describe` tool you want to edit (if any).
|
||||||
|
|
||||||
|
|
||||||
## Configuration options
|
## Configuration options
|
||||||
@ -49,7 +48,7 @@ publish_labels = ...
|
|||||||
|
|
||||||
!!! example "Possible configurations"
|
!!! example "Possible configurations"
|
||||||
|
|
||||||
- `disable_publish_labels`: if set to true, the tool will not publish the labels to the PR. Default is false.
|
- `publish_labels`: if set to true, the tool will publish the labels to the PR. Default is true.
|
||||||
|
|
||||||
- `publish_description_as_comment`: if set to true, the tool will publish the description as a comment to the PR. If false, it will overwrite the original description. Default is false.
|
- `publish_description_as_comment`: if set to true, the tool will publish the description as a comment to the PR. If false, it will overwrite the original description. Default is false.
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ publish_labels = ...
|
|||||||
|
|
||||||
- `add_original_user_description`: if set to true, the tool will add the original user description to the generated description. Default is true.
|
- `add_original_user_description`: if set to true, the tool will add the original user description to the generated description. Default is true.
|
||||||
|
|
||||||
- `generate_ai_title`: if set to true, the tool will automatically generate a title for the PR. If false, it will keep the original title. Default is false.
|
- `generate_ai_title`: if set to true, the tool will also generate an AI title for the PR. Default is false.
|
||||||
|
|
||||||
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
|
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
|
||||||
|
|
||||||
@ -65,7 +64,7 @@ publish_labels = ...
|
|||||||
|
|
||||||
- `enable_pr_type`: if set to false, it will not show the `PR type` as a text value in the description content. Default is true.
|
- `enable_pr_type`: if set to false, it will not show the `PR type` as a text value in the description content. Default is true.
|
||||||
|
|
||||||
- `disable_final_update_message`: if set to true, the tool will skip adding a comment message [`PR Description updated to latest commit...`](https://github.com/Codium-ai/pr-agent/pull/499#issuecomment-1837412176) after finishing calling `/describe`. Default is false.
|
- `final_update_message`: if set to true, it will add a comment message [`PR Description updated to latest commit...`](https://github.com/Codium-ai/pr-agent/pull/499#issuecomment-1837412176) after finishing calling `/describe`. Default is true.
|
||||||
|
|
||||||
- `enable_semantic_files_types`: if set to true, "Changes walkthrough" section will be generated. Default is true.
|
- `enable_semantic_files_types`: if set to true, "Changes walkthrough" section will be generated. Default is true.
|
||||||
- `collapsible_file_list`: if set to true, the file list in the "Changes walkthrough" section will be collapsible. If set to "adaptive", the file list will be collapsible only if there are more than 8 files. Default is "adaptive".
|
- `collapsible_file_list`: if set to true, the file list in the "Changes walkthrough" section will be collapsible. If set to "adaptive", the file list will be collapsible only if there are more than 8 files. Default is "adaptive".
|
||||||
@ -169,25 +168,18 @@ The description should be comprehensive and detailed, indicating when to add the
|
|||||||
!!! tip "Automation"
|
!!! tip "Automation"
|
||||||
- When you first install PR-Agent app, the [default mode](../usage-guide/automations_and_usage.md#github-app) for the describe tool is:
|
- When you first install PR-Agent app, the [default mode](../usage-guide/automations_and_usage.md#github-app) for the describe tool is:
|
||||||
```
|
```
|
||||||
pr_commands = ["/describe --pr_description.add_original_user_description=true"
|
pr_commands = ["/describe", ...]
|
||||||
"--pr_description.keep_original_user_title=true", ...]
|
|
||||||
```
|
```
|
||||||
meaning the `describe` tool will run automatically on every PR, will keep the original title, and will add the original user description above the generated description.
|
meaning the `describe` tool will run automatically on every PR, with the default configurations.
|
||||||
<br> This default settings aim to strike a good balance between automation and control:
|
|
||||||
- If you want more automation, just give the PR a title, and the tool will auto-write a full description; If you want more control, you can add a detailed description, and the tool will add the complementary description below it.
|
|
||||||
- For maximal automation, you can change the default mode to:
|
|
||||||
```
|
|
||||||
pr_commands = ["/describe --pr_description.add_original_user_description=false"
|
|
||||||
"--pr_description.keep_original_user_title=true", ...]
|
|
||||||
```
|
|
||||||
so the title will be auto-generated as well.
|
|
||||||
- Markers are an alternative way to control the generated description, to give maximal control to the user. If you set:
|
|
||||||
```
|
|
||||||
pr_commands = ["/describe --pr_description.use_description_markers=true", ...]
|
|
||||||
```
|
|
||||||
the tool will replace every marker of the form `pr_agent:marker_name` in the PR description with the relevant content, where `marker_name` is one of the following:
|
|
||||||
* `type`: the PR type.
|
|
||||||
* `summary`: the PR summary.
|
|
||||||
* `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.
|
|
||||||
|
- Markers are an alternative way to control the generated description, to give maximal control to the user. If you set:
|
||||||
|
```
|
||||||
|
pr_commands = ["/describe --pr_description.use_description_markers=true", ...]
|
||||||
|
```
|
||||||
|
the tool will replace every marker of the form `pr_agent:marker_name` in the PR description with the relevant content, where `marker_name` is one of the following:
|
||||||
|
* `type`: the PR type.
|
||||||
|
* `summary`: the PR summary.
|
||||||
|
* `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.
|
||||||
|
@ -5,14 +5,24 @@ It can be invoked manually by commenting on any PR:
|
|||||||
```
|
```
|
||||||
/add_docs
|
/add_docs
|
||||||
```
|
```
|
||||||
For example:
|
|
||||||
|
## Example usage
|
||||||
|
|
||||||
|
Invoke the tool manually by commenting `/add_docs` on any PR:
|
||||||
|
|
||||||
{width=768}
|
{width=768}
|
||||||
|
|
||||||
|
The tool will generate documentation for all the components that changed in the PR:
|
||||||
|
|
||||||
{width=768}
|
{width=768}
|
||||||
|
|
||||||
{width=768}
|
{width=768}
|
||||||
|
|
||||||
|
You can state a name of a specific component in the PR to get documentation only for that component:
|
||||||
|
```
|
||||||
|
/add_docs component_name
|
||||||
|
```
|
||||||
|
|
||||||
## Configuration options
|
## Configuration options
|
||||||
- `docs_style`: The exact style of the documentation (for python docstring). you can choose between: `google`, `numpy`, `sphinx`, `restructuredtext`, `plain`. Default is `sphinx`.
|
- `docs_style`: The exact style of the documentation (for python docstring). you can choose between: `google`, `numpy`, `sphinx`, `restructuredtext`, `plain`. Default is `sphinx`.
|
||||||
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
|
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
|
||||||
@ -20,5 +30,4 @@ For example:
|
|||||||
**Notes**
|
**Notes**
|
||||||
|
|
||||||
- Language that are currently fully supported: Python, Java, C++, JavaScript, TypeScript, C#.
|
- Language that are currently fully supported: Python, Java, C++, JavaScript, TypeScript, C#.
|
||||||
- For languages that are not fully supported, the tool will suggest documentation only for new components in the PR.
|
- This tool can also be triggered interactively by using the [`analyze`](./analyze.md) tool.
|
||||||
- A previous version of the tool, that offered support only for new components, was deprecated.
|
|
@ -5,21 +5,70 @@ The tool can be triggered automatically every time a new PR is [opened](../usage
|
|||||||
/improve
|
/improve
|
||||||
```
|
```
|
||||||
|
|
||||||
### Summarized vs committable code suggestions
|
## Example usage
|
||||||
|
|
||||||
The code suggestions can be presented as a single comment (via `pr_code_suggestions.summarize=true`):
|
### Manual triggering
|
||||||
|
|
||||||
|
Invoke the tool manually by commenting `/improve` on any PR. The code suggestions by default are presented as a single comment:
|
||||||
|
|
||||||
{width=512}
|
{width=512}
|
||||||
|
|
||||||
Or as a separate commitable code comment for each suggestion:
|
To edit [configurations](#configuration-options) related to the improve tool, use the following template:
|
||||||
|
```
|
||||||
|
/improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
|
||||||
|
```
|
||||||
|
|
||||||
{width=512}
|
For example, you can choose to present the suggestions as commitable code comments, by running the following command:
|
||||||
|
```
|
||||||
|
/improve --pr_code_suggestions.commitable_code_suggestions=true
|
||||||
|
```
|
||||||
|
|
||||||
|
{width=512}
|
||||||
|
|
||||||
|
|
||||||
Note that a single comment has a significantly smaller PR footprint. We recommend this mode for most cases.
|
Note that a single comment has a significantly smaller PR footprint. We recommend this mode for most cases.
|
||||||
Also note that collapsible are not supported in _Bitbucket_. Hence, the suggestions are presented there as code comments.
|
Also note that collapsible are not supported in _Bitbucket_. Hence, the suggestions are presented there as code comments.
|
||||||
|
|
||||||
### Extended mode
|
### Automatic triggering
|
||||||
|
|
||||||
|
To run the `improve` automatically when a PR is opened, define in a [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/#wiki-configuration-file):
|
||||||
|
```
|
||||||
|
[github_app]
|
||||||
|
pr_commands = [
|
||||||
|
"/improve",
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
[pr_code_suggestions]
|
||||||
|
num_code_suggestions = ...
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
- The `pr_commands` lists commands that will be executed automatically when a PR is opened.
|
||||||
|
- The `[pr_code_suggestions]` section contains the configurations for the `improve` tool you want to edit (if any)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Configuration options
|
||||||
|
|
||||||
|
!!! example "General options"
|
||||||
|
|
||||||
|
- `num_code_suggestions`: number of code suggestions provided by the 'improve' tool. Default is 4 for CLI, 0 for auto tools.
|
||||||
|
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
|
||||||
|
- `rank_suggestions`: if set to true, the tool will rank the suggestions, based on importance. Default is false.
|
||||||
|
- `commitable_code_suggestions`: if set to true, the tool will display the suggestions as commitable code comments. Default is false.
|
||||||
|
- `persistent_comment`: if set to true, the improve comment will be persistent, meaning that every new improve request will edit the previous one. Default is false.
|
||||||
|
- `enable_help_text`: if set to true, the tool will display a help text in the comment. Default is true.
|
||||||
|
|
||||||
|
!!! example "params for '/improve --extended' mode"
|
||||||
|
|
||||||
|
- `auto_extended_mode`: enable extended mode automatically (no need for the `--extended` option). Default is true.
|
||||||
|
- `num_code_suggestions_per_chunk`: number of code suggestions provided by the 'improve' tool, per chunk. Default is 5.
|
||||||
|
- `rank_extended_suggestions`: if set to true, the tool will rank the suggestions, based on importance. Default is true.
|
||||||
|
- `max_number_of_calls`: maximum number of chunks. Default is 5.
|
||||||
|
- `final_clip_factor`: factor to remove suggestions with low confidence. Default is 0.9.;
|
||||||
|
|
||||||
|
## Extended mode
|
||||||
|
|
||||||
An extended mode, which does not involve PR Compression and provides more comprehensive suggestions, can be invoked by commenting on any PR:
|
An extended mode, which does not involve PR Compression and provides more comprehensive suggestions, can be invoked by commenting on any PR:
|
||||||
```
|
```
|
||||||
@ -36,29 +85,6 @@ auto_extended_mode=true
|
|||||||
Note that the extended mode divides the PR code changes into chunks, up to the token limits, where each chunk is handled separately (might use multiple calls to GPT-4 for large PRs).
|
Note that the extended mode divides the PR code changes into chunks, up to the token limits, where each chunk is handled separately (might use multiple calls to GPT-4 for large PRs).
|
||||||
Hence, the total number of suggestions is proportional to the number of chunks, i.e., the size of the PR.
|
Hence, the total number of suggestions is proportional to the number of chunks, i.e., the size of the PR.
|
||||||
|
|
||||||
### Configuration options
|
|
||||||
|
|
||||||
To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L66) related to the improve tool (`pr_code_suggestions` section), use the following template:
|
|
||||||
```
|
|
||||||
/improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
|
|
||||||
```
|
|
||||||
|
|
||||||
!!! example "General options"
|
|
||||||
|
|
||||||
- `num_code_suggestions`: number of code suggestions provided by the 'improve' tool. Default is 4 for CLI, 0 for auto tools.
|
|
||||||
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
|
|
||||||
- `rank_suggestions`: if set to true, the tool will rank the suggestions, based on importance. Default is false.
|
|
||||||
- `summarize`: if set to true, the tool will display the suggestions in a single comment. Default is true.
|
|
||||||
- `persistent_comment`: if set to true, the improve comment will be persistent, meaning that every new improve request will edit the previous one. Default is false.
|
|
||||||
- `enable_help_text`: if set to true, the tool will display a help text in the comment. Default is true.
|
|
||||||
|
|
||||||
!!! example "params for '/improve --extended' mode"
|
|
||||||
|
|
||||||
- `auto_extended_mode`: enable extended mode automatically (no need for the `--extended` option). Default is true.
|
|
||||||
- `num_code_suggestions_per_chunk`: number of code suggestions provided by the 'improve' tool, per chunk. Default is 5.
|
|
||||||
- `rank_extended_suggestions`: if set to true, the tool will rank the suggestions, based on importance. Default is true.
|
|
||||||
- `max_number_of_calls`: maximum number of chunks. Default is 5.
|
|
||||||
- `final_clip_factor`: factor to remove suggestions with low confidence. Default is 0.9.
|
|
||||||
|
|
||||||
|
|
||||||
## Usage Tips
|
## Usage Tips
|
||||||
|
@ -8,14 +8,19 @@ it can be invoked manually by commenting on any PR:
|
|||||||
To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool.
|
To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool.
|
||||||
|
|
||||||
|
|
||||||
Example result:
|
## Example usage
|
||||||
|
|
||||||
|
Invoke the tool manually by commenting `/improve_component` on any PR:
|
||||||
|
|
||||||
{width=768}
|
{width=768}
|
||||||
|
|
||||||
|
The tool will generate code suggestions for the selected component (if no component is stated, it will generate code suggestions for the largest component):
|
||||||
|
|
||||||
{width=768}
|
{width=768}
|
||||||
|
|
||||||
**Notes**
|
**Notes**
|
||||||
- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript, C#.
|
- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript, C#.
|
||||||
|
- This tool can also be triggered interactively by using the [`analyze`](./analyze.md) tool.
|
||||||
|
|
||||||
## Configuration options
|
## Configuration options
|
||||||
- `num_code_suggestions`: number of code suggestions to provide. Default is 4
|
- `num_code_suggestions`: number of code suggestions to provide. Default is 4
|
||||||
|
@ -4,55 +4,80 @@ The tool can be triggered automatically every time a new PR is [opened](../usage
|
|||||||
```
|
```
|
||||||
/review
|
/review
|
||||||
```
|
```
|
||||||
For example:
|
|
||||||
|
## Example usage
|
||||||
|
|
||||||
|
### Manual triggering
|
||||||
|
|
||||||
|
Invoke the tool manually by commenting `/review` on any PR:
|
||||||
|
|
||||||
{width=512}
|
{width=512}
|
||||||
|
|
||||||
|
After ~30 seconds, the tool will generate a review for the PR:
|
||||||
|
|
||||||
{width=512}
|
{width=512}
|
||||||
|
|
||||||
|
If you want to edit [configurations](#configuration-options), add the relevant ones to the command:
|
||||||
|
```
|
||||||
|
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
|
||||||
|
```
|
||||||
|
|
||||||
|
### Automatic triggering
|
||||||
|
|
||||||
|
To run the `review` automatically when a PR is opened, define in a [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/#wiki-configuration-file):
|
||||||
|
```
|
||||||
|
[github_app]
|
||||||
|
pr_commands = [
|
||||||
|
"/review",
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
[pr_reviewer]
|
||||||
|
num_code_suggestions = ...
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
- The `pr_commands` lists commands that will be executed automatically when a PR is opened.
|
||||||
|
- The `[pr_reviewer]` section contains the configurations for the `review` tool you want to edit (if any).
|
||||||
|
|
||||||
|
|
||||||
## Configuration options
|
## Configuration options
|
||||||
|
|
||||||
### General configurations
|
### General configurations
|
||||||
|
|
||||||
To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L19) related to the review tool (`pr_reviewer` section), use the following template:
|
|
||||||
```
|
|
||||||
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
|
|
||||||
```
|
|
||||||
|
|
||||||
!!! example "General options"
|
!!! example "General options"
|
||||||
- `num_code_suggestions`: number of code suggestions provided by the 'review' tool. For manual comments, default is 4. For [PR-Agent app](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L142) auto tools, default is 0, meaning no code suggestions will be provided by the review tool, unless you manually edit `pr_commands`.
|
- <a name="num_code_suggestions"></a>`num_code_suggestions`: number of code suggestions provided by the 'review' tool. For manual comments, default is 4. For [PR-Agent app](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L142) auto tools, default is 0, meaning no code suggestions will be provided by the review tool, unless you manually edit `pr_commands`.
|
||||||
- `inline_code_comments`: if set to true, the tool will publish the code suggestions as comments on the code diff. Default is false.
|
- <a name="inline_code_comments"></a>`inline_code_comments`: if set to true, the tool will publish the code suggestions as comments on the code diff. Default is false.
|
||||||
- `persistent_comment`: if set to true, the review comment will be persistent, meaning that every new review request will edit the previous one. Default is true.
|
- <a name="persistent_comment"></a>`persistent_comment`: if set to true, the review comment will be persistent, meaning that every new review request will edit the previous one. Default is true.
|
||||||
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
|
- <a name="extra_instructions"></a>`extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
|
||||||
- `enable_help_text`: if set to true, the tool will display a help text in the comment. Default is true.
|
- <a name="enable_help_text"></a>`enable_help_text`: if set to true, the tool will display a help text in the comment. Default is true.
|
||||||
|
|
||||||
!!! example "Enable\\disable sub-sections"
|
!!! example "Enable\\disable sub-sections"
|
||||||
You can enable or disable specific sub-sections of the review tool:
|
You can enable or disable specific sub-sections of the review tool:
|
||||||
|
|
||||||
- `require_score_review`: if set to true, the tool will add a section that scores the PR. Default is false.
|
- <a name="require_score_review"></a>`require_score_review`: if set to true, the tool will add a section that scores the PR. Default is false.
|
||||||
- `require_tests_review`: if set to true, the tool will add a section that checks if the PR contains tests. Default is true.
|
- <a name="require_tests_review"></a>`require_tests_review`: if set to true, the tool will add a section that checks if the PR contains tests. Default is true.
|
||||||
- `require_estimate_effort_to_review`: if set to true, the tool will add a section that estimates the effort needed to review the PR. Default is true.
|
- <a name="require_estimate_effort_to_review"></a>`require_estimate_effort_to_review`: if set to true, the tool will add a section that estimates the effort needed to review the PR. Default is true.
|
||||||
- `require_can_be_split_review`: if set to true, the tool will add a section that checks if the PR contains several themes, and can be split into smaller PRs. Default is false.
|
- <a name="require_can_be_split_review"></a>`require_can_be_split_review`: if set to true, the tool will add a section that checks if the PR contains several themes, and can be split into smaller PRs. Default is false.
|
||||||
|
|
||||||
!!! example "SOC2 ticket compliance 💎"
|
!!! example "SOC2 ticket compliance 💎"
|
||||||
|
|
||||||
This sub-tool checks if the PR description properly contains a ticket to a project management system (e.g., Jira, Asana, Trello, etc.), as required by SOC2 compliance. If not, it will add a label to the PR: "Missing SOC2 ticket".
|
This sub-tool checks if the PR description properly contains a ticket to a project management system (e.g., Jira, Asana, Trello, etc.), as required by SOC2 compliance. If not, it will add a label to the PR: "Missing SOC2 ticket".
|
||||||
|
|
||||||
- `require_soc2_ticket`: If set to true, the SOC2 ticket checker sub-tool will be enabled. Default is false.
|
- <a name="require_soc2_ticket"></a>`require_soc2_ticket`: If set to true, the SOC2 ticket checker sub-tool will be enabled. Default is false.
|
||||||
- `soc2_ticket_prompt`: The prompt for the SOC2 ticket review. Default is: `Does the PR description include a link to ticket in a project management system (e.g., Jira, Asana, Trello, etc.) ?`. Edit this field if your compliance requirements are different.
|
- <a name="soc2_ticket_prompt"></a>`soc2_ticket_prompt`: The prompt for the SOC2 ticket review. Default is: `Does the PR description include a link to ticket in a project management system (e.g., Jira, Asana, Trello, etc.) ?`. Edit this field if your compliance requirements are different.
|
||||||
|
|
||||||
!!! example "Adding PR labels"
|
!!! example "Adding PR labels"
|
||||||
You can enable the tool to add specific labels to the PR:
|
You can enable the tool to add specific labels to the PR:
|
||||||
|
|
||||||
- `enable_review_labels_security`: if set to true, the tool will publish a 'possible security issue' label if it detects a security issue. Default is true.
|
- <a name="enable_review_labels_security"></a>`enable_review_labels_security`: if set to true, the tool will publish a 'possible security issue' label if it detects a security issue. Default is true.
|
||||||
- `enable_review_labels_effort`: if set to true, the tool will publish a 'Review effort [1-5]: x' label. Default is true.
|
- <a name="enable_review_labels_effort"></a>`enable_review_labels_effort`: if set to true, the tool will publish a 'Review effort [1-5]: x' label. Default is true.
|
||||||
|
|
||||||
!!! example "Auto-approval"
|
!!! example "Auto-approval"
|
||||||
The review tool can approve a PR when a specific comment, `/review auto_approve` is invoked.
|
The review tool can approve a PR when a specific comment, `/review auto_approve` is invoked.
|
||||||
|
|
||||||
- `enable_auto_approval`: if set to true, the tool will approve the PR when invoked with the 'auto_approve' command. Default is false. This flag can be changed only from configuration file.
|
- <a name="enable_auto_approval"></a>`enable_auto_approval`: if set to true, the tool will approve the PR when invoked with the 'auto_approve' command. Default is false. This flag can be changed only from configuration file.
|
||||||
- `maximal_review_effort`: maximal effort level for auto-approval. If the PR's estimated review effort is above this threshold, the auto-approval will not run. Default is 5.
|
- <a name="maximal_review_effort"></a>`maximal_review_effort`: maximal effort level for auto-approval. If the PR's estimated review effort is above this threshold, the auto-approval will not run. Default is 5.
|
||||||
|
|
||||||
### Incremental Mode
|
### Incremental Mode
|
||||||
Incremental review only considers changes since the last PR-Agent review. This can be useful when working on the PR in an iterative manner, and you want to focus on the changes since the last review instead of reviewing the entire PR again.
|
Incremental review only considers changes since the last PR-Agent review. This can be useful when working on the PR in an iterative manner, and you want to focus on the changes since the last review instead of reviewing the entire PR again.
|
||||||
|
@ -4,7 +4,9 @@ It can be invoked manually by commenting on any PR:
|
|||||||
```
|
```
|
||||||
/similar_issue
|
/similar_issue
|
||||||
```
|
```
|
||||||
For example:
|
|
||||||
|
|
||||||
|
## Example usage
|
||||||
|
|
||||||
{width=768}
|
{width=768}
|
||||||
|
|
||||||
|
@ -7,17 +7,23 @@ It can be invoked manually by commenting on any PR:
|
|||||||
where 'component_name' is the name of a specific component in the PR.
|
where 'component_name' is the name of a specific component in the PR.
|
||||||
To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool.
|
To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool.
|
||||||
|
|
||||||
|
## Example usage
|
||||||
|
|
||||||
An example [result](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment-1913679429):
|
Invoke the tool manually by commenting `/test` on any PR:
|
||||||
|
|
||||||
{width=704}
|
{width=704}
|
||||||
|
|
||||||
|
The tool will generate tests for the selected component (if no component is stated, it will generate tests for largest component):
|
||||||
|
|
||||||
{width=768}
|
{width=768}
|
||||||
|
|
||||||
{width=768}
|
{width=768}
|
||||||
|
|
||||||
|
(Example taken from [here](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment-1913679429)):
|
||||||
|
|
||||||
**Notes**
|
**Notes**
|
||||||
- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript, C#.
|
- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript, C#.
|
||||||
|
- This tool can also be triggered interactively by using the [`analyze`](./analyze.md) tool.
|
||||||
|
|
||||||
|
|
||||||
## Configuration options
|
## Configuration options
|
||||||
|
@ -4,7 +4,8 @@ It can be invoked manually by commenting on any PR:
|
|||||||
```
|
```
|
||||||
/update_changelog
|
/update_changelog
|
||||||
```
|
```
|
||||||
For example:
|
|
||||||
|
## Example usage
|
||||||
|
|
||||||
{width=768}
|
{width=768}
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ For example:
|
|||||||
|
|
||||||
## Configuration options
|
## Configuration options
|
||||||
|
|
||||||
Under the section 'pr_update_changelog', the [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L50) contains options to customize the 'update changelog' tool:
|
Under the section `pr_update_changelog`, the [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L50) contains options to customize the 'update changelog' tool:
|
||||||
|
|
||||||
- `push_changelog_changes`: whether to push the changes to CHANGELOG.md, or just print them. Default is false (print only).
|
- `push_changelog_changes`: whether to push the changes to CHANGELOG.md, or just print them. Default is false (print only).
|
||||||
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...
|
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...
|
@ -125,6 +125,19 @@ key = ...
|
|||||||
|
|
||||||
Also, review the [AiHandler](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/ai_handler.py) file for instructions on how to set keys for other models.
|
Also, review the [AiHandler](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/ai_handler.py) file for instructions on how to set keys for other models.
|
||||||
|
|
||||||
|
### Groq
|
||||||
|
|
||||||
|
To use Llama3 model with Groq, for example, set:
|
||||||
|
```
|
||||||
|
[config] # in configuration.toml
|
||||||
|
model = "llama3-70b-8192"
|
||||||
|
model_turbo = "llama3-70b-8192"
|
||||||
|
fallback_models = ["groq/llama3-70b-8192"]
|
||||||
|
[groq] # in .secrets.toml
|
||||||
|
key = ... # your Groq api key
|
||||||
|
```
|
||||||
|
(you can obtain a Groq key from [here](https://console.groq.com/keys))
|
||||||
|
|
||||||
### Vertex AI
|
### Vertex AI
|
||||||
|
|
||||||
To use Google's Vertex AI platform and its associated models (chat-bison/codechat-bison) set:
|
To use Google's Vertex AI platform and its associated models (chat-bison/codechat-bison) set:
|
||||||
|
@ -62,22 +62,21 @@ The configuration parameter `pr_commands` defines the list of tools that will be
|
|||||||
```
|
```
|
||||||
[github_app]
|
[github_app]
|
||||||
pr_commands = [
|
pr_commands = [
|
||||||
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true --pr_description.disable_final_update_message=true",
|
"/describe --pr_description.final_update_message=false",
|
||||||
"/review --pr_reviewer.num_code_suggestions=0",
|
"/review --pr_reviewer.num_code_suggestions=0",
|
||||||
"/improve",
|
"/improve",
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
This means that when a new PR is opened/reopened or marked as ready for review, PR-Agent will run the `describe`, `review` and `improve` tools.
|
This means that when a new PR is opened/reopened or marked as ready for review, PR-Agent will run the `describe`, `review` and `improve` tools.
|
||||||
For the `describe` tool, for example, the `add_original_user_description` and `keep_original_user_title` parameters will be set to true.
|
For the `review` tool, for example, the `num_code_suggestions` parameter will be set to 0.
|
||||||
|
|
||||||
You can override the default tool parameters by using one the three options for a [configuration file](https://codium-ai.github.io/Docs-PR-Agent/usage-guide/#configuration-options): **wiki**, **local**, or **global**.
|
You can override the default tool parameters by using one the three options for a [configuration file](https://codium-ai.github.io/Docs-PR-Agent/usage-guide/#configuration-options): **wiki**, **local**, or **global**.
|
||||||
For example, if your local `.pr_agent.toml` file contains:
|
For example, if your local `.pr_agent.toml` file contains:
|
||||||
```
|
```
|
||||||
[pr_description]
|
[pr_description]
|
||||||
add_original_user_description = false
|
generate_ai_title = true
|
||||||
keep_original_user_title = false
|
|
||||||
```
|
```
|
||||||
When a new PR is opened, PR-Agent will run the `describe` tool with the above parameters.
|
Every time you run the `describe` tool, including automatic runs, the PR title will be generated by the AI.
|
||||||
|
|
||||||
To cancel the automatic run of all the tools, set:
|
To cancel the automatic run of all the tools, set:
|
||||||
```
|
```
|
||||||
@ -102,8 +101,8 @@ The configuration parameter `push_commands` defines the list of tools that will
|
|||||||
[github_app]
|
[github_app]
|
||||||
handle_push_trigger = true
|
handle_push_trigger = true
|
||||||
push_commands = [
|
push_commands = [
|
||||||
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
|
"/describe",
|
||||||
"/review --pr_reviewer.num_code_suggestions=0 --pr_reviewer.disable_final_update_message=true",
|
"/review --pr_reviewer.num_code_suggestions=0 --pr_reviewer.final_update_message=false",
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
This means that when new code is pushed to the PR, the PR-Agent will run the `describe` and `review` tools, with the specified parameters.
|
This means that when new code is pushed to the PR, the PR-Agent will run the `describe` and `review` tools, with the specified parameters.
|
||||||
@ -142,7 +141,7 @@ After setting up a GitLab webhook, to control which commands will run automatica
|
|||||||
```
|
```
|
||||||
[gitlab]
|
[gitlab]
|
||||||
pr_commands = [
|
pr_commands = [
|
||||||
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
|
"/describe",
|
||||||
"/review --pr_reviewer.num_code_suggestions=0",
|
"/review --pr_reviewer.num_code_suggestions=0",
|
||||||
"/improve",
|
"/improve",
|
||||||
]
|
]
|
||||||
@ -170,7 +169,7 @@ Specifically, set the following values:
|
|||||||
[bitbucket_app]
|
[bitbucket_app]
|
||||||
pr_commands = [
|
pr_commands = [
|
||||||
"/review --pr_reviewer.num_code_suggestions=0",
|
"/review --pr_reviewer.num_code_suggestions=0",
|
||||||
"/improve --pr_code_suggestions.summarize=false",
|
"/improve --pr_code_suggestions.commitable_code_suggestions=true",
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -202,7 +201,7 @@ To control which commands will run automatically when a new PR is opened, you ca
|
|||||||
```
|
```
|
||||||
[azure_devops_server]
|
[azure_devops_server]
|
||||||
pr_commands = [
|
pr_commands = [
|
||||||
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
|
"/describe",
|
||||||
"/review --pr_reviewer.num_code_suggestions=0",
|
"/review --pr_reviewer.num_code_suggestions=0",
|
||||||
"/improve",
|
"/improve",
|
||||||
]
|
]
|
||||||
|
@ -23,7 +23,7 @@ An example content:
|
|||||||
|
|
||||||
```
|
```
|
||||||
[pr_description]
|
[pr_description]
|
||||||
keep_original_user_title=false
|
generate_ai_title=true
|
||||||
```
|
```
|
||||||
|
|
||||||
PR-Agent will know to remove the triple-quotes when reading the configuration content.
|
PR-Agent will know to remove the triple-quotes when reading the configuration content.
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
MAX_TOKENS = {
|
MAX_TOKENS = {
|
||||||
'text-embedding-ada-002': 8000,
|
'text-embedding-ada-002': 8000,
|
||||||
'gpt-3.5-turbo': 4000,
|
'gpt-3.5-turbo': 16000,
|
||||||
|
'gpt-3.5-turbo-0125': 16000,
|
||||||
'gpt-3.5-turbo-0613': 4000,
|
'gpt-3.5-turbo-0613': 4000,
|
||||||
'gpt-3.5-turbo-0301': 4000,
|
'gpt-3.5-turbo-1106': 16000,
|
||||||
'gpt-3.5-turbo-16k': 16000,
|
'gpt-3.5-turbo-16k': 16000,
|
||||||
'gpt-3.5-turbo-16k-0613': 16000,
|
'gpt-3.5-turbo-16k-0613': 16000,
|
||||||
'gpt-4': 8000,
|
'gpt-4': 8000,
|
||||||
@ -31,4 +32,6 @@ MAX_TOKENS = {
|
|||||||
'bedrock/anthropic.claude-v2:1': 100000,
|
'bedrock/anthropic.claude-v2:1': 100000,
|
||||||
'bedrock/anthropic.claude-3-sonnet-20240229-v1:0': 100000,
|
'bedrock/anthropic.claude-3-sonnet-20240229-v1:0': 100000,
|
||||||
'bedrock/anthropic.claude-3-haiku-20240307-v1:0': 100000,
|
'bedrock/anthropic.claude-3-haiku-20240307-v1:0': 100000,
|
||||||
|
'groq/llama3-8b-8192': 8192,
|
||||||
|
'groq/llama3-70b-8192': 8192,
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,8 @@ class LiteLLMAIHandler(BaseAiHandler):
|
|||||||
litellm.anthropic_key = get_settings().anthropic.key
|
litellm.anthropic_key = get_settings().anthropic.key
|
||||||
if get_settings().get("COHERE.KEY", None):
|
if get_settings().get("COHERE.KEY", None):
|
||||||
litellm.cohere_key = get_settings().cohere.key
|
litellm.cohere_key = get_settings().cohere.key
|
||||||
if get_settings().get("REPLICATE.KEY", None):
|
if get_settings().get("GROQ.KEY", None):
|
||||||
litellm.replicate_key = get_settings().replicate.key
|
litellm.api_key = get_settings().groq.key
|
||||||
if get_settings().get("REPLICATE.KEY", None):
|
if get_settings().get("REPLICATE.KEY", None):
|
||||||
litellm.replicate_key = get_settings().replicate.key
|
litellm.replicate_key = get_settings().replicate.key
|
||||||
if get_settings().get("HUGGINGFACE.KEY", None):
|
if get_settings().get("HUGGINGFACE.KEY", None):
|
||||||
|
@ -68,11 +68,11 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool = True, increment
|
|||||||
output_data (dict): A dictionary containing data to be converted to markdown format.
|
output_data (dict): A dictionary containing data to be converted to markdown format.
|
||||||
Returns:
|
Returns:
|
||||||
str: The markdown formatted text generated from the input dictionary.
|
str: The markdown formatted text generated from the input dictionary.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
emojis = {
|
emojis = {
|
||||||
"Can be split": "🔀",
|
"Can be split": "🔀",
|
||||||
"Possible issues": "🔍",
|
"Possible issues": "⚡",
|
||||||
"Score": "🏅",
|
"Score": "🏅",
|
||||||
"Relevant tests": "🧪",
|
"Relevant tests": "🧪",
|
||||||
"Focused PR": "✨",
|
"Focused PR": "✨",
|
||||||
@ -83,9 +83,9 @@ def convert_to_markdown(output_data: dict, gfm_supported: bool = True, increment
|
|||||||
}
|
}
|
||||||
markdown_text = ""
|
markdown_text = ""
|
||||||
if not incremental_review:
|
if not incremental_review:
|
||||||
markdown_text += f"## PR Review\n\n"
|
markdown_text += f"## PR Review 🔍\n\n"
|
||||||
else:
|
else:
|
||||||
markdown_text += f"## Incremental PR Review\n\n"
|
markdown_text += f"## Incremental PR Review 🔍 \n\n"
|
||||||
markdown_text += f"⏮️ Review for commits since previous PR-Agent review {incremental_review}.\n\n"
|
markdown_text += f"⏮️ Review for commits since previous PR-Agent review {incremental_review}.\n\n"
|
||||||
if gfm_supported:
|
if gfm_supported:
|
||||||
markdown_text += "<table>\n<tr>\n"
|
markdown_text += "<table>\n<tr>\n"
|
||||||
|
@ -36,6 +36,7 @@ def get_settings():
|
|||||||
try:
|
try:
|
||||||
return context["settings"]
|
return context["settings"]
|
||||||
except Exception:
|
except Exception:
|
||||||
|
print("error")
|
||||||
return global_settings
|
return global_settings
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class GitProvider(ABC):
|
|||||||
|
|
||||||
# if the existing description was generated by the pr-agent, but it doesn't contain a user description,
|
# if the existing description was generated by the pr-agent, but it doesn't contain a user description,
|
||||||
# return nothing (empty string) because it means there is no user description
|
# return nothing (empty string) because it means there is no user description
|
||||||
user_description_header = "## **user description**"
|
user_description_header = "### **user description**"
|
||||||
if user_description_header not in description_lowercase:
|
if user_description_header not in description_lowercase:
|
||||||
get_logger().info(f"Existing description was generated by the pr-agent, but it doesn't contain a user description")
|
get_logger().info(f"Existing description was generated by the pr-agent, but it doesn't contain a user description")
|
||||||
return ""
|
return ""
|
||||||
@ -102,8 +102,8 @@ class GitProvider(ABC):
|
|||||||
return original_user_description
|
return original_user_description
|
||||||
|
|
||||||
def _possible_headers(self):
|
def _possible_headers(self):
|
||||||
return ("## **user description**", "## **pr type**", "## **pr description**", "## **pr labels**", "## **type**", "## **description**",
|
return ("### **user description**", "### **pr type**", "### **pr description**", "### **pr labels**", "### **type**", "### **description**",
|
||||||
"## **labels**", "### 🤖 generated by pr agent")
|
"### **labels**", "### 🤖 generated by pr agent")
|
||||||
|
|
||||||
def _is_generated_by_pr_agent(self, description_lowercase: str) -> bool:
|
def _is_generated_by_pr_agent(self, description_lowercase: str) -> bool:
|
||||||
possible_headers = self._possible_headers()
|
possible_headers = self._possible_headers()
|
||||||
|
@ -229,7 +229,7 @@ class GithubProvider(GitProvider):
|
|||||||
self.publish_comment(pr_comment)
|
self.publish_comment(pr_comment)
|
||||||
|
|
||||||
def publish_comment(self, pr_comment: str, is_temporary: bool = False):
|
def publish_comment(self, pr_comment: str, is_temporary: bool = False):
|
||||||
if is_temporary or not get_settings().config.publish_output_progress:
|
if is_temporary and not get_settings().config.publish_output_progress:
|
||||||
get_logger().debug(f"Skipping publish_comment for temporary comment: {pr_comment}")
|
get_logger().debug(f"Skipping publish_comment for temporary comment: {pr_comment}")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ async def handle_new_pr_opened(body: Dict[str, Any],
|
|||||||
if not (pull_request and api_url):
|
if not (pull_request and api_url):
|
||||||
get_logger().info(f"Invalid PR event: {action=} {api_url=}")
|
get_logger().info(f"Invalid PR event: {action=} {api_url=}")
|
||||||
return {}
|
return {}
|
||||||
if action in get_settings().github_app.handle_pr_actions: # ['opened', 'reopened', 'ready_for_review', 'review_requested']
|
if action in get_settings().github_app.handle_pr_actions: # ['opened', 'reopened', 'ready_for_review']
|
||||||
if get_identity_provider().verify_eligibility("github", sender_id, api_url) is not Eligibility.NOT_ELIGIBLE:
|
if get_identity_provider().verify_eligibility("github", sender_id, api_url) is not Eligibility.NOT_ELIGIBLE:
|
||||||
await _perform_auto_commands_github("pr_commands", agent, body, api_url, log_context)
|
await _perform_auto_commands_github("pr_commands", agent, body, api_url, log_context)
|
||||||
else:
|
else:
|
||||||
|
@ -68,10 +68,9 @@ some_config2=...
|
|||||||
output += """\
|
output += """\
|
||||||
- When you first install the app, the [default mode](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) for the describe tool is:
|
- When you first install the app, the [default mode](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) for the describe tool is:
|
||||||
```
|
```
|
||||||
pr_commands = ["/describe --pr_description.add_original_user_description=true"
|
pr_commands = ["/describe", ...]
|
||||||
"--pr_description.keep_original_user_title=true", ...]
|
|
||||||
```
|
```
|
||||||
meaning the `describe` tool will run automatically on every PR, will keep the original title, and will add the original user description above the generated description.
|
meaning the `describe` tool will run automatically on every PR.
|
||||||
|
|
||||||
- Markers are an alternative way to control the generated description, to give maximal control to the user. If you set:
|
- Markers are an alternative way to control the generated description, to give maximal control to the user. If you set:
|
||||||
```
|
```
|
||||||
@ -180,7 +179,7 @@ You can ask questions about the entire PR, about specific code lines, or about a
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_improve_usage_guide():
|
def get_improve_usage_guide():
|
||||||
output = "**Overview:**\n"
|
output = "**Overview:**\n"
|
||||||
output += "The `improve` tool scans the PR code changes, and automatically generates suggestions for improving the PR code. "
|
output += "The code suggestions tool, named `improve`, scans the PR code changes, and automatically generates code suggestions for improving the PR."
|
||||||
output += "The tool can be triggered [automatically](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on a PR.\n"
|
output += "The tool can be triggered [automatically](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on a PR.\n"
|
||||||
output += """\
|
output += """\
|
||||||
- When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L78) related to the improve tool (`pr_code_suggestions` section), use the following template:
|
- When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L78) related to the improve tool (`pr_code_suggestions` section), use the following template:
|
||||||
|
@ -29,6 +29,9 @@ key = "" # Optional, uncomment if you want to use Cohere. Acquire through https:
|
|||||||
[replicate]
|
[replicate]
|
||||||
key = "" # Optional, uncomment if you want to use Replicate. Acquire through https://replicate.com/
|
key = "" # Optional, uncomment if you want to use Replicate. Acquire through https://replicate.com/
|
||||||
|
|
||||||
|
[groq]
|
||||||
|
key = "" # Acquire through https://console.groq.com/keys
|
||||||
|
|
||||||
[huggingface]
|
[huggingface]
|
||||||
key = "" # Optional, uncomment if you want to use Huggingface Inference API. Acquire through https://huggingface.co/docs/api-inference/quicktour
|
key = "" # Optional, uncomment if you want to use Huggingface Inference API. Acquire through https://huggingface.co/docs/api-inference/quicktour
|
||||||
api_base = "" # the base url for your huggingface inference endpoint
|
api_base = "" # the base url for your huggingface inference endpoint
|
||||||
|
@ -36,7 +36,7 @@ ask_and_reflect=false
|
|||||||
#automatic_review=true
|
#automatic_review=true
|
||||||
persistent_comment=true
|
persistent_comment=true
|
||||||
extra_instructions = ""
|
extra_instructions = ""
|
||||||
disable_final_update_message = false
|
final_update_message = true
|
||||||
# review labels
|
# review labels
|
||||||
enable_review_labels_security=true
|
enable_review_labels_security=true
|
||||||
enable_review_labels_effort=true
|
enable_review_labels_effort=true
|
||||||
@ -44,20 +44,20 @@ enable_review_labels_effort=true
|
|||||||
require_all_thresholds_for_incremental_review=false
|
require_all_thresholds_for_incremental_review=false
|
||||||
minimal_commits_for_incremental_review=0
|
minimal_commits_for_incremental_review=0
|
||||||
minimal_minutes_for_incremental_review=0
|
minimal_minutes_for_incremental_review=0
|
||||||
enable_help_text=true # Determines whether to include help text in the PR review. Enabled by default.
|
enable_help_text=false # Determines whether to include help text in the PR review. Enabled by default.
|
||||||
# auto approval
|
# auto approval
|
||||||
enable_auto_approval=false
|
enable_auto_approval=false
|
||||||
maximal_review_effort=5
|
maximal_review_effort=5
|
||||||
|
|
||||||
|
|
||||||
[pr_description] # /describe #
|
[pr_description] # /describe #
|
||||||
disable_publish_labels=false
|
publish_labels=true
|
||||||
add_original_user_description=true
|
add_original_user_description=true
|
||||||
generate_ai_title=false
|
generate_ai_title=false
|
||||||
use_bullet_points=true
|
use_bullet_points=true
|
||||||
extra_instructions = ""
|
extra_instructions = ""
|
||||||
enable_pr_type=true
|
enable_pr_type=true
|
||||||
disable_final_update_message = false
|
final_update_message = true
|
||||||
enable_help_text=false
|
enable_help_text=false
|
||||||
enable_help_comment=true
|
enable_help_comment=true
|
||||||
# describe as comment
|
# describe as comment
|
||||||
@ -74,16 +74,16 @@ include_generated_by_header=true
|
|||||||
#custom_labels = ['Bug fix', 'Tests', 'Bug fix with tests', 'Enhancement', 'Documentation', 'Other']
|
#custom_labels = ['Bug fix', 'Tests', 'Bug fix with tests', 'Enhancement', 'Documentation', 'Other']
|
||||||
|
|
||||||
[pr_questions] # /ask #
|
[pr_questions] # /ask #
|
||||||
enable_help_text=true
|
enable_help_text=false
|
||||||
|
|
||||||
|
|
||||||
[pr_code_suggestions] # /improve #
|
[pr_code_suggestions] # /improve #
|
||||||
max_context_tokens=8000
|
max_context_tokens=8000
|
||||||
num_code_suggestions=4
|
num_code_suggestions=4
|
||||||
summarize = true
|
commitable_code_suggestions = false
|
||||||
extra_instructions = ""
|
extra_instructions = ""
|
||||||
rank_suggestions = false
|
rank_suggestions = false
|
||||||
enable_help_text=true
|
enable_help_text=false
|
||||||
persistent_comment=false
|
persistent_comment=false
|
||||||
# params for '/improve --extended' mode
|
# params for '/improve --extended' mode
|
||||||
auto_extended_mode=true
|
auto_extended_mode=true
|
||||||
@ -110,7 +110,7 @@ num_tests=3 # number of tests to generate. max 5.
|
|||||||
avoid_mocks=true # if true, the generated tests will prefer to use real objects instead of mocks
|
avoid_mocks=true # if true, the generated tests will prefer to use real objects instead of mocks
|
||||||
file = "" # in case there are several components with the same name, you can specify the relevant file
|
file = "" # in case there are several components with the same name, you can specify the relevant file
|
||||||
class_name = "" # in case there are several methods with the same name in the same file, you can specify the relevant class name
|
class_name = "" # in case there are several methods with the same name in the same file, you can specify the relevant class name
|
||||||
enable_help_text=true
|
enable_help_text=false
|
||||||
|
|
||||||
[pr_improve_component] # /improve_component #
|
[pr_improve_component] # /improve_component #
|
||||||
num_code_suggestions=4
|
num_code_suggestions=4
|
||||||
@ -148,9 +148,9 @@ override_deployment_type = true
|
|||||||
# settings for "pull_request" event
|
# settings for "pull_request" event
|
||||||
handle_pr_actions = ['opened', 'reopened', 'ready_for_review']
|
handle_pr_actions = ['opened', 'reopened', 'ready_for_review']
|
||||||
pr_commands = [
|
pr_commands = [
|
||||||
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
|
"/describe",
|
||||||
"/review --pr_reviewer.num_code_suggestions=0",
|
"/review --pr_reviewer.num_code_suggestions=0",
|
||||||
"/improve --pr_code_suggestions.summarize=true",
|
"/improve",
|
||||||
]
|
]
|
||||||
# settings for "pull_request" event with "synchronize" action - used to detect and handle push triggers for new commits
|
# settings for "pull_request" event with "synchronize" action - used to detect and handle push triggers for new commits
|
||||||
handle_push_trigger = false
|
handle_push_trigger = false
|
||||||
@ -160,7 +160,7 @@ push_trigger_wait_for_initial_review = true
|
|||||||
push_trigger_pending_tasks_backlog = true
|
push_trigger_pending_tasks_backlog = true
|
||||||
push_trigger_pending_tasks_ttl = 300
|
push_trigger_pending_tasks_ttl = 300
|
||||||
push_commands = [
|
push_commands = [
|
||||||
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
|
"/describe",
|
||||||
"/review --pr_reviewer.num_code_suggestions=0",
|
"/review --pr_reviewer.num_code_suggestions=0",
|
||||||
]
|
]
|
||||||
ignore_pr_title = []
|
ignore_pr_title = []
|
||||||
@ -169,15 +169,15 @@ ignore_bot_pr = true
|
|||||||
[gitlab]
|
[gitlab]
|
||||||
url = "https://gitlab.com" # URL to the gitlab service
|
url = "https://gitlab.com" # URL to the gitlab service
|
||||||
pr_commands = [
|
pr_commands = [
|
||||||
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
|
"/describe",
|
||||||
"/review --pr_reviewer.num_code_suggestions=0",
|
"/review --pr_reviewer.num_code_suggestions=0",
|
||||||
"/improve --pr_code_suggestions.summarize=true",
|
"/improve",
|
||||||
]
|
]
|
||||||
|
|
||||||
[bitbucket_app]
|
[bitbucket_app]
|
||||||
pr_commands = [
|
pr_commands = [
|
||||||
"/review --pr_reviewer.num_code_suggestions=0",
|
"/review --pr_reviewer.num_code_suggestions=0",
|
||||||
"/improve --pr_code_suggestions.summarize=false",
|
"/improve --pr_code_suggestions.commitable_code_suggestions=true",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class CodeSuggestion(BaseModel):
|
|||||||
relevant_file: str = Field(description="the relevant file full path")
|
relevant_file: str = Field(description="the relevant file full path")
|
||||||
language: str = Field(description="the code language of the relevant file")
|
language: str = Field(description="the code language of the relevant file")
|
||||||
suggestion_content: str = Field(description="an actionable suggestion for meaningfully improving the new code introduced in the PR")
|
suggestion_content: str = Field(description="an actionable suggestion for meaningfully improving the new code introduced in the PR")
|
||||||
{%- if summarize_mode %}
|
{%- if not commitable_code_suggestions_mode %}
|
||||||
existing_code: str = Field(description="a short code snippet from a '__new hunk__' section to illustrate the relevant existing code. Don't show the line numbers.")
|
existing_code: str = Field(description="a short code snippet from a '__new hunk__' section to illustrate the relevant existing code. Don't show the line numbers.")
|
||||||
improved_code: str = Field(description="a short code snippet to illustrate the improved code, after applying the suggestion.")
|
improved_code: str = Field(description="a short code snippet to illustrate the improved code, after applying the suggestion.")
|
||||||
one_sentence_summary:str = Field(description="a short summary of the suggestion action, in a single sentence. Focus on the 'what'. Be general, and avoid method or variable names.")
|
one_sentence_summary:str = Field(description="a short summary of the suggestion action, in a single sentence. Focus on the 'what'. Be general, and avoid method or variable names.")
|
||||||
@ -80,7 +80,7 @@ code_suggestions:
|
|||||||
python
|
python
|
||||||
suggestion_content: |
|
suggestion_content: |
|
||||||
...
|
...
|
||||||
{%- if summarize_mode %}
|
{%- if not commitable_code_suggestions_mode %}
|
||||||
existing_code: |
|
existing_code: |
|
||||||
...
|
...
|
||||||
improved_code: |
|
improved_code: |
|
||||||
|
@ -57,7 +57,7 @@ class PRCodeSuggestions:
|
|||||||
"language": self.main_language,
|
"language": self.main_language,
|
||||||
"diff": "", # empty diff for initial calculation
|
"diff": "", # empty diff for initial calculation
|
||||||
"num_code_suggestions": num_code_suggestions,
|
"num_code_suggestions": num_code_suggestions,
|
||||||
"summarize_mode": get_settings().pr_code_suggestions.summarize,
|
"commitable_code_suggestions_mode": get_settings().pr_code_suggestions.commitable_code_suggestions,
|
||||||
"extra_instructions": get_settings().pr_code_suggestions.extra_instructions,
|
"extra_instructions": get_settings().pr_code_suggestions.extra_instructions,
|
||||||
"commit_messages_str": self.git_provider.get_commit_messages(),
|
"commit_messages_str": self.git_provider.get_commit_messages(),
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ class PRCodeSuggestions:
|
|||||||
|
|
||||||
if (not data) or (not 'code_suggestions' in data) or (not data['code_suggestions']):
|
if (not data) or (not 'code_suggestions' in data) or (not data['code_suggestions']):
|
||||||
get_logger().error('No code suggestions found for PR.')
|
get_logger().error('No code suggestions found for PR.')
|
||||||
pr_body = "## PR Code Suggestions\n\nNo code suggestions found for PR."
|
pr_body = "## PR Code Suggestions ✨\n\nNo code suggestions found for PR."
|
||||||
get_logger().debug(f"PR output", artifact=pr_body)
|
get_logger().debug(f"PR output", artifact=pr_body)
|
||||||
if self.progress_response:
|
if self.progress_response:
|
||||||
self.git_provider.edit_comment(self.progress_response, body=pr_body)
|
self.git_provider.edit_comment(self.progress_response, body=pr_body)
|
||||||
@ -105,7 +105,7 @@ class PRCodeSuggestions:
|
|||||||
|
|
||||||
if get_settings().config.publish_output:
|
if get_settings().config.publish_output:
|
||||||
self.git_provider.remove_initial_comment()
|
self.git_provider.remove_initial_comment()
|
||||||
if get_settings().pr_code_suggestions.summarize and self.git_provider.is_supported("gfm_markdown"):
|
if (not get_settings().pr_code_suggestions.commitable_code_suggestions) and self.git_provider.is_supported("gfm_markdown"):
|
||||||
|
|
||||||
# generate summarized suggestions
|
# generate summarized suggestions
|
||||||
pr_body = self.generate_summarized_suggestions(data)
|
pr_body = self.generate_summarized_suggestions(data)
|
||||||
@ -113,14 +113,14 @@ class PRCodeSuggestions:
|
|||||||
|
|
||||||
# add usage guide
|
# add usage guide
|
||||||
if get_settings().pr_code_suggestions.enable_help_text:
|
if get_settings().pr_code_suggestions.enable_help_text:
|
||||||
pr_body += "<hr>\n\n<details> <summary><strong>✨ Improve tool usage guide:</strong></summary><hr> \n\n"
|
pr_body += "<hr>\n\n<details> <summary><strong>💡 Tool usage guide:</strong></summary><hr> \n\n"
|
||||||
pr_body += HelpMessage.get_improve_usage_guide()
|
pr_body += HelpMessage.get_improve_usage_guide()
|
||||||
pr_body += "\n</details>\n"
|
pr_body += "\n</details>\n"
|
||||||
|
|
||||||
if get_settings().pr_code_suggestions.persistent_comment:
|
if get_settings().pr_code_suggestions.persistent_comment:
|
||||||
final_update_message = False
|
final_update_message = False
|
||||||
self.git_provider.publish_persistent_comment(pr_body,
|
self.git_provider.publish_persistent_comment(pr_body,
|
||||||
initial_header="## PR Code Suggestions",
|
initial_header="## PR Code Suggestions ✨",
|
||||||
update_header=True,
|
update_header=True,
|
||||||
name="suggestions",
|
name="suggestions",
|
||||||
final_update_message=final_update_message, )
|
final_update_message=final_update_message, )
|
||||||
@ -197,7 +197,7 @@ class PRCodeSuggestions:
|
|||||||
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:
|
try:
|
||||||
if get_settings().pr_code_suggestions.summarize:
|
if not get_settings().pr_code_suggestions.commitable_code_suggestions:
|
||||||
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}")
|
||||||
continue
|
continue
|
||||||
@ -213,7 +213,7 @@ class PRCodeSuggestions:
|
|||||||
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)
|
||||||
if get_settings().pr_code_suggestions.summarize:
|
if not get_settings().pr_code_suggestions.commitable_code_suggestions:
|
||||||
one_sentence_summary_list.append(suggestion['one_sentence_summary'])
|
one_sentence_summary_list.append(suggestion['one_sentence_summary'])
|
||||||
suggestion_list.append(suggestion)
|
suggestion_list.append(suggestion)
|
||||||
else:
|
else:
|
||||||
@ -382,7 +382,7 @@ class PRCodeSuggestions:
|
|||||||
|
|
||||||
def generate_summarized_suggestions(self, data: Dict) -> str:
|
def generate_summarized_suggestions(self, data: Dict) -> str:
|
||||||
try:
|
try:
|
||||||
pr_body = "## PR Code Suggestions\n\n"
|
pr_body = "## PR Code Suggestions ✨\n\n"
|
||||||
|
|
||||||
if len(data.get('code_suggestions', [])) == 0:
|
if len(data.get('code_suggestions', [])) == 0:
|
||||||
pr_body += "No suggestions found to improve this PR."
|
pr_body += "No suggestions found to improve this PR."
|
||||||
@ -394,7 +394,7 @@ class PRCodeSuggestions:
|
|||||||
for ext in extensions:
|
for ext in extensions:
|
||||||
extension_to_language[ext] = language
|
extension_to_language[ext] = language
|
||||||
|
|
||||||
pr_body = "## PR Code Suggestions\n\n"
|
pr_body = "## PR Code Suggestions ✨\n\n"
|
||||||
|
|
||||||
pr_body += "<table>"
|
pr_body += "<table>"
|
||||||
header = f"Suggestions"
|
header = f"Suggestions"
|
||||||
|
@ -95,10 +95,7 @@ class PRDescription:
|
|||||||
self.file_label_dict = self._prepare_file_labels()
|
self.file_label_dict = self._prepare_file_labels()
|
||||||
|
|
||||||
pr_labels, pr_file_changes = [], []
|
pr_labels, pr_file_changes = [], []
|
||||||
# backward compatibility support
|
if get_settings().pr_description.publish_labels:
|
||||||
publish_label = get_settings().pr_reviewer.get("publish_labels", True) \
|
|
||||||
and not get_settings().pr_description.disable_publish_labels
|
|
||||||
if publish_label:
|
|
||||||
pr_labels = self._prepare_labels()
|
pr_labels = self._prepare_labels()
|
||||||
|
|
||||||
if get_settings().pr_description.use_description_markers:
|
if get_settings().pr_description.use_description_markers:
|
||||||
@ -116,12 +113,12 @@ class PRDescription:
|
|||||||
pr_body += HelpMessage.get_describe_usage_guide()
|
pr_body += HelpMessage.get_describe_usage_guide()
|
||||||
pr_body += "\n</details>\n"
|
pr_body += "\n</details>\n"
|
||||||
elif get_settings().pr_description.enable_help_comment:
|
elif get_settings().pr_description.enable_help_comment:
|
||||||
pr_body += "\n\n___\n\n> ✨ **PR-Agent usage**:"
|
pr_body += "\n\n___\n\n> 💡 **PR-Agent usage**:"
|
||||||
pr_body += "\n>Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions\n\n"
|
pr_body += "\n>Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions\n\n"
|
||||||
|
|
||||||
if get_settings().config.publish_output:
|
if get_settings().config.publish_output:
|
||||||
# publish labels
|
# publish labels
|
||||||
if publish_label and self.git_provider.is_supported("get_labels"):
|
if get_settings().pr_description.publish_labels and self.git_provider.is_supported("get_labels"):
|
||||||
original_labels = self.git_provider.get_pr_labels(update=True)
|
original_labels = self.git_provider.get_pr_labels(update=True)
|
||||||
get_logger().debug(f"original labels", artifact=original_labels)
|
get_logger().debug(f"original labels", artifact=original_labels)
|
||||||
user_labels = get_user_labels(original_labels)
|
user_labels = get_user_labels(original_labels)
|
||||||
@ -146,10 +143,8 @@ class PRDescription:
|
|||||||
else:
|
else:
|
||||||
self.git_provider.publish_description(pr_title, pr_body)
|
self.git_provider.publish_description(pr_title, pr_body)
|
||||||
|
|
||||||
# publish final update message - with backward compatibility support
|
# publish final update message
|
||||||
publish_update_message = get_settings().pr_reviewer.get("final_update_message", True)\
|
if (get_settings().pr_description.final_update_message):
|
||||||
and not get_settings().pr_description.disable_final_update_message
|
|
||||||
if (publish_update_message):
|
|
||||||
latest_commit_url = self.git_provider.get_latest_commit_url()
|
latest_commit_url = self.git_provider.get_latest_commit_url()
|
||||||
if latest_commit_url:
|
if latest_commit_url:
|
||||||
pr_url = self.git_provider.get_pr_url()
|
pr_url = self.git_provider.get_pr_url()
|
||||||
@ -306,10 +301,7 @@ class PRDescription:
|
|||||||
|
|
||||||
# Remove the 'PR Title' key from the dictionary
|
# Remove the 'PR Title' key from the dictionary
|
||||||
ai_title = self.data.pop('title', self.vars["title"])
|
ai_title = self.data.pop('title', self.vars["title"])
|
||||||
# get config - with backward compatibility
|
if (not get_settings().pr_description.generate_ai_title):
|
||||||
keep_user_title = get_settings().pr_reviewer.get("keep_original_user_title", True) \
|
|
||||||
and not get_settings().pr_description.generate_ai_title
|
|
||||||
if keep_user_title:
|
|
||||||
# Assign the original PR title to the 'title' variable
|
# Assign the original PR title to the 'title' variable
|
||||||
title = self.vars["title"]
|
title = self.vars["title"]
|
||||||
else:
|
else:
|
||||||
@ -325,7 +317,11 @@ class PRDescription:
|
|||||||
value = self.file_label_dict
|
value = self.file_label_dict
|
||||||
else:
|
else:
|
||||||
key_publish = key.rstrip(':').replace("_", " ").capitalize()
|
key_publish = key.rstrip(':').replace("_", " ").capitalize()
|
||||||
pr_body += f"## **{key_publish}**\n"
|
if key_publish== "Type":
|
||||||
|
key_publish = "PR Type"
|
||||||
|
# elif key_publish == "Description":
|
||||||
|
# key_publish = "PR Description"
|
||||||
|
pr_body += f"### **{key_publish}**\n"
|
||||||
if 'walkthrough' in key.lower():
|
if 'walkthrough' in key.lower():
|
||||||
if self.git_provider.is_supported("gfm_markdown"):
|
if self.git_provider.is_supported("gfm_markdown"):
|
||||||
pr_body += "<details> <summary>files:</summary>\n\n"
|
pr_body += "<details> <summary>files:</summary>\n\n"
|
||||||
@ -337,7 +333,7 @@ class PRDescription:
|
|||||||
pr_body += "</details>\n"
|
pr_body += "</details>\n"
|
||||||
elif 'pr_files' in key.lower():
|
elif 'pr_files' in key.lower():
|
||||||
changes_walkthrough, pr_file_changes = self.process_pr_files_prediction(changes_walkthrough, value)
|
changes_walkthrough, pr_file_changes = self.process_pr_files_prediction(changes_walkthrough, value)
|
||||||
changes_walkthrough = f"## **Changes walkthrough**\n{changes_walkthrough}"
|
changes_walkthrough = f"### **Changes walkthrough** 📝\n{changes_walkthrough}"
|
||||||
else:
|
else:
|
||||||
# if the value is a list, join its items by comma
|
# if the value is a list, join its items by comma
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
|
@ -18,8 +18,8 @@ class PRHelpMessage:
|
|||||||
relevant_configs = {'pr_help': dict(get_settings().pr_help),
|
relevant_configs = {'pr_help': dict(get_settings().pr_help),
|
||||||
'config': dict(get_settings().config)}
|
'config': dict(get_settings().config)}
|
||||||
get_logger().debug("Relevant configs", artifacts=relevant_configs)
|
get_logger().debug("Relevant configs", artifacts=relevant_configs)
|
||||||
pr_comment = "## PR Agent Walkthrough\n\n"
|
pr_comment = "## PR Agent Walkthrough 🤖\n\n"
|
||||||
pr_comment += "🤖 Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more."""
|
pr_comment += "Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more."""
|
||||||
pr_comment += "\n\nHere is a list of tools you can use to interact with the PR Agent:\n"
|
pr_comment += "\n\nHere is a list of tools you can use to interact with the PR Agent:\n"
|
||||||
base_path = "https://pr-agent-docs.codium.ai/tools"
|
base_path = "https://pr-agent-docs.codium.ai/tools"
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class PRQuestions:
|
|||||||
get_logger().debug(f"PR output", artifact=pr_comment)
|
get_logger().debug(f"PR output", artifact=pr_comment)
|
||||||
|
|
||||||
if self.git_provider.is_supported("gfm_markdown") and get_settings().pr_questions.enable_help_text:
|
if self.git_provider.is_supported("gfm_markdown") and get_settings().pr_questions.enable_help_text:
|
||||||
pr_comment += "<hr>\n\n<details> <summary><strong>✨ Ask tool usage guide:</strong></summary><hr> \n\n"
|
pr_comment += "<hr>\n\n<details> <summary><strong>💡 Tool usage guide:</strong></summary><hr> \n\n"
|
||||||
pr_comment += HelpMessage.get_ask_usage_guide()
|
pr_comment += HelpMessage.get_ask_usage_guide()
|
||||||
pr_comment += "\n</details>\n"
|
pr_comment += "\n</details>\n"
|
||||||
|
|
||||||
@ -116,6 +116,6 @@ class PRQuestions:
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
def _prepare_pr_answer(self) -> str:
|
def _prepare_pr_answer(self) -> str:
|
||||||
answer_str = f"Question: {self.question_str}\n\n"
|
answer_str = f"### **Ask**❓\n{self.question_str}\n\n"
|
||||||
answer_str += f"Answer:\n{self.prediction.strip()}\n\n"
|
answer_str += f"### **Answer:**\n{self.prediction.strip()}\n\n"
|
||||||
return answer_str
|
return answer_str
|
||||||
|
@ -135,11 +135,9 @@ class PRReviewer:
|
|||||||
if get_settings().config.publish_output:
|
if get_settings().config.publish_output:
|
||||||
# publish the review
|
# publish the review
|
||||||
if get_settings().pr_reviewer.persistent_comment and not self.incremental.is_incremental:
|
if get_settings().pr_reviewer.persistent_comment and not self.incremental.is_incremental:
|
||||||
# get config with backward compatibility
|
final_update_message = get_settings().pr_reviewer.final_update_message
|
||||||
final_update_message = get_settings().pr_reviewer.get("final_update_message", True)\
|
|
||||||
and not get_settings().pr_reviewer.disable_final_update_message
|
|
||||||
self.git_provider.publish_persistent_comment(pr_review,
|
self.git_provider.publish_persistent_comment(pr_review,
|
||||||
initial_header="## PR Review",
|
initial_header="## PR Review 🔍",
|
||||||
update_header=True,
|
update_header=True,
|
||||||
final_update_message=final_update_message, )
|
final_update_message=final_update_message, )
|
||||||
else:
|
else:
|
||||||
@ -236,7 +234,7 @@ class PRReviewer:
|
|||||||
|
|
||||||
# Add help text if gfm_markdown is supported
|
# Add help text if gfm_markdown is supported
|
||||||
if self.git_provider.is_supported("gfm_markdown") and get_settings().pr_reviewer.enable_help_text:
|
if self.git_provider.is_supported("gfm_markdown") and get_settings().pr_reviewer.enable_help_text:
|
||||||
markdown_text += "<hr>\n\n<details> <summary><strong>✨ Review tool usage guide:</strong></summary><hr> \n\n"
|
markdown_text += "<hr>\n\n<details> <summary><strong>💡 Tool usage guide:</strong></summary><hr> \n\n"
|
||||||
markdown_text += HelpMessage.get_review_usage_guide()
|
markdown_text += HelpMessage.get_review_usage_guide()
|
||||||
markdown_text += "\n</details>\n"
|
markdown_text += "\n</details>\n"
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class PRUpdateChangelog:
|
|||||||
if self.commit_changelog:
|
if self.commit_changelog:
|
||||||
self._push_changelog_update(new_file_content, answer)
|
self._push_changelog_update(new_file_content, answer)
|
||||||
else:
|
else:
|
||||||
self.git_provider.publish_comment(f"**Changelog updates:**\n\n{answer}")
|
self.git_provider.publish_comment(f"**Changelog updates:** 🔄\n\n{answer}")
|
||||||
|
|
||||||
async def _prepare_prediction(self, model: str):
|
async def _prepare_prediction(self, model: str):
|
||||||
self.patches_diff = get_pr_diff(self.git_provider, self.token_handler, model)
|
self.patches_diff = get_pr_diff(self.git_provider, self.token_handler, model)
|
||||||
@ -141,7 +141,7 @@ class PRUpdateChangelog:
|
|||||||
self.git_provider.pr.create_review(commit=last_commit_id, comments=[d])
|
self.git_provider.pr.create_review(commit=last_commit_id, comments=[d])
|
||||||
except Exception:
|
except Exception:
|
||||||
# we can't create a review for some reason, let's just publish a comment
|
# we can't create a review for some reason, let's just publish a comment
|
||||||
self.git_provider.publish_comment(f"**Changelog updates:**\n\n{answer}")
|
self.git_provider.publish_comment(f"**Changelog updates: 🔄**\n\n{answer}")
|
||||||
|
|
||||||
def _get_default_changelog(self):
|
def _get_default_changelog(self):
|
||||||
example_changelog = \
|
example_changelog = \
|
||||||
|
@ -52,7 +52,7 @@ class TestConvertToMarkdown:
|
|||||||
'suggestion': "Consider raising an exception or logging a warning when 'pr_url' attribute is not found. This can help in debugging issues related to the absence of 'pr_url' in instances where it's expected. [important]\n",
|
'suggestion': "Consider raising an exception or logging a warning when 'pr_url' attribute is not found. This can help in debugging issues related to the absence of 'pr_url' in instances where it's expected. [important]\n",
|
||||||
'relevant_line': '[return ""](https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199)'}]}
|
'relevant_line': '[return ""](https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199)'}]}
|
||||||
|
|
||||||
expected_output = '## PR Review\n\n<table>\n<tr>\n<tr><td> ⏱️ <strong>Estimated effort to review [1-5]</strong></td><td>\n\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n</td></tr>\n<tr><td> 🧪 <strong>Relevant tests</strong></td><td>\n\nNo\n\n\n</td></tr>\n<tr><td> 🔍 <strong>Possible issues</strong></td><td>\n\nNo\n\n</td></tr>\n<tr><td> 🔒 <strong>Security concerns</strong></td><td>\n\nNo\n\n</td></tr>\n</table>\n\n\n<details><summary> <strong>Code feedback:</strong></summary>\n\n<hr><table><tr><td>relevant file</td><td>pr_agent/git_providers/git_provider.py\n</td></tr><tr><td>suggestion </td><td>\n\n<strong>\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n</strong>\n</td></tr><tr><td>relevant line</td><td><a href=\'https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199\'>return ""</a></td></tr></table><hr>\n\n</details>'
|
expected_output = '## PR Review 🔍\n\n<table>\n<tr>\n<tr><td> ⏱️ <strong>Estimated effort to review [1-5]</strong></td><td>\n\n1, because the changes are minimal and straightforward, focusing on a single functionality addition.\n\n\n</td></tr>\n<tr><td> 🧪 <strong>Relevant tests</strong></td><td>\n\nNo\n\n\n</td></tr>\n<tr><td> ⚡ <strong>Possible issues</strong></td><td>\n\nNo\n\n</td></tr>\n<tr><td> 🔒 <strong>Security concerns</strong></td><td>\n\nNo\n\n</td></tr>\n</table>\n\n\n<details><summary> <strong>Code feedback:</strong></summary>\n\n<hr><table><tr><td>relevant file</td><td>pr_agent/git_providers/git_provider.py\n</td></tr><tr><td>suggestion </td><td>\n\n<strong>\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n</strong>\n</td></tr><tr><td>relevant line</td><td><a href=\'https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199\'>return ""</a></td></tr></table><hr>\n\n</details>'
|
||||||
|
|
||||||
assert convert_to_markdown(input_data).strip() == expected_output.strip()
|
assert convert_to_markdown(input_data).strip() == expected_output.strip()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user