From abc05e771181a862d3c4e796be1c98dc5e351102 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 9 Jan 2024 16:25:23 +0200 Subject: [PATCH] ask helper --- docs/ASK.md | 8 ++++++-- pr_agent/servers/help.py | 25 ++++++++++++++++++++++++- pr_agent/settings/configuration.toml | 2 ++ pr_agent/tools/pr_questions.py | 6 ++++++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/docs/ASK.md b/docs/ASK.md index 72dd0bb0..ab8847d5 100644 --- a/docs/ASK.md +++ b/docs/ASK.md @@ -6,6 +6,10 @@ It can be invoked manually by commenting on any PR: /ask "..." ``` For example: - +___ - \ No newline at end of file +___ + +___ + +Note that the tool does not have "memory" of previous questions, and answers each question independently. \ No newline at end of file diff --git a/pr_agent/servers/help.py b/pr_agent/servers/help.py index 633c3281..29c3f3fc 100644 --- a/pr_agent/servers/help.py +++ b/pr_agent/servers/help.py @@ -75,7 +75,7 @@ Edit this field to enable/disable the tool, or to change the used configurations output += "
About the 'Code feedback' section
\n\n" output+="""\ The `review` tool provides several type of feedbacks, one of them is code suggestions. -If you are interested **only** in the code suggestions, it is recommended to use the [`improve`](./IMPROVE.md) feature instead, since it dedicated only to code suggestions, and usually gives better results. +If you are interested **only** in the code suggestions, it is recommended to use the [`improve`](https://github.com/Codium-ai/pr-agent/blob/main/docs/IMPROVE.md) feature instead, since it dedicated only to code suggestions, and usually gives better results. Use the `review` tool if you want to get a more comprehensive feedback, which includes code suggestions as well. """ output += "\n\n
\n\n" @@ -184,3 +184,26 @@ Make sure to provide proper title, and a detailed and well-phrased description f output += f"\n\nSee the [describe usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/DESCRIBE.md) page for a comprehensive guide on using this tool.\n\n" return output + + @staticmethod + def get_ask_usage_guide(): + output = "**Overview:**\n" + output += """\ +The [`ask` tool](https://github.com/Codium-ai/pr-agent/blob/main/docs/ASK.md] answers questions about the PR, based on the PR code changes. Note that the tool does not have "memory" of previous questions, and answers each question independently. +It can be invoked manually by commenting on any PR: +``` +/ask "..." +``` + """ + output += "\n\n" + + # general + output += "\n\n\n\n" + + output += "
More PR-Agent commands
\n\n" + output += HelpMessage.get_general_bot_help_text() + output += "\n\n
" + + output += f"\n\nSee the [review usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/REVIEW.md) page for a comprehensive guide on using this tool.\n\n" + + return output diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 89912e46..b0e9c295 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -63,6 +63,8 @@ include_generated_by_header=true #custom_labels = ['Bug fix', 'Tests', 'Bug fix with tests', 'Enhancement', 'Documentation', 'Other'] [pr_questions] # /ask # +enable_help_text=true + [pr_code_suggestions] # /improve # num_code_suggestions=4 diff --git a/pr_agent/tools/pr_questions.py b/pr_agent/tools/pr_questions.py index 4d499598..5514d7fa 100644 --- a/pr_agent/tools/pr_questions.py +++ b/pr_agent/tools/pr_questions.py @@ -11,6 +11,7 @@ from pr_agent.config_loader import get_settings from pr_agent.git_providers import get_git_provider from pr_agent.git_providers.git_provider import get_main_pr_language from pr_agent.log import get_logger +from pr_agent.servers.help import HelpMessage class PRQuestions: @@ -52,6 +53,11 @@ class PRQuestions: await retry_with_fallback_models(self._prepare_prediction) get_logger().info('Preparing answer...') pr_comment = self._prepare_pr_answer() + if self.git_provider.is_supported("gfm_markdown") and get_settings().pr_questions.enable_help_text: + pr_comment += "
\n\n
✨ Usage guide:
\n\n" + pr_comment += HelpMessage.get_ask_usage_guide() + pr_comment += "\n
\n" + if get_settings().config.publish_output: get_logger().info('Pushing answer...') self.git_provider.publish_comment(pr_comment)