Skip to content

Commit

Permalink
final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Ye committed Jun 5, 2024
1 parent ad3b741 commit feb8d13
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 4 additions & 1 deletion sweepai/core/on_comment_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
</issue_sub_request>
<justification>
1. Why this subtask is needed.
2. A detailed explanation of the subtask, including the specific code entities that need to be changed.
2. Answer the following question: Does this subtask involve working with code that has been added in the pull request? Was the code removed in the pull request? Or is the previously untouched code.
3. Justify your answer to the above question by either including the patch index where the code was added or removed. If it was untouched, then justify why it was untouched.
4. A detailed explanation of the subtask, including the specific code entities that need to be changed.
</justification>
[additional sub requests as needed]
</issue_sub_requests>"""
Expand Down Expand Up @@ -98,6 +100,7 @@
<proposed_changes>
For each of the sub requests here, pinpoint the exact places to make changes. Describe exactly what to do, referencing specific code entities in the relevant files.
Break the above steps up into seperate actionable steps and number them.
Double check the state of the code base.
Example:
1. Step 1
- Step 1a
Expand Down
3 changes: 0 additions & 3 deletions sweepai/core/sweep_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,6 @@ def get_files_to_change(
error_message, error_indices = get_error_message(file_change_requests, cloned_repo, renames_dict=renames_dict)
logger.debug("New indices", error_indices)
yield renames_dict, user_facing_message + "Here are the changes we decided to make. I'm currently just making some edits:\n", file_change_requests
# breakpoint()
# breakpoint()

validate_file_change_requests(file_change_requests, cloned_repo, renames_dict=renames_dict)
yield renames_dict, user_facing_message + "Here are the changes we decided to make. I'm done making edits and now I'm just validating the changes using a linter to catch any mistakes like syntax errors or undefined variables:\n", file_change_requests
Expand Down Expand Up @@ -1020,7 +1018,6 @@ def get_files_to_change_for_on_comment(
response_cleanup=cleanup_fcrs,
MAX_CALLS=10
)
# breakpoint()
relevant_modules = []
pattern = re.compile(r"<relevant_modules>(.*?)</relevant_modules>", re.DOTALL)
relevant_modules_match = pattern.search(files_to_change_response)
Expand Down
6 changes: 4 additions & 2 deletions sweepai/handlers/on_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ def edit_comment(new_comment: str) -> None:
pruned_source_code = smart_prune_file_based_on_patches(numbered_source_code, pr_change.patches)
source_codes.append(f'<file_with_patches_applied file_name="{file_name}">\n{pruned_source_code}\n</file>')
patch_changes = [patch.changes for patch in pr_change.patches]
patches_string = "\n".join(patch_changes)
patch_annotations = pr_change.annotations
patches_with_annotations = [f'<patch index="{i}">\n{patch}\n</patch>\n<patch_description index="{i}">\n{patch_annotations[i]}\n<patch_description>' for i, patch in enumerate(patch_changes)]
patches_string = "\n".join(patches_with_annotations)
patches.append(
f'<patches file_name="{file_name}">\n{patches_string}\n</patches>'
)
Expand All @@ -237,7 +239,7 @@ def edit_comment(new_comment: str) -> None:
"<code_files_with_patches_applied>\n" + "\n".join(source_codes) + "\n</code_files_with_patches_applied>"
)
pr_diff_string = (
"<pr_changes>\n" + "\n".join(patches) + "\n\n# Here are all the code files with the above patches applied:\n\n" + source_code_string + "</pr_changes>"
"<pr_changes>\n" + "\n".join(patches) + "\n\n# Here is the current state of the codebase with the above patches applied:\n\n" + source_code_string + "</pr_changes>"
)

# This means it's a comment on a file
Expand Down

0 comments on commit feb8d13

Please sign in to comment.