From 428c49b02a490990444c8341d3cbd108719e3fb4 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 17:59:45 +0000 Subject: [PATCH 01/22] Fixed gha prompt --- sweepai/core/prompts.py | 3 ++- sweepai/utils/utils.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sweepai/core/prompts.py b/sweepai/core/prompts.py index 75095b120b..1c96fc59a8 100644 --- a/sweepai/core/prompts.py +++ b/sweepai/core/prompts.py @@ -443,6 +443,7 @@ Step 1. Reference the original code in tags, copying them VERBATIM from the file, with correct indentation and whitespace. - Do NOT paraphrase or abbreviate the source code. - Placeholder comments like "# existing code" are not permitted. + - Minimum one function for context. Step 2. Write the new code in tags, specifying necessary imports and including relevant type definitions, interfaces, and schemas. - BE EXACT as this code will replace the mentioned . Step 3. Determine if this is a change that occurs EXACTLY in other parts of the same file. If so, add a true flag. @@ -502,7 +503,7 @@ a. Describe the section of code that needs to be modified, i.e. the test case that checks if `foo` == `bar`. -Copy the original_code here VERBATIM from the file. Do NOT paraphrase or abbreviate the source code. Placeholder comments like "# existing code" are not permitted. +Copy the original_code here VERBATIM from the file. Do NOT paraphrase or abbreviate the source code. Placeholder comments like "# existing code" are not permitted. Minimum one function. b. Describe the changes that need to be made to the code, i.e. the test case should instead check if `foo` != `baz`. diff --git a/sweepai/utils/utils.py b/sweepai/utils/utils.py index 93b0e5ab39..cc6ce338be 100644 --- a/sweepai/utils/utils.py +++ b/sweepai/utils/utils.py @@ -414,6 +414,7 @@ def find_deepest_error(node: Node) -> Optional[Node]: @file_cache() def get_pylint_check_results(file_path: str, code: str) -> CheckResults: + logger.debug(f"Running pylint on {file_path}...") file_hash = uuid.uuid4().hex new_file = os.path.join("/tmp", file_hash + "_" + os.path.basename(file_path)) stem = os.path.splitext(os.path.basename(file_path))[0] @@ -444,6 +445,7 @@ def get_pylint_check_results(file_path: str, code: str) -> CheckResults: error_message = error_message.replace(new_file, file_path).replace(f"{file_hash}_" + stem, stem) error_message = error_message.split("-----------------------------------", 1)[0].strip() error_message = f"> pylint {file_path}\n\n" + error_message + logger.debug("Done running pylint.") return CheckResults(pylint=error_message if not succeeded else "") @file_cache() From d15b01676393c9f0560db6221b7f6f47ce0948da Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 18:19:31 +0000 Subject: [PATCH 02/22] Stringzilla --- pyproject.toml | 1 + requirements.txt | 1 + sweepai/agents/modify.py | 25 ++++++++----------------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ef3c580f53..233a8ec722 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,7 @@ dependencies = [ "backoff==2.2.1", "pymongo==4.6.3", "gitpython==3.1.42", + "stringzilla==3.8.4", "tree-sitter==0.21.0", "tree-sitter-python==0.21.0", "tree-sitter-javascript==0.21.0", diff --git a/requirements.txt b/requirements.txt index 5886626a2b..4c164150f9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -552,6 +552,7 @@ starlette==0.36.3 # via # fastapi # prometheus-fastapi-instrumentator +stringzilla==3.8.4 tabulate==0.9.0 tenacity==8.2.3 # via voyageai diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index ac3e171a64..f6ecfef34c 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -4,6 +4,7 @@ import re from rapidfuzz import fuzz, process +import stringzilla as sz from loguru import logger import rapidfuzz @@ -554,23 +555,13 @@ def rstrip_lines(text: str) -> str: def indent(text: str, spaces: int) -> str: return "\n".join([f"{' ' * spaces}{line}" for line in text.split("\n")]) +pattern = sz.regex(r"[^\w(){}\[\]_]+") + def tokenize_code(code: str): - # Split on all non-alphanumeric characters - tokens = [] - current_token = "" - available_set = ("(", ")", "{", "}", "[", "]", "_") - for char in code: - if char.isalnum() or char in available_set: - current_token += char - elif current_token: - tokens.append(current_token) - current_token = "" - if current_token: - tokens.append(current_token) - return tokens + return pattern.split(code) def code_processor(code: str): - return " ".join(tokenize_code(code)) + return " ".join(pattern.split(code)) def find_best_match(needle: str, haystack: str, threshold: int = 60, verbose=True, tokenized=False): best_match = 0 @@ -869,11 +860,11 @@ def get_replaces_per_fcr(fcr: FileChangeRequest) -> int: def parse_fcr(fcr: FileChangeRequest): flags = "" justification, *_ = fcr.instructions.split("", 1) - original_code_pattern = r"(.*?)" - new_code_pattern = r"(.*?)" + original_code_pattern = r"\n(.*?)\n" + new_code_pattern = r"\n(.*?)\n" original_code_matches = list(re.finditer(original_code_pattern, fcr.instructions, re.DOTALL)) new_code_matches = list(re.finditer(new_code_pattern, fcr.instructions, re.DOTALL)) - replace_all_pattern = r"(.*?)" + replace_all_pattern = r"true" replace_all_matches = list(re.finditer(replace_all_pattern, fcr.instructions, re.DOTALL)) if replace_all_matches: flags += "\ntrue" From d08c8b5f7ea95b6a12e25d6d9376d7149f8bc339 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 18:25:55 +0000 Subject: [PATCH 03/22] Fixed tokenizing --- sweepai/agents/modify.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index f6ecfef34c..0aa3ae1ec6 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -2,6 +2,7 @@ from math import inf import os import re +import sys from rapidfuzz import fuzz, process import stringzilla as sz @@ -555,13 +556,11 @@ def rstrip_lines(text: str) -> str: def indent(text: str, spaces: int) -> str: return "\n".join([f"{' ' * spaces}{line}" for line in text.split("\n")]) -pattern = sz.regex(r"[^\w(){}\[\]_]+") - def tokenize_code(code: str): - return pattern.split(code) + return [str(token) for token in sz.Str(code).split_charset(separator=' \n\t\r()\{\}\[\]_', maxsplit=sys.maxsize, keepseparator=False) if token] def code_processor(code: str): - return " ".join(pattern.split(code)) + return " ".join(tokenize_code(code)) def find_best_match(needle: str, haystack: str, threshold: int = 60, verbose=True, tokenized=False): best_match = 0 From 7211961ba3b12a8c4708a805279e196b8dc49776 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 19:32:50 +0000 Subject: [PATCH 04/22] Cleanup planning --- sweepai/core/sweep_bot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sweepai/core/sweep_bot.py b/sweepai/core/sweep_bot.py index d87eb653fe..18cb1895db 100644 --- a/sweepai/core/sweep_bot.py +++ b/sweepai/core/sweep_bot.py @@ -1026,7 +1026,6 @@ def get_files_to_change_for_gha( ], ) MODEL = "claude-3-opus-20240229" if not use_faster_model else "claude-3-sonnet-20240229" - # MODEL = "claude-3-opus-20240229" if not use_faster_model else "claude-3-haiku-20240307" files_to_change_response = chat_gpt.chat_anthropic( content=joint_message + "\n\n" + gha_files_to_change_prompt, model=MODEL, From 37fc09a82d1dd5fe2e42f26f53b829f4e75c198b Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 20:17:46 +0000 Subject: [PATCH 05/22] Minor bug fix --- sweepai/agents/modify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index 0aa3ae1ec6..f4083091a8 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -859,8 +859,8 @@ def get_replaces_per_fcr(fcr: FileChangeRequest) -> int: def parse_fcr(fcr: FileChangeRequest): flags = "" justification, *_ = fcr.instructions.split("", 1) - original_code_pattern = r"\n(.*?)\n" - new_code_pattern = r"\n(.*?)\n" + original_code_pattern = r"\n(.*?)" + new_code_pattern = r"\n(.*?)" original_code_matches = list(re.finditer(original_code_pattern, fcr.instructions, re.DOTALL)) new_code_matches = list(re.finditer(new_code_pattern, fcr.instructions, re.DOTALL)) replace_all_pattern = r"true" From 074994fa741d3457215be623b919459f3f0f297a Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 20:57:47 +0000 Subject: [PATCH 06/22] Better tokenizer --- sweepai/agents/modify.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index f4083091a8..612b351549 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -557,7 +557,13 @@ def indent(text: str, spaces: int) -> str: return "\n".join([f"{' ' * spaces}{line}" for line in text.split("\n")]) def tokenize_code(code: str): - return [str(token) for token in sz.Str(code).split_charset(separator=' \n\t\r()\{\}\[\]_', maxsplit=sys.maxsize, keepseparator=False) if token] + cleaned_code = "" + for line in code.split("\n"): + stripped_line = line.strip() + if stripped_line.startswith("#") or stripped_line.startswith("//") or len(stripped_line) == 0: + continue + cleaned_code += line + "\n" + return [str(token) for token in sz.Str(cleaned_code).split_charset(separator=' \n\t\r()\{\}\[\]', maxsplit=sys.maxsize, keepseparator=True) if str(token).strip()] def code_processor(code: str): return " ".join(tokenize_code(code)) @@ -570,7 +576,7 @@ def find_best_match(needle: str, haystack: str, threshold: int = 60, verbose=Tru num_match_lines = len(needle.split("\n")) for start_line in tqdm(range(num_lines), total=num_lines) if verbose else range(num_lines): potential_choices = [] - for end_line in range(start_line + max(1, num_match_lines - 5), start_line + num_match_lines + 5): + for end_line in range(start_line + max(1, num_match_lines - 10), start_line + num_match_lines + 10): if end_line > num_lines: break potential_choice = "\n".join(file_contents_lines[start_line:end_line]) @@ -581,7 +587,7 @@ def find_best_match(needle: str, haystack: str, threshold: int = 60, verbose=Tru potential_choices, scorer=fuzz.QRatio, score_cutoff=threshold, - processor=code_processor if tokenized else None, + processor=tokenize_code if tokenized else None, ) if results is not None: @@ -630,7 +636,7 @@ def find_best_matches( scorer=fuzz.QRatio, score_cutoff=threshold, limit=num_matches, - processor=code_processor if tokenized else None, + processor=tokenize_code if tokenized else None, **kwargs ) From dbd34d9ebc651788e7eace24a8f8a0b7d160203e Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 20:59:42 +0000 Subject: [PATCH 07/22] Refactor --- sweepai/agents/modify.py | 64 +++++++++++++++++++++------------------ sweepai/core/sweep_bot.py | 4 +-- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index 612b351549..fafd7ce93e 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -568,38 +568,38 @@ def tokenize_code(code: str): def code_processor(code: str): return " ".join(tokenize_code(code)) -def find_best_match(needle: str, haystack: str, threshold: int = 60, verbose=True, tokenized=False): - best_match = 0 - best_score = 0 - file_contents_lines = haystack.split("\n") - num_lines = len(file_contents_lines) - num_match_lines = len(needle.split("\n")) - for start_line in tqdm(range(num_lines), total=num_lines) if verbose else range(num_lines): - potential_choices = [] - for end_line in range(start_line + max(1, num_match_lines - 10), start_line + num_match_lines + 10): - if end_line > num_lines: - break - potential_choice = "\n".join(file_contents_lines[start_line:end_line]) - potential_choices.append(potential_choice) - - results = process.extractOne( - needle, - potential_choices, - scorer=fuzz.QRatio, - score_cutoff=threshold, - processor=tokenize_code if tokenized else None, - ) +# def find_best_match(needle: str, haystack: str, threshold: int = 60, verbose=True, tokenized=False): +# best_match = 0 +# best_score = 0 +# file_contents_lines = haystack.split("\n") +# num_lines = len(file_contents_lines) +# num_match_lines = len(needle.split("\n")) +# for start_line in tqdm(range(num_lines), total=num_lines) if verbose else range(num_lines): +# potential_choices = [] +# for end_line in range(start_line + max(1, num_match_lines - 10), start_line + num_match_lines + 10): +# if end_line > num_lines: +# break +# potential_choice = "\n".join(file_contents_lines[start_line:end_line]) +# potential_choices.append(potential_choice) + +# results = process.extractOne( +# needle, +# potential_choices, +# scorer=fuzz.QRatio, +# score_cutoff=threshold, +# processor=tokenize_code if tokenized else None, +# ) - if results is not None: - choice, score, _index = results +# if results is not None: +# choice, score, _index = results - if score > best_score: - best_score = score - best_match = choice +# if score > best_score: +# best_score = score +# best_match = choice - if best_score > threshold: - return best_match, best_score - return "", 0 +# if best_score > threshold: +# return best_match, best_score +# return "", 0 def find_best_matches( needle: str, @@ -654,6 +654,12 @@ def find_best_matches( deduped_best_matches.append((match, score)) return deduped_best_matches[:num_matches] +def find_best_match(*args, **kwargs): + results = find_best_matches(*args, **kwargs) + if len(results) > 0: + return results[0] + return "", 0 + def find_max_indentation(needle: str): max_indent = 0 for line in needle.splitlines(): diff --git a/sweepai/core/sweep_bot.py b/sweepai/core/sweep_bot.py index 18cb1895db..d9a59a227f 100644 --- a/sweepai/core/sweep_bot.py +++ b/sweepai/core/sweep_bot.py @@ -222,7 +222,7 @@ def get_error_message( if best_score > 80: error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify the following code instead?\n```\n{best_match}\n```\nHere is the diff between your proposed and the most similar code in the file:\n```diff\n{generate_diff(indent(original_code, best_indent), best_match)}\n```\n\n\n" elif best_score > 50: - best_matches = find_best_matches(original_code, file_contents, threshold=60, tokenized=True) + best_matches = find_best_matches(original_code, file_contents, threshold=threshold, tokenized=True) if len(best_matches) > 1: best_matches_string = "\n\n".join([f"Code match {i}:\n```\n{match_}\n```" for i, (match_, score) in enumerate(best_matches)]) error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify one of the following pieces of code instead?\n{best_matches_string}\n\n\n" @@ -244,8 +244,6 @@ def get_error_message( else: error_message += f"\nThe file `{file_change_request.filename}` does not exist. Double-check your spelling.\n\n\n" error_indices.append(i) - # if error_message: - # breakpoint() return error_message, error_indices def sort_and_fuse_snippets( From bb0c69f77d761fae7c8484fd6e51b469258720fb Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 21:55:00 +0000 Subject: [PATCH 08/22] Whitespace fixes --- sweepai/agents/modify.py | 23 +++++++++++++++-------- sweepai/utils/modify_utils.py | 4 ++-- sweepai/utils/utils.py | 1 - 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index fafd7ce93e..a25eed4e79 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -446,7 +446,7 @@ def test_multiply_negative_by_negative(self): Then, call the make_change function to fix the linter warnings. If the warning cannot be resolved, call submit_task with an explanation of the issue.""" -fix_syntax_prompt = """You must resolve the issue by following these steps: +fix_syntax_prompt = """You MUST resolve the issue by following these steps: # 1. Thinking @@ -457,7 +457,7 @@ def test_multiply_negative_by_negative(self): # 2. Function call -Reinvoke the make_change function call with different changes that yields valid code.""" +Then, reinvoke the make_change function call with different changes that yields valid code.""" ORIGINAL_CODE_NOT_FOUND_PROMPT = """The original_code provided does not appear to be present in file {file_path}. Your provided original_code erroneously contains: ``` @@ -554,7 +554,7 @@ def rstrip_lines(text: str) -> str: return "\n".join([line.rstrip() for line in text.split("\n")]) def indent(text: str, spaces: int) -> str: - return "\n".join([f"{' ' * spaces}{line}" for line in text.split("\n")]) + return "\n".join([f"{' ' * spaces}{line}" if line.strip() else "" for line in text.split("\n")]) def tokenize_code(code: str): cleaned_code = "" @@ -675,7 +675,11 @@ def contains_ignoring_whitespace(needle: str, haystack: str): for indent_size in range(0, max_indent + 2, 2): indented_needle = indent(needle, indent_size) if indented_needle in haystack: - return True + start_char = haystack.index(indented_needle) + start_line = haystack[:start_char].count("\n") + end_char = start_char + len(indented_needle) + 1 + end_line = haystack[:end_char].count("\n") + return start_line, end_line return False MODEL = "claude-3-haiku-20240307" @@ -1318,8 +1322,6 @@ def handle_function_call( second_diff_text = surrounding_lines_before + START_MARKER + best_match + END_MARKER + surrounding_lines_after best_match_diff = generate_diff(first_diff_text, second_diff_text, n=20) # this is bounded to 14 * 2 lines of context error_message = f"The original_code provided does not appear to be present in file {file_name}. Your provided original_code contains:\n```\n{tool_call['original_code']}\n```\nDid you mean the following?\n```\n{best_match}\n```\nHere is the difference between the original_code and the most similar existing code from the file, along with its surrounding code:\n```\n{best_match_diff}\n```\n" + DID_YOU_MEAN_PROMPT - # error_message = f"The original_code provided does not appear to be present in file {file_name}. Your provided original_code contains:\n```\n{tool_call['original_code']}\n```\nHere is the diff and surrounding code:\n```\n{best_match_diff}\n```" - manual_code_check(file_contents, original_code) else: # check other files, this code should skip if there are no other files all_file_contents = list(dict.fromkeys([get_latest_contents(fcr.filename, cloned_repo, modify_files_dict) for fcr in llm_state["fcrs"] if fcr.filename != file_name])) @@ -1356,7 +1358,10 @@ def handle_function_call( else: original_code_lines = original_code.split("\n") if len(original_code_lines) > 1: - original_code = "\n".join(f'{correct_indent * " "}{line}' for line in original_code_lines) + """This will match the whitespace from the code file itself""" + best_span = contains_ignoring_whitespace(original_code, file_contents) + start_line, end_line = best_span + original_code = "\n".join(file_contents.split("\n")[start_line:end_line]) else: original_code = f'{correct_indent * " "}{original_code.lstrip()}' # before we apply changes make sure original_code is unique inside current_chunk @@ -1407,7 +1412,7 @@ def handle_function_call( if original_code not in file_contents: new_correct_indent, new_rstrip_original_code = manual_code_check(file_contents, new_code) if new_correct_indent == -1: - error_message = f"The original_code provided does not appear to be present in file {file_name}. Your provided original_code contains:\n```\n{tool_call['original_code']}\n```\nBut this section of code was not found anywhere inside the current file. DOUBLE CHECK that the change you are trying to make is not already implemented in the code!" + error_message = f"The original_code provided does not appear to be present in file {file_name}. Your provided original_code contains:\n```\n{tool_call['original_code']}\n```\nBut this section of code was not found anywhere inside the current file." else: error_message = f"The original_code provided does not appear to be present in file {file_name}. However, the new_code provided is present in the file. If you would like to apply this change, please provide the correct original_code. Otherwise, call submit_task to move on to the next task." break @@ -1437,6 +1442,8 @@ def handle_function_call( ) if failing_parse: error_message = f"Error: Invalid code changes have been applied. You requested the following changes:\n\n```diff\n{current_diff}\n```\n\nBut it produces invalid code with the following error logs:\n```\n{failing_parse}\n```\n\n" + fix_syntax_prompt + print(error_message) + breakpoint() break elif check_results_message: warning_message = check_results_message diff --git a/sweepai/utils/modify_utils.py b/sweepai/utils/modify_utils.py index b01b85a978..1a2da76c56 100644 --- a/sweepai/utils/modify_utils.py +++ b/sweepai/utils/modify_utils.py @@ -85,14 +85,14 @@ def manual_code_check(file_contents: str, code_snippet: str) -> tuple[int, bool] # assume one indent is two spaces and check max 10 indents for indent in range(0, 40, 2): - new_code_lines = [f"{' ' * indent}{line}" for line in code_lines] + new_code_lines = [f"{' ' * indent}{line}" if line.strip() else "" for line in code_lines] new_code = "\n".join(new_code_lines) if new_code in file_contents: return indent, False # sometimes llm returns code with trailing whitespace, if we have reached here check again but strip all trailing whitespace code_lines = [line.rstrip() for line in code_snippet.split("\n")] for indent in range(0, 40, 2): - new_code_lines = [f"{' ' * indent}{line}" for line in code_lines] + new_code_lines = [f"{' ' * indent}{line}" if line.strip() else "" for line in code_lines] new_code = "\n".join(new_code_lines) if new_code in file_contents: return indent, True diff --git a/sweepai/utils/utils.py b/sweepai/utils/utils.py index cc6ce338be..f4fa895e35 100644 --- a/sweepai/utils/utils.py +++ b/sweepai/utils/utils.py @@ -430,7 +430,6 @@ def get_pylint_check_results(file_path: str, code: str) -> CheckResults: "--disable=R", "--disable=import-error", "--disable=no-member", - "--disable=unused-import" # we have a workaround for this tbh ], reporter=reporter, exit=False, From 90359972097c5749f74229e9b1324018991d65da Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 22:12:26 +0000 Subject: [PATCH 09/22] Prompt fixes --- sweepai/agents/modify.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index a25eed4e79..7300819e71 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -489,15 +489,22 @@ def test_multiply_negative_by_negative(self): # Function call Then, follow up with a make_change function call with the corrected parameters. If you are unable to find the correct section of code, call the submit_task function with an explanation of the issue.""" -MULTIPLE_OCCURRENCES_PROMPT = """Resolve this error by following these steps: +MULTIPLE_OCCURRENCES_PROMPT = """You MUST resolve this error by following these steps: # 1. Thinking a. Identify whether you want to replace all occurrences of the original code or only a specific one. If you want to replace all occurrences, you can use the replace_all flag by adding true to the function arguments. b. If you want to replace only a specific occurrence, which occurrence you want to replace and the corresponding surrounding context, following this format: + +Corrected original code: ``` The original_code block you want to replace with surrounding context. ``` + +Corrected new code: +``` +The new_code block you want to replace with the same surrounding context. +``` # 2. Function Call From 1a10a6b48536c463ba031e80508617a800a77031 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 22:12:41 +0000 Subject: [PATCH 10/22] Pylint diff fixes --- sweepai/utils/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sweepai/utils/utils.py b/sweepai/utils/utils.py index f4fa895e35..4a7cfc5405 100644 --- a/sweepai/utils/utils.py +++ b/sweepai/utils/utils.py @@ -222,7 +222,7 @@ def get_new_lint_errors_for_pylint(new_errors: str, old_errors: str) -> str: results = [] for line in additional_errors: _file_delimiter, error_type, *_ = line.split(" ") - if not error_type.startswith("E") and old_error_types.count(error_type) < 2: # if there are more than 1 of the same error, we consider it new + if error_type.startswith("E") or old_error_types.count(error_type) < 2: # if there are more than 1 of the same error, we consider it new results.append(line) return "\n".join(results) @@ -447,16 +447,16 @@ def get_pylint_check_results(file_path: str, code: str) -> CheckResults: logger.debug("Done running pylint.") return CheckResults(pylint=error_message if not succeeded else "") -@file_cache() def get_check_results(file_path: str, code: str) -> CheckResults: is_valid, error_message = check_syntax(file_path, code) if not is_valid: return CheckResults(parse_error_message=error_message) - ext = file_path.split(".")[-1] # noqa + ext = file_path.rsplit(".")[-1] # noqa if ext == "py": try: return get_pylint_check_results(file_path, code) except Exception as e: + breakpoint() logger.exception(e) elif ext in ["js", "jsx", "ts", "tsx"]: # see if eslint is installed From 77d0f4000712d1659df961adf75f7364a863a760 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 22:18:27 +0000 Subject: [PATCH 11/22] Find best matches --- sweepai/agents/modify.py | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index 7300819e71..fbcfb7b200 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -575,39 +575,6 @@ def tokenize_code(code: str): def code_processor(code: str): return " ".join(tokenize_code(code)) -# def find_best_match(needle: str, haystack: str, threshold: int = 60, verbose=True, tokenized=False): -# best_match = 0 -# best_score = 0 -# file_contents_lines = haystack.split("\n") -# num_lines = len(file_contents_lines) -# num_match_lines = len(needle.split("\n")) -# for start_line in tqdm(range(num_lines), total=num_lines) if verbose else range(num_lines): -# potential_choices = [] -# for end_line in range(start_line + max(1, num_match_lines - 10), start_line + num_match_lines + 10): -# if end_line > num_lines: -# break -# potential_choice = "\n".join(file_contents_lines[start_line:end_line]) -# potential_choices.append(potential_choice) - -# results = process.extractOne( -# needle, -# potential_choices, -# scorer=fuzz.QRatio, -# score_cutoff=threshold, -# processor=tokenize_code if tokenized else None, -# ) - -# if results is not None: -# choice, score, _index = results - -# if score > best_score: -# best_score = score -# best_match = choice - -# if best_score > threshold: -# return best_match, best_score -# return "", 0 - def find_best_matches( needle: str, haystack: str, From ebd80b6e29c88f80b0bdd7b48890ebdcda7ec13e Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 22:25:23 +0000 Subject: [PATCH 12/22] Fixed off-by-one error --- sweepai/agents/modify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index fbcfb7b200..6d380ba27e 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -651,8 +651,7 @@ def contains_ignoring_whitespace(needle: str, haystack: str): if indented_needle in haystack: start_char = haystack.index(indented_needle) start_line = haystack[:start_char].count("\n") - end_char = start_char + len(indented_needle) + 1 - end_line = haystack[:end_char].count("\n") + end_line = start_line + indented_needle.count("\n") + 1 return start_line, end_line return False @@ -1457,6 +1456,7 @@ def handle_function_call( # breakpoint() modify_files_dict[file_name]['contents'] = new_file_contents llm_state["attempt_lazy_change"] = False # no longer attempt lazy change + # breakpoint() elif llm_state["completed_changes_per_fcr"][current_fcr_index] + 1 < llm_state["changes_per_fcr"][current_fcr_index]: # Incomplete changes, should use a different prompt realistically llm_response = f"SUCCESS\n\nThe following changes have been applied:\n\n```diff\n{generate_diff(file_contents, new_file_contents, n=25)}\n```\n{self_review_prompt.format(current_task=llm_state['current_task'])}" From 64c7d998997e279e5d44246a71d8c524774e3e9f Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 23:06:55 +0000 Subject: [PATCH 13/22] Fixed anthropic trailing new lines --- sweepai/agents/modify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index 6d380ba27e..d7cea87c2c 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -848,8 +848,8 @@ def get_replaces_per_fcr(fcr: FileChangeRequest) -> int: def parse_fcr(fcr: FileChangeRequest): flags = "" justification, *_ = fcr.instructions.split("", 1) - original_code_pattern = r"\n(.*?)" - new_code_pattern = r"\n(.*?)" + original_code_pattern = r"\s*\n(.*?)" + new_code_pattern = r"\s*\n(.*?)" original_code_matches = list(re.finditer(original_code_pattern, fcr.instructions, re.DOTALL)) new_code_matches = list(re.finditer(new_code_pattern, fcr.instructions, re.DOTALL)) replace_all_pattern = r"true" From b63cee26c4d2e39d64dec64f19d6a0ac09c3c2b1 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 23:07:04 +0000 Subject: [PATCH 14/22] Improved auto-fix prompt --- sweepai/core/prompts.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sweepai/core/prompts.py b/sweepai/core/prompts.py index 1c96fc59a8..f6cef4348a 100644 --- a/sweepai/core/prompts.py +++ b/sweepai/core/prompts.py @@ -316,9 +316,11 @@ Otherwise, you must patch the task to resolve the error like so: - + Rewritten instructions to resolve the error. Update the original_code and new_code blocks as required, ensuring that the block contains the actual code from the file. + +The index should be equivalent to the error number. [additional blocks as needed, for the same file or different files] @@ -443,7 +445,7 @@ Step 1. Reference the original code in tags, copying them VERBATIM from the file, with correct indentation and whitespace. - Do NOT paraphrase or abbreviate the source code. - Placeholder comments like "# existing code" are not permitted. - - Minimum one function for context. + - Start with a function header. Step 2. Write the new code in tags, specifying necessary imports and including relevant type definitions, interfaces, and schemas. - BE EXACT as this code will replace the mentioned . Step 3. Determine if this is a change that occurs EXACTLY in other parts of the same file. If so, add a true flag. @@ -498,12 +500,12 @@ Then, based on the analysis, propose a fix by following the format below. If the error has already been fixed, you can skip this step. - + Instructions for modifying one section of the file. Each block must have exactly one original_code and one new_code block. Do not make a change that has already been made by the intern. a. Describe the section of code that needs to be modified, i.e. the test case that checks if `foo` == `bar`. -Copy the original_code here VERBATIM from the file. Do NOT paraphrase or abbreviate the source code. Placeholder comments like "# existing code" are not permitted. Minimum one function. +Copy the original_code here VERBATIM from the file. Do NOT paraphrase or abbreviate the source code. Placeholder comments like "# existing code" are not permitted. Start with a function header. b. Describe the changes that need to be made to the code, i.e. the test case should instead check if `foo` != `baz`. From e71f00232e397da16ab6e4a714107e7d4b88dac4 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 23:20:50 +0000 Subject: [PATCH 15/22] Cleanup --- sweepai/core/sweep_bot.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sweepai/core/sweep_bot.py b/sweepai/core/sweep_bot.py index d9a59a227f..0828cecc62 100644 --- a/sweepai/core/sweep_bot.py +++ b/sweepai/core/sweep_bot.py @@ -180,9 +180,6 @@ def get_error_message( file_change_requests: list[FileChangeRequest], cloned_repo: ClonedRepo, ): - """ - TODO: - """ error_message = "" error_indices = [] for i, file_change_request in enumerate(file_change_requests): @@ -192,11 +189,11 @@ def get_error_message( parsed_fcr = parse_fcr(file_change_request) if not parsed_fcr["original_code"]: # breakpoint() - error_message += f"\nYou forgot to provide both an block. If you would like to drop this task use the marker.\n\n\n" + error_message += f"\nYou forgot to provide both an block. Here is what you provided in the instructions:\n```\n{file_change_request.instructions}\n```\nIf you would like to drop this task use the marker.\n\n\n" error_indices.append(i) continue if not parsed_fcr["new_code"]: - error_message += f"\nYou forgot to a block. If you would like to drop this task use the marker.\n\n\n" + error_message += f"\nYou forgot to a block. Here is what you provided in the instructions:\n```\n{file_change_request.instructions}\n```\nIf you would like to drop this task use the marker.\n\n\n" error_indices.append(i) continue original_code = parsed_fcr["original_code"][0].strip("\n") @@ -244,6 +241,8 @@ def get_error_message( else: error_message += f"\nThe file `{file_change_request.filename}` does not exist. Double-check your spelling.\n\n\n" error_indices.append(i) + # if error_message: + # breakpoint() return error_message, error_indices def sort_and_fuse_snippets( From dfb6db874dc68f1aa06e6c378e77e4fd68385e54 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 23:20:56 +0000 Subject: [PATCH 16/22] GHA Fix improvement --- sweepai/core/prompts.py | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/sweepai/core/prompts.py b/sweepai/core/prompts.py index f6cef4348a..01e5aedc0d 100644 --- a/sweepai/core/prompts.py +++ b/sweepai/core/prompts.py @@ -288,27 +288,10 @@ You will first think step-by-step about the error, and then either rewrite the instructions with the corrected fix, or drop the task. -Analyze what went wrong, including the file path and the specific code block that needs to be modified. The fix for error #1. - -Strategies: -- For " does not exist in the file" errors: - - Look closely and carefully at the actual contents of the file. Are there any missing indentation, whitespace or comments? - - Look closely at similar files, could you have selected the wrong file? -- For empty blocks: - - First, look closely at the file to determine where to make the change. Then, copy that code into the . Then, copy the code into with the code you would like to add before or after the code in the block to prepend or append code. - -Update with the necessary changes: - -The corrected code from the file verbatim. Abbreviating, missing indents, paraphrasing and placeholder code are NOT permitted. It is absolutely critical that the indentation is correct and matches the source code EXACTLY. - - -Update block with the necessary changes: - -Updated new code, based on the corrections in . Ensure all newly introduced indents and comments are propagated here. - +Analyze what went wrong, including the file path and the specific code block that needs to be modified in great detail. If you have failed to copy code verbatim, indicate precisely what is different between the code you provided and the code in the actual file. -Let's resolve the errors in your proposed plan: +Then, let's resolve the errors in your proposed plan: If you determine that this task is not needed, you may drop the task like so: @@ -318,6 +301,16 @@ Rewritten instructions to resolve the error. Update the original_code and new_code blocks as required, ensuring that the block contains the actual code from the file. + +Update with the necessary changes: + +The corrected code from the file verbatim. Abbreviating, missing indents, paraphrasing and placeholder code are NOT permitted. It is absolutely critical that the indentation is correct and matches the source code EXACTLY. + + +Update block with the necessary changes: + +Updated new code, based on the corrections in . Ensure all newly introduced indents and comments are propagated here. + The index should be equivalent to the error number. From 49a67c55bc3d1ae023230908b6b1a9c9f8de98f1 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 23:32:56 +0000 Subject: [PATCH 17/22] Multiple auto-fix attempts --- sweepai/core/sweep_bot.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/sweepai/core/sweep_bot.py b/sweepai/core/sweep_bot.py index 0828cecc62..c0b74224f7 100644 --- a/sweepai/core/sweep_bot.py +++ b/sweepai/core/sweep_bot.py @@ -220,12 +220,13 @@ def get_error_message( error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify the following code instead?\n```\n{best_match}\n```\nHere is the diff between your proposed and the most similar code in the file:\n```diff\n{generate_diff(indent(original_code, best_indent), best_match)}\n```\n\n\n" elif best_score > 50: best_matches = find_best_matches(original_code, file_contents, threshold=threshold, tokenized=True) + ellipses_message = "You must copy code out in full and may not use ellipses, abbreviations, or any short-hand notation in your code." if "... " in original_code else "" if len(best_matches) > 1: best_matches_string = "\n\n".join([f"Code match {i}:\n```\n{match_}\n```" for i, (match_, score) in enumerate(best_matches)]) - error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify one of the following pieces of code instead?\n{best_matches_string}\n\n\n" + error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify one of the following pieces of code instead?\n{best_matches_string}\n{ellipses_message}\n\n" else: # Same as case > 80 - error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify the following code instead?\n```\n{best_match}\n```\nHere is the diff between your proposed and the most similar code in the file:\n```diff\n{generate_diff(indent(original_code, best_indent), best_match)}\n```\n\n\n" + error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify the following code instead?\n```\n{best_match}\n```\nHere is the diff between your proposed and the most similar code in the file:\n```diff\n{generate_diff(indent(original_code, best_indent), best_match)}\n```\n{ellipses_message}\n\n" else: error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify the following code instead?\n```\n{best_match}\n```\n\n\n" else: @@ -494,7 +495,9 @@ def get_files_to_change( error_message, error_indices = get_error_message(file_change_requests, cloned_repo) - if error_message: + for _ in range(3): + if not error_message: + break fix_attempt = chat_gpt.chat_anthropic( content=fix_files_to_change_prompt.format(error_message=error_message), model=MODEL, @@ -512,9 +515,9 @@ def get_files_to_change( logger.warning(f"Index {drop} not in error indices") continue file_change_requests.pop(error_indices[drop]) - new_error_message, new_error_indices = get_error_message(file_change_requests, cloned_repo) logger.debug("Old indices", error_indices) - logger.debug("New indices", new_error_indices) + error_message, error_indices = get_error_message(file_change_requests, cloned_repo) + logger.debug("New indices", error_indices) validate_file_change_requests(file_change_requests, cloned_repo) return file_change_requests, files_to_change_response @@ -1066,10 +1069,11 @@ def get_files_to_change_for_gha( file_change_request.raw_relevant_files = " ".join(relevant_modules) file_change_requests.append(file_change_request) - # Auto-fix plan, should do this multiple times but once works for now. error_message, error_indices = get_error_message(file_change_requests, cloned_repo) - if error_message: + for _ in range(3): + if not error_message: + break fix_attempt = chat_gpt.chat_anthropic( content=fix_files_to_change_prompt.format(error_message=error_message), model=MODEL, @@ -1087,9 +1091,10 @@ def get_files_to_change_for_gha( logger.warning(f"Index {drop} not in error indices") continue file_change_requests.pop(error_indices[drop]) - new_error_message, new_error_indices = get_error_message(file_change_requests, cloned_repo) logger.debug("Old indices", error_indices) - logger.debug("New indices", new_error_indices) + error_message, error_indices = get_error_message(file_change_requests, cloned_repo) + logger.debug("New indices", error_indices) + breakpoint() validate_file_change_requests(file_change_requests, cloned_repo) return file_change_requests, files_to_change_response From 738921c2feb8eeff4e0b27821fe38857c4cde61b Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 23:36:17 +0000 Subject: [PATCH 18/22] Decreased numbers --- sweepai/agents/modify.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index d7cea87c2c..e675c78977 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -1086,7 +1086,7 @@ def modify( )) # if previous things go wrong we make llm call if not function_calls_string: - model = MODEL if llm_state["attempt_count"] < 5 else SLOW_MODEL + model = MODEL if llm_state["attempt_count"] < 3 else SLOW_MODEL logger.info(f"Using model: {model}") function_calls_string = chat_gpt.chat_anthropic( content=function_output, @@ -1095,9 +1095,9 @@ def modify( use_openai=use_openai, ) if function_calls_string in llm_state["visited_set"]: - if llm_state["attempt_count"] < 5: + if llm_state["attempt_count"] < 3: logger.warning(f"Function call {function_calls_string} has already been visited, retrying with a different model.") - llm_state["attempt_count"] = 5 + llm_state["attempt_count"] = 3 function_calls_string = chat_gpt.chat_anthropic( content=SLOW_MODEL, model=model, From 0462cc827f0ada6e4ab2bc13e48c9f5fce1dab31 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 23:36:47 +0000 Subject: [PATCH 19/22] GHA Fix cleanup --- sweepai/core/prompts.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sweepai/core/prompts.py b/sweepai/core/prompts.py index 01e5aedc0d..dd17dac4b6 100644 --- a/sweepai/core/prompts.py +++ b/sweepai/core/prompts.py @@ -293,11 +293,7 @@ Then, let's resolve the errors in your proposed plan: -If you determine that this task is not needed, you may drop the task like so: - -Index of the task to drop - -Otherwise, you must patch the task to resolve the error like so: +If you would like patch the corresponding task of the plan, create a modify block with an index. The index should be equivalent to the error number of this error_resolution block. Rewritten instructions to resolve the error. Update the original_code and new_code blocks as required, ensuring that the block contains the actual code from the file. @@ -313,7 +309,9 @@ -The index should be equivalent to the error number. +Otherwise, if you absolutely cannot resolve the error, drop the task like so: + +Index of the task to drop [additional blocks as needed, for the same file or different files] From 499740456a040658973c6171c3a2d34e2446d8d1 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 23:52:43 +0000 Subject: [PATCH 20/22] Prompt improvements --- sweepai/core/prompts.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sweepai/core/prompts.py b/sweepai/core/prompts.py index dd17dac4b6..536eb45004 100644 --- a/sweepai/core/prompts.py +++ b/sweepai/core/prompts.py @@ -283,19 +283,19 @@ For each error, identify what went wrong and what the fix is. Analyze the contents of the provided file path to find the correct code block that needs to be modified. Update the block with the actual code from the file, and then provide the necessary changes in the block. Follow the format: -Error #1: Description of the error +Error #0: Description of the error You will first think step-by-step about the error, and then either rewrite the instructions with the corrected fix, or drop the task. -Analyze what went wrong, including the file path and the specific code block that needs to be modified in great detail. If you have failed to copy code verbatim, indicate precisely what is different between the code you provided and the code in the actual file. +Analyze extremely carefully in great detail what went wrong, including the file path and the specific code block that needs to be modified. If you have failed to copy code verbatim, indicate precisely what is different between the code you provided and the code in the actual file. Then, let's resolve the errors in your proposed plan: If you would like patch the corresponding task of the plan, create a modify block with an index. The index should be equivalent to the error number of this error_resolution block. - + Rewritten instructions to resolve the error. Update the original_code and new_code blocks as required, ensuring that the block contains the actual code from the file. Update with the necessary changes: From d6fe6460064c707d52208fdfcefecf2da8f78dba Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 23:53:00 +0000 Subject: [PATCH 21/22] Changes in diff sizes --- sweepai/core/sweep_bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sweepai/core/sweep_bot.py b/sweepai/core/sweep_bot.py index c0b74224f7..0e56d1cb7d 100644 --- a/sweepai/core/sweep_bot.py +++ b/sweepai/core/sweep_bot.py @@ -217,7 +217,7 @@ def get_error_message( continue if best_score > threshold: if best_score > 80: - error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify the following code instead?\n```\n{best_match}\n```\nHere is the diff between your proposed and the most similar code in the file:\n```diff\n{generate_diff(indent(original_code, best_indent), best_match)}\n```\n\n\n" + error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify the following code instead?\n```\n{best_match}\n```\nHere is the diff between your proposed and the most similar code in the file:\n```diff\n{generate_diff(indent(original_code, best_indent), best_match, n=10)}\n```\n\n\n" elif best_score > 50: best_matches = find_best_matches(original_code, file_contents, threshold=threshold, tokenized=True) ellipses_message = "You must copy code out in full and may not use ellipses, abbreviations, or any short-hand notation in your code." if "... " in original_code else "" @@ -226,7 +226,7 @@ def get_error_message( error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify one of the following pieces of code instead?\n{best_matches_string}\n{ellipses_message}\n\n" else: # Same as case > 80 - error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify the following code instead?\n```\n{best_match}\n```\nHere is the diff between your proposed and the most similar code in the file:\n```diff\n{generate_diff(indent(original_code, best_indent), best_match)}\n```\n{ellipses_message}\n\n" + error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify the following code instead?\n```\n{best_match}\n```\nHere is the diff between your proposed and the most similar code in the file:\n```diff\n{generate_diff(indent(original_code, best_indent), best_match, n=10)}\n```\n{ellipses_message}\n\n" else: error_message += f"\n does not exist in `{file_change_request.filename}`. Your proposed contains:\n```\n{indent(original_code, best_indent)}\n```\nDid you mean to modify the following code instead?\n```\n{best_match}\n```\n\n\n" else: From 74489417b03485aeb64e5605f9c7319125ad6745 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Mon, 29 Apr 2024 23:55:16 +0000 Subject: [PATCH 22/22] Removed breakpoint --- sweepai/agents/modify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sweepai/agents/modify.py b/sweepai/agents/modify.py index 5834c76a61..a9008032dd 100644 --- a/sweepai/agents/modify.py +++ b/sweepai/agents/modify.py @@ -1415,8 +1415,8 @@ def handle_function_call( ) if failing_parse: error_message = f"Error: Invalid code changes have been applied. You requested the following changes:\n\n```diff\n{current_diff}\n```\n\nBut it produces invalid code with the following error logs:\n```\n{failing_parse}\n```\n\n" + fix_syntax_prompt - print(error_message) - breakpoint() + # print(error_message) + # breakpoint() break elif check_results_message: warning_message = check_results_message