diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py
index d91e9c06..c0955dea 100644
--- a/pr_agent/algo/utils.py
+++ b/pr_agent/algo/utils.py
@@ -70,109 +70,6 @@ def unique_strings(input_list: List[str]) -> List[str]:
seen.add(item)
return unique_list
-
-def convert_to_markdown(output_data: dict, gfm_supported: bool = True, incremental_review=None) -> str:
- """
- Convert a dictionary of data into markdown format.
- Args:
- output_data (dict): A dictionary containing data to be converted to markdown format.
- Returns:
- str: The markdown formatted text generated from the input dictionary.
- """
-
- emojis = {
- "Can be split": "๐",
- "Possible issues": "โก",
- "Key issues to review": "โก",
- "Score": "๐
",
- "Relevant tests": "๐งช",
- "Focused PR": "โจ",
- "Relevant ticket": "๐ซ",
- "Security concerns": "๐",
- "Insights from user's answers": "๐",
- "Code feedback": "๐ค",
- "Estimated effort to review [1-5]": "โฑ๏ธ",
- }
- markdown_text = ""
- if not incremental_review:
- markdown_text += f"{PRReviewHeader.REGULAR.value} ๐\n\n"
- else:
- markdown_text += f"{PRReviewHeader.INCREMENTAL.value} ๐\n\n"
- markdown_text += f"โฎ๏ธ Review for commits since previous PR-Agent review {incremental_review}.\n\n"
- if gfm_supported:
- markdown_text += "
\n"
- # markdown_text += """ Feedback | | """
-
- if not output_data or not output_data.get('review', {}):
- return ""
-
- for key, value in output_data['review'].items():
- if value is None or value == '' or value == {} or value == []:
- if key.lower() != 'can_be_split':
- continue
- key_nice = key.replace('_', ' ').capitalize()
- emoji = emojis.get(key_nice, "")
- if gfm_supported:
- if 'Estimated effort to review' in key_nice:
- key_nice = 'Estimated effort to review [1-5]'
- if 'security concerns' in key_nice.lower():
- value = emphasize_header(value.strip())
- markdown_text += f" {emoji} {key_nice} | \n{value}\n\n |
\n"
- elif 'can be split' in key_nice.lower():
- markdown_text += process_can_be_split(emoji, value)
- elif 'key issues to review' in key_nice.lower():
- value = value.strip()
- issues = value.split('\n- ')
- for i, _ in enumerate(issues):
- issues[i] = issues[i].strip().strip('-').strip()
- issues = unique_strings(issues) # remove duplicates
- number_of_issues = len(issues)
- if number_of_issues > 1:
- markdown_text += f" {emoji} {key_nice} | \n"
- for i, issue in enumerate(issues):
- if not issue:
- continue
- issue = emphasize_header(issue)
- issue = replace_code_tags(issue)
- if i == 0:
- markdown_text += f"\n{issue} |
\n"
- else:
- markdown_text += f"\n\n{issue} |
\n"
- else:
- value = emphasize_header(value.strip('-').strip())
- value = replace_code_tags(value)
- markdown_text += f" {emoji} {key_nice} | \n{value}\n\n |
\n"
- else:
- markdown_text += f" {emoji} {key_nice} | \n{value}\n\n |
\n"
- else:
- if len(value.split()) > 1:
- markdown_text += f"{emoji} **{key_nice}:**\n\n {value}\n\n"
- else:
- markdown_text += f"{emoji} **{key_nice}:** {value}\n\n"
- if gfm_supported:
- markdown_text += "
\n"
-
- if 'code_feedback' in output_data:
- if gfm_supported:
- markdown_text += f"\n\n"
- markdown_text += f" Code feedback:
\n\n"
- markdown_text += "
"
- else:
- markdown_text += f"\n\n** Code feedback:**\n\n"
- for i, value in enumerate(output_data['code_feedback']):
- if value is None or value == '' or value == {} or value == []:
- continue
- markdown_text += parse_code_suggestion(value, i, gfm_supported)+"\n\n"
- if markdown_text.endswith('
'):
- markdown_text = markdown_text[:-4]
- if gfm_supported:
- markdown_text += f" "
- #print(markdown_text)
-
-
- return markdown_text
-
-
def convert_to_markdown_v2(output_data: dict, gfm_supported: bool = True, incremental_review=None) -> str:
"""
Convert a dictionary of data into markdown format.
@@ -252,7 +149,7 @@ def convert_to_markdown_v2(output_data: dict, gfm_supported: bool = True, increm
if is_value_no(value):
markdown_text += f"{emoji} No security concerns identified"
else:
- markdown_text += f"{emoji} Security concerns"
+ markdown_text += f"{emoji} Security concerns
\n\n"
value = emphasize_header(value.strip())
markdown_text += f"{value}"
markdown_text += f"\n"
@@ -263,10 +160,11 @@ def convert_to_markdown_v2(output_data: dict, gfm_supported: bool = True, increm
markdown_text += f"### {emoji} Security concerns\n\n"
value = emphasize_header(value.strip())
markdown_text += f"{value}\n\n"
- elif 'can be split' in key_nice.lower() and gfm_supported:
- markdown_text += f""
- markdown_text += process_can_be_split(emoji, value)
- markdown_text += f" |
\n"
+ elif 'can be split' in key_nice.lower():
+ if gfm_supported:
+ markdown_text += f""
+ markdown_text += process_can_be_split(emoji, value)
+ markdown_text += f" |
\n"
elif 'key issues to review' in key_nice.lower():
value = value.strip()
issues = value.split('\n- ')
@@ -277,7 +175,7 @@ def convert_to_markdown_v2(output_data: dict, gfm_supported: bool = True, increm
markdown_text += f""
markdown_text += f"{emoji} {key_nice}
\n\n"
else:
- markdown_text += f"### {emoji} Key issues to review\n\n"
+ markdown_text += f"### {emoji} Key issues to review:\n\n"
for i, issue in enumerate(issues):
if not issue:
continue
@@ -302,7 +200,7 @@ def convert_to_markdown_v2(output_data: dict, gfm_supported: bool = True, increm
markdown_text += f" Code feedback:\n\n"
markdown_text += " "
else:
- markdown_text += f"\n\n** Code feedback:**\n\n"
+ markdown_text += f"\n\n### Code feedback:\n\n"
for i, value in enumerate(output_data['code_feedback']):
if value is None or value == '' or value == {} or value == []:
continue
@@ -324,7 +222,7 @@ def process_can_be_split(emoji, value):
value = "No"
# markdown_text += f" {emoji} {key_nice} | \n\n{value}\n\n | \n"
# markdown_text += f"### {emoji} No multiple PR themes\n\n"
- markdown_text += f"{emoji} No multiple PR themes<\n\n"
+ markdown_text += f"{emoji} No multiple PR themes\n\n"
else:
markdown_text += f"{emoji} {key_nice}
\n\n"
for i, split in enumerate(value):
diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py
index 4cbe9a68..c3276033 100644
--- a/pr_agent/tools/pr_reviewer.py
+++ b/pr_agent/tools/pr_reviewer.py
@@ -8,7 +8,7 @@ from pr_agent.algo.ai_handlers.base_ai_handler import BaseAiHandler
from pr_agent.algo.ai_handlers.litellm_ai_handler import LiteLLMAIHandler
from pr_agent.algo.pr_processing import get_pr_diff, retry_with_fallback_models
from pr_agent.algo.token_handler import TokenHandler
-from pr_agent.algo.utils import convert_to_markdown, github_action_output, load_yaml, ModelType, \
+from pr_agent.algo.utils import github_action_output, load_yaml, ModelType, \
show_relevant_configurations, convert_to_markdown_v2, PRReviewHeader
from pr_agent.config_loader import get_settings
from pr_agent.git_providers import get_git_provider, get_git_provider_with_context
|