mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-02 03:40:38 +08:00
@ -51,9 +51,13 @@ def parse_code_suggestion(code_suggestions: dict) -> str:
|
||||
markdown_text += f" - **{code_key}:**\n{code_str_indented}\n"
|
||||
else:
|
||||
if "suggestion number" in sub_key.lower():
|
||||
markdown_text += f"- **suggestion {sub_value}:**\n" # prettier formatting
|
||||
# markdown_text += f"- **suggestion {sub_value}:**\n" # prettier formatting
|
||||
pass
|
||||
elif "relevant file" in sub_key.lower():
|
||||
markdown_text += f"\n - **{sub_key}:** {sub_value}\n"
|
||||
else:
|
||||
markdown_text += f" - **{sub_key}:** {sub_value}\n"
|
||||
markdown_text += f" **{sub_key}:** {sub_value}\n"
|
||||
|
||||
markdown_text += "\n"
|
||||
return markdown_text
|
||||
|
||||
|
@ -3,6 +3,7 @@ system="""You are CodiumAI-PR-Reviewer, a language model designed to review git
|
||||
Your task is to answer questions about the new PR code (the '+' lines), and provide feedback.
|
||||
Be informative, constructive, and give examples. Try to be as specific as possible, and don't avoid answering the questions.
|
||||
Make sure not to repeat modifications already implemented in the new PR code (the '+' lines).
|
||||
Answer only the questions, and don't add unrelated content.
|
||||
"""
|
||||
|
||||
user="""PR Info:
|
||||
|
@ -33,7 +33,7 @@ You must use the following JSON schema to format your answer:
|
||||
{%- if require_minimal_and_focused %}
|
||||
"Minimal and focused": {
|
||||
"type": "string",
|
||||
"description": "is this PR as minimal and focused as possible, with all code changes centered around a single coherent theme, described in the PR description and title ?" explain your answer"
|
||||
"description": "is this PR as minimal and focused as possible, with all code changes centered around a single coherent theme, described in the PR description and title ?" Make sure to explain your answer"
|
||||
}
|
||||
},
|
||||
{%- endif %}
|
||||
@ -107,7 +107,7 @@ Example output:
|
||||
"Relevant tests added": "No",
|
||||
{%- endif %}
|
||||
{%- if require_minimal_and_focused %}
|
||||
"Minimal and focused": "No, because ..."
|
||||
"Minimal and focused": "yes\\no, because ..."
|
||||
{%- endif %}
|
||||
},
|
||||
"PR Feedback":
|
||||
|
@ -64,6 +64,8 @@ class PRQuestions:
|
||||
return response
|
||||
|
||||
def _prepare_pr_answer(self) -> str:
|
||||
answer_str = f"Questions: {self.question_str}\n\n"
|
||||
answer_str = f"Question: {self.question_str}\n\n"
|
||||
answer_str += f"Answer: {self.prediction.strip()}\n\n"
|
||||
if settings.config.verbosity_level >= 2:
|
||||
logging.info(f"answer_str:\n{answer_str}")
|
||||
return answer_str
|
||||
|
@ -81,9 +81,18 @@ class PRReviewer:
|
||||
except json.decoder.JSONDecodeError:
|
||||
logging.error("Unable to decode JSON response from AI")
|
||||
data = {}
|
||||
|
||||
# reordering for nicer display
|
||||
if 'PR Feedback' in data:
|
||||
if 'Security concerns' in data['PR Feedback']:
|
||||
val = data['PR Feedback']['Security concerns']
|
||||
del data['PR Feedback']['Security concerns']
|
||||
data['PR Analysis']['Security concerns'] = val
|
||||
|
||||
markdown_text = convert_to_markdown(data)
|
||||
markdown_text += "\nAdd a comment that says 'Please review' to ask for a new review after you update the PR.\n"
|
||||
markdown_text += "Add a comment that says 'Please answer <QUESTION...>' to ask a question about this PR.\n"
|
||||
markdown_text += "\n## How to use\n\n"
|
||||
markdown_text += "```\nMention '@pr-agent' in a pr comment to get another review.\n"
|
||||
markdown_text += "Mention '@pr-agent <QUESTION>' in a pr comment to ask a question about this PR.\n```\n"
|
||||
if settings.config.verbosity_level >= 2:
|
||||
logging.info(f"Markdown response:\n{markdown_text}")
|
||||
return markdown_text
|
||||
|
Reference in New Issue
Block a user