Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add persistent improve #807

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/docs/tools/improve.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,17 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen

!!! 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 ...".
- `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.

!!! 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 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.
- `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.
Expand Down
1 change: 1 addition & 0 deletions pr_agent/settings/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ summarize = true
extra_instructions = ""
rank_suggestions = false
enable_help_text=true
persistent_comment=false
# params for '/improve --extended' mode
auto_extended_mode=true
num_code_suggestions_per_chunk=5
Expand Down
16 changes: 13 additions & 3 deletions pr_agent/tools/pr_code_suggestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,20 @@ async def run(self):
pr_body += HelpMessage.get_improve_usage_guide()
pr_body += "\n</details>\n"

if self.progress_response:
self.git_provider.edit_comment(self.progress_response, body=pr_body)
if get_settings().pr_code_suggestions.persistent_comment:
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:
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:
self.push_inline_code_suggestions(data)
Expand Down
Loading