Skip to content

Commit

Permalink
protections
Browse files Browse the repository at this point in the history
  • Loading branch information
mrT23 committed Mar 5, 2024
1 parent 359a15c commit d77db93
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pr_agent/tools/pr_code_suggestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,14 @@ async def run(self):
else:
data = await retry_with_fallback_models(self._prepare_prediction_extended, ModelType.TURBO)


if (not data) or (not 'code_suggestions' in data):
get_logger().info('No code suggestions found for PR.')
if (not data) or (not 'code_suggestions' in data) or (not data['code_suggestions']):
get_logger().error('No code suggestions found for PR.')
pr_body = "## PR Code Suggestions\n\nNo code suggestions found for PR."
get_logger().debug(f"PR output", artifact=pr_body)
if self.progress_response:
self.git_provider.edit_comment(self.progress_response, body=pr_body)
else:
self.git_provider.publish_comment(pr_body)
return

if (not self.is_extended and get_settings().pr_code_suggestions.rank_suggestions) or \
Expand Down Expand Up @@ -179,6 +184,7 @@ def _prepare_pr_code_suggestions(self) -> Dict:
suggestion_list = []
one_sentence_summary_list = []
for i, suggestion in enumerate(data['code_suggestions']):
continue
if get_settings().pr_code_suggestions.summarize:
if not suggestion or 'one_sentence_summary' not in suggestion or 'label' not in suggestion or 'relevant_file' not in suggestion:
get_logger().debug(f"Skipping suggestion {i + 1}, because it is invalid: {suggestion}")
Expand Down Expand Up @@ -317,7 +323,7 @@ async def rank_suggestions(self, data: List) -> List:
suggestion_list.append(suggestion)
data_sorted = [[]] * len(suggestion_list)

if len(suggestion_list ) == 1:
if len(suggestion_list) == 1:
return suggestion_list

try:
Expand Down

0 comments on commit d77db93

Please sign in to comment.