Files
pr-agent/docs/IMPROVE.md

60 lines
3.5 KiB
Markdown
Raw Normal View History

2023-09-29 16:39:25 +03:00
# Improve Tool
2023-09-29 09:47:13 +03:00
2023-11-26 17:41:20 +02:00
The `improve` tool scans the PR code changes, and automatically generates committable suggestions for improving the PR code.
2023-09-29 09:47:13 +03:00
It can be invoked manually by commenting on any PR:
```
/improve
```
For example:
<kbd><img src=https://codium.ai/images/pr_agent/improve_comment.png width="768"></kbd>
<kbd><img src=https://codium.ai/images/pr_agent/improve.png width="768"></kbd>
2023-09-29 09:47:13 +03:00
The `improve` tool can also be triggered automatically every time a new PR is opened. See examples for automatic triggers for [GitHub App](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) and [GitHub Action](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-action)
An extended mode, which does not involve PR Compression and provides more comprehensive suggestions, can be invoked by commenting on any PR:
```
/improve --extended
```
Note that the extended mode divides the PR code changes into chunks, up to the token limits, where each chunk is handled separately (multiple calls to GPT-4).
2023-11-26 17:41:20 +02:00
Hence, the total number of suggestions is proportional to the number of chunks, i.e., the size of the PR.
2023-09-29 09:47:13 +03:00
### Configuration options
Under the section 'pr_code_suggestions', the [configuration file](./../pr_agent/settings/configuration.toml#L40) contains options to customize the 'improve' tool:
- `num_code_suggestions`: number of code suggestions provided by the 'improve' tool. Default is 4.
- `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.
- `include_improved_code`: if set to true, the tool will include an improved code implementation in the suggestion. Default is true.
2023-09-29 09:47:13 +03:00
#### params for '/improve --extended' mode
- `auto_extended_mode`: enable extended mode automatically (no need for the `--extended` option). Default is false.
2023-09-29 09:47:13 +03:00
- `num_code_suggestions_per_chunk`: number of code suggestions provided by the 'improve' tool, per chunk. Default is 8.
- `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.
2023-10-19 09:16:20 +03:00
- `final_clip_factor`: factor to remove suggestions with low confidence. Default is 0.9.
#### summarize mode
2023-11-26 17:41:20 +02:00
- `summarize`: if set to true, the tool will present the code suggestions in a compact way. Default is false.
2023-11-26 17:17:36 +02:00
2023-11-26 17:41:20 +02:00
In this mode, instead of presenting committable suggestions, the different suggestions will be combined into a single compact comment, with significantly smaller PR footprint.
2023-11-26 17:21:02 +02:00
For example:
2023-11-26 17:21:02 +02:00
`/improve --pr_code_suggestions.summarize=true`
<kbd><img src=https://codium.ai/images/pr_agent/improved_summerize_open.png width="768"></kbd>
2023-10-19 09:16:20 +03:00
2023-11-30 16:35:44 +02:00
___
### A note on code suggestions quality
2023-10-19 09:16:20 +03:00
2023-11-30 17:13:47 +02:00
- While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
2023-10-19 09:16:20 +03:00
2023-10-19 09:20:36 +03:00
- Suggestions are not meant to be [simplistic](./../pr_agent/settings/pr_code_suggestions_prompts.toml#L34). Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
- Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project.
2023-10-19 09:16:20 +03:00
2023-11-26 17:41:20 +02:00
- Best quality will be obtained by using 'improve --extended' mode.