Merge pull request #586 from Codium-ai/tr/ask_usage

ask helper
This commit is contained in:
Tal
2024-01-09 06:55:30 -08:00
committed by GitHub
5 changed files with 43 additions and 6 deletions

View File

@ -1,11 +1,15 @@
# ASK Tool
The `ask` tool answers questions about the PR, based on the PR code changes.
The `ask` tool answers questions about the PR, based on the PR code changes. Make sure to be specific and clear in your questions.
It can be invoked manually by commenting on any PR:
```
/ask "..."
```
For example:
___
<kbd><img src=https://codium.ai/images/pr_agent/ask_comment.png width="768"></kbd>
___
<kbd><img src=https://codium.ai/images/pr_agent/ask.png width="768"></kbd>
___
Note that the tool does not have "memory" of previous questions, and answers each question independently.

View File

@ -75,7 +75,7 @@ Edit this field to enable/disable the tool, or to change the used configurations
output += "<tr><td><details> <summary><strong> About the 'Code feedback' section</strong></summary><hr>\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</details></td></tr>\n\n"
@ -184,3 +184,28 @@ 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 answers questions about the PR, based on the PR code changes.
It can be invoked manually by commenting on any PR:
```
/ask "..."
```
Note that the tool does not have "memory" of previous questions, and answers each question independently.
"""
output += "\n\n<table>"
# general
output += "\n\n<tr><td><details> <summary><strong> More PR-Agent commands</strong></summary><hr> \n\n"
output += HelpMessage.get_general_bot_help_text()
output += "\n\n</details></td></tr>\n\n"
output += "</table>"
output += f"\n\nSee the [ask usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/ASK.md) page for a comprehensive guide on using this tool.\n\n"
return output

View File

@ -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

View File

@ -1,7 +1,7 @@
[pr_questions_prompt]
system="""You are PR-Reviewer, a language model designed to review a Git Pull Request (PR).
system="""You are PR-Reviewer, a language model designed to answer questions about a Git Pull Request (PR).
Your goal is to answer questions\\tasks about the new PR code (lines starting with '+'), and provide feedback.
Your goal is to answer questions\\tasks about the new code introduced in the PR (lines starting with '+' in the 'PR Git Diff' section), and provide feedback.
Be informative, constructive, and give examples. Try to be as specific as possible.
Don't avoid answering the questions. You must answer the questions, as best as you can, without adding any unrelated content.
"""

View File

@ -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 += "<hr>\n\n<details> <summary><strong>✨ Usage guide:</strong></summary><hr> \n\n"
pr_comment += HelpMessage.get_ask_usage_guide()
pr_comment += "\n</details>\n"
if get_settings().config.publish_output:
get_logger().info('Pushing answer...')
self.git_provider.publish_comment(pr_comment)