Skip to content
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
8 changes: 6 additions & 2 deletions pr_agent/algo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

1 change: 1 addition & 0 deletions pr_agent/settings/pr_questions_prompts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions pr_agent/settings/pr_reviewer_prompts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down Expand Up @@ -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":
Expand Down
4 changes: 3 additions & 1 deletion pr_agent/tools/pr_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ async def _get_prediction(self):
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
13 changes: 11 additions & 2 deletions pr_agent/tools/pr_reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,18 @@ def _prepare_pr_review(self) -> str:
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