From aef8e958e8637ea4c5d94216195ff49a23bc36a0 Mon Sep 17 00:00:00 2001 From: wwzeng1 Date: Mon, 23 Oct 2023 01:47:02 +0000 Subject: [PATCH] update prompts --- sweepai/core/sweep_bot.py | 10 ++-------- sweepai/core/update_prompts.py | 8 ++++---- sweepai/utils/github_utils.py | 4 ++-- tests/rerun_issue_direct.py | 25 ++++++++++++++++--------- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/sweepai/core/sweep_bot.py b/sweepai/core/sweep_bot.py index 547628af26..bb91261f51 100644 --- a/sweepai/core/sweep_bot.py +++ b/sweepai/core/sweep_bot.py @@ -738,7 +738,6 @@ def check_sandbox( content=content, changed_files=changed_files, ) - logger.print(output) sandbox_execution = SandboxResponse(**output) if output["success"]: content = output["updated_content"] @@ -993,7 +992,7 @@ def modify_file( raise SystemExit except UnneededEditError as e: if chunking: - return contents, "", None, changed_files + return contents, f"feat: Updated {file_change_request.filename}", None, changed_files raise e except Exception as e: raise e @@ -1009,11 +1008,7 @@ def modify_file( self.delete_messages_from_chat(key) raise e try: - commit_message_match = None - if commit_message_match: - commit_message = commit_message_match.group("commit_message") - else: - commit_message = f"feat: Updated {file_change_request.filename}" + commit_message = f"feat: Updated {file_change_request.filename}" commit_message = commit_message[: min(len(commit_message), 50)] changed_files.append( ( @@ -1555,7 +1550,6 @@ def get_new_file(temperature: float = 0.0): "No changes made to file.", changed_files, ) - try: result = self.repo.update_file( file_name, diff --git a/sweepai/core/update_prompts.py b/sweepai/core/update_prompts.py index 2a44cc0c13..61a217e19d 100644 --- a/sweepai/core/update_prompts.py +++ b/sweepai/core/update_prompts.py @@ -9,7 +9,7 @@ Describe what should be changed to the snippets from the old_file to complete the request. -Then, for each snippet in a list, determine whether changes should be made. If so, describe the changes needed, with references to the lines that should be changed and what to change it to. Otherwise, do not write an updated_snippet block for this snippet. +Then, for each snippet in a list, determine whether changes should be made. If so, describe the changes needed, with references to the lines that should be changed and what to change it to. Maximize information density. @@ -41,7 +41,7 @@ Describe what should be changed to the snippets from the old_file to complete the request. -Then, for each snippet in a list, determine whether changes should be made. If so, describe the changes needed, with references to the lines that should be changed and what to change it to. Otherwise, do not write an updated_snippet block for this snippet. +Then, for each snippet in a list, determine whether changes should be made. If so, describe the changes needed, with references to the lines that should be changed and what to change it to. Maximize information density. @@ -88,7 +88,7 @@ Describe what should be changed to the snippets from the old_file to complete the request. -Then, for each snippet in a list, determine whether changes should be made. If so, describe the changes needed, with references to the lines that should be changed and what to change it to. Otherwise, do not write an updated_snippet block for this snippet. +Then, for each snippet in a list, determine whether changes should be made. If so, describe the changes needed, with references to the lines that should be changed and what to change it to. Maximize information density. @@ -134,7 +134,7 @@ Respond in the following format: -For each snippet in a list, determine whether changes should be made. If so, describe the changes needed. Otherwise, do not write an updated_snippet block for this snippet. +For each snippet in a list, determine whether changes should be made. If so, describe the changes needed. diff --git a/sweepai/utils/github_utils.py b/sweepai/utils/github_utils.py index e401144584..39f9ba735f 100644 --- a/sweepai/utils/github_utils.py +++ b/sweepai/utils/github_utils.py @@ -102,8 +102,8 @@ class ClonedRepo: @cached_property def cache_dir(self): - random_bytes = os.urandom(16) - hash_obj = hashlib.sha256(random_bytes) + curr_time_str = str(time.time()).encode("utf-8") + hash_obj = hashlib.sha256(curr_time_str) hash_hex = hash_obj.hexdigest() if self.branch: return os.path.join( diff --git a/tests/rerun_issue_direct.py b/tests/rerun_issue_direct.py index fc762b09ef..8cee75ed58 100644 --- a/tests/rerun_issue_direct.py +++ b/tests/rerun_issue_direct.py @@ -87,17 +87,24 @@ def test_issue_url( issue_request = fetch_issue_request(issue_url) print(f"Sending request...") - request_process = multiprocessing.Process( - target=send_request, args=(issue_request,) - ) - request_process.start() + if debug: + client = TestClient(app) + response = client.post( + "/", json=issue_request.dict(), headers={"X-GitHub-Event": "issues"} + ) + print(response) + else: + request_process = multiprocessing.Process( + target=send_request, args=(issue_request,) + ) + request_process.start() - request_process.join(timeout=None if debug else 150) + request_process.join(timeout=150) - if request_process.is_alive(): - print("Terminating the process...") - request_process.terminate() - request_process.join() # Ensure process has terminated before proceeding + if request_process.is_alive(): + print("Terminating the process...") + request_process.terminate() + request_process.join() # Ensure process has terminated before proceeding better_stack_link = f"{better_stack_prefix}{html.escape(issue_url)}" print(f"Track the logs at the following link:\n\n{better_stack_link}")