Skip to content
Open
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
3 changes: 2 additions & 1 deletion sweepai/core/sweep_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
from sweepai.utils.str_utils import extract_object_fields_from_string
from sweepai.utils.streamable_functions import streamable


BOT_ANALYSIS_SUMMARY = "bot_analysis_summary"
SNIPPET_TOKEN_BUDGET = int(150_000 * 3.5) # 140k tokens
MAX_SNIPPETS = 15
Expand Down Expand Up @@ -1160,7 +1161,7 @@ def get_files_to_change_for_chat(
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

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
return renames_dict, file_change_requests, files_to_change_response
except RegexMatchError as e:
Expand Down
2 changes: 1 addition & 1 deletion sweepai/handlers/create_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def handle_file_change_requests(
if not previous_modify_files_dict:
previous_modify_files_dict = {}
if modify_files_dict:
for file_name, file_content in modify_files_dict.items():
for file_name, file_content in dict(modify_files_dict).items():
previous_modify_files_dict[file_name] = copy.deepcopy(file_content)
# update status of corresponding fcr to be succeeded
for file_change_request in file_change_requests:
Expand Down
4 changes: 2 additions & 2 deletions sweepai/handlers/on_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ def edit_comment(new_comment: str) -> None:
username,
"polluted_commits_error",
properties={
"old_keys": ",".join(previous_file_contents_to_commit.keys()),
"new_keys": ",".join(new_file_contents_to_commit.keys())
"old_keys": ",".join(previous_file_contents_to_commit),
"new_keys": ",".join(new_file_contents_to_commit)
},
)
commit = commit_multi_file_changes(cloned_repo, new_file_contents_to_commit, commit_message, branch_name)
Expand Down
64 changes: 60 additions & 4 deletions sweepai/handlers/on_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import traceback
from time import time

from github import BadCredentialsException
from github import BadCredentialsException, Github, IssueComment
from github.PullRequest import PullRequest as GithubPullRequest
from github.Repository import Repository
from loguru import logger


Expand Down Expand Up @@ -264,12 +265,18 @@ def on_ticket(
def edit_sweep_comment(
message: str,
index: int,
current_index: int,
user_token: str,
g: Github,
repo: Repository,
issue_comment: IssueComment,
initial_sandbox_response: int,
initial_sandbox_response_file: str,
pr_message="",
done=False,
step_complete=True,
add_bonus_message=True,
):
nonlocal current_index, user_token, g, repo, issue_comment, initial_sandbox_response, initial_sandbox_response_file
message = sanitize_string_for_github(message)
if pr_message:
pr_message = sanitize_string_for_github(pr_message)
Expand Down Expand Up @@ -391,7 +398,14 @@ def edit_sweep_comment(

edit_sweep_comment(
"I've just finished validating the issue. I'm now going to start searching for relevant files.",
0
0,
current_index,
user_token,
g,
repo,
issue_comment,
initial_sandbox_response,
initial_sandbox_response_file
)

prs_extracted = PRReader.extract_prs(repo, summary)
Expand All @@ -405,6 +419,13 @@ def edit_sweep_comment(
),
),
1,
current_index,
user_token,
g,
repo,
issue_comment,
initial_sandbox_response,
initial_sandbox_response_file
)

try:
Expand Down Expand Up @@ -456,12 +477,26 @@ def edit_sweep_comment(
else ""
),
1,
current_index,
user_token,
g,
repo,
issue_comment,
initial_sandbox_response,
initial_sandbox_response_file,
step_complete=False
)
else:
edit_sweep_comment(
message,
1,
current_index,
user_token,
g,
repo,
issue_comment,
initial_sandbox_response,
initial_sandbox_response_file,
step_complete=False
)

Expand All @@ -484,6 +519,13 @@ def edit_sweep_comment(
else ""
),
1,
current_index,
user_token,
g,
repo,
issue_comment,
initial_sandbox_response,
initial_sandbox_response_file
)

# # Search agent
Expand Down Expand Up @@ -549,6 +591,13 @@ def edit_sweep_comment(
edit_sweep_comment(
"I'm currently validating your changes using parsers and linters to check for mistakes like syntax errors or undefined variables. If I see any of these errors, I will automatically fix them.",
3,
current_index,
user_token,
g,
repo,
issue_comment,
initial_sandbox_response,
initial_sandbox_response_file
)
pull_request: SweepPullRequest = SweepPullRequest(
title="Sweep: " + title,
Expand Down Expand Up @@ -579,13 +628,20 @@ def edit_sweep_comment(
"polluted_commits_error",
properties={
"old_keys": ",".join(previous_file_contents_to_commit.keys()),
"new_keys": ",".join(new_file_contents_to_commit.keys())
"new_keys": ",".join(new_file_contents_to_commit.keys())
},
)
commit = commit_multi_file_changes(cloned_repo, new_file_contents_to_commit, commit_message, pull_request.branch_name, renames_dict=renames_dict)
edit_sweep_comment(
f"Your changes have been successfully made to the branch [`{pull_request.branch_name}`](https://github.com/{repo_full_name}/tree/{pull_request.branch_name}). I have validated these changes using a syntax checker and a linter.",
3,
current_index,
user_token,
g,
repo,
issue_comment,
initial_sandbox_response,
initial_sandbox_response_file
)
except Exception as e:
logger.exception(e)
Expand Down