Merge pull request #807 from Codium-ai/tr/persistent_improve

Add persistent improve
This commit is contained in:
Tal
2024-03-20 08:16:59 +02:00
committed by GitHub
3 changed files with 18 additions and 6 deletions

View File

@ -53,16 +53,17 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen
!!! example "General options" !!! example "General options"
- `num_code_suggestions`: number of code suggestions provided by the 'improve' tool. Default is 4. - `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 ...". - `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. - `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 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. - `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" !!! example "params for '/improve --extended' mode"
- `auto_extended_mode`: enable extended mode automatically (no need for the `--extended` option). Default is true. - `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 8. - `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. - `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. - `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. - `final_clip_factor`: factor to remove suggestions with low confidence. Default is 0.9.

View File

@ -82,6 +82,7 @@ summarize = true
extra_instructions = "" extra_instructions = ""
rank_suggestions = false rank_suggestions = false
enable_help_text=true enable_help_text=true
persistent_comment=false
# params for '/improve --extended' mode # params for '/improve --extended' mode
auto_extended_mode=true auto_extended_mode=true
num_code_suggestions_per_chunk=5 num_code_suggestions_per_chunk=5

View File

@ -117,10 +117,20 @@ class PRCodeSuggestions:
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 self.progress_response: if get_settings().pr_code_suggestions.persistent_comment:
self.git_provider.edit_comment(self.progress_response, body=pr_body) final_update_message = False
self.git_provider.publish_persistent_comment(pr_body,
initial_header="## PR Code Suggestions",
update_header=True,
final_update_message=final_update_message, )
if self.progress_response:
self.progress_response.delete()
else: else:
self.git_provider.publish_comment(pr_body)
if self.progress_response:
self.git_provider.edit_comment(self.progress_response, body=pr_body)
else:
self.git_provider.publish_comment(pr_body)
else: else:
self.push_inline_code_suggestions(data) self.push_inline_code_suggestions(data)