From 66888009cf5030f7b3b794561213a27404e96384 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Thu, 20 Jun 2024 00:14:15 +0000 Subject: [PATCH] Fixed bugs --- sweepai/agents/modify_utils.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/sweepai/agents/modify_utils.py b/sweepai/agents/modify_utils.py index 8dd7b32c2a..cb5a977600 100644 --- a/sweepai/agents/modify_utils.py +++ b/sweepai/agents/modify_utils.py @@ -361,7 +361,7 @@ def test_multiply_negative_by_negative(self): {original_code} ``` -Let's fix this error by responding in the following format: +Let's fix this error by responding in the following format. Fill everything in square brackets with the actual contents. # Thinking @@ -370,17 +370,12 @@ def test_multiply_negative_by_negative(self): [additional functions] Based on these options, deterimine the most similar function header to the original_code you provided. -2. Copy the most similar section of code from the ACTUAL contents of {file_path}. Follow this format: +2. Now, copy JUST THE FIRST OR LAST TEN LINES of the ACTUAL contents of {file_path} to the previous . This will go into the parameter of the new function call. Follow this format: ``` -ACTUAL contents of {file_path} that are most similar to original_code +[JUST FIRST OR LAST TEN LINES of the ACTUAL contents of {file_path}] ``` -3. Copy the most similar section of the ACTUAL contents of {file_path} to the previous . This will go into the parameter of the new function call. Follow this format: -``` -The most similar section of the ACTUAL contents of {file_path} -``` - -4. Write the updated code, applying the changes from your previously provided section into the new parameter. This will go into the new parameter. +3. Write the updated code, applying the changes from your previously provided section into the new parameter. This will go into the new parameter. # Function call @@ -839,9 +834,9 @@ def create_tool_call_response(tool_name: str, tool_call_response_contents: str) def get_latest_contents(file_name: str, cloned_repo: ClonedRepo, modify_files_dict: dict) -> str: if file_name in modify_files_dict and "contents" in modify_files_dict[file_name]: return modify_files_dict[file_name]["contents"] - elif file_name in cloned_repo.get_file_list(): + try: return cloned_repo.get_file_contents(file_name) - else: + except FileNotFoundError: return "" def get_surrounding_lines(file_contents: str, best_match: str) -> tuple[str, str]: @@ -1207,7 +1202,6 @@ def handle_function_call( "contents": file_contents, "original_contents": file_contents, } - llm_state["fcrs"][current_fcr_index].is_completed = True if warning_message: original_code_indents = len(original_code) - len(original_code.lstrip()) new_code_indents = len(new_code) - len(new_code.lstrip()) @@ -1222,15 +1216,11 @@ def handle_function_call( # 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'])}" modify_files_dict[file_name]['contents'] = new_file_contents - llm_state["attempt_lazy_change"] = True + llm_state["attempt_lazy_change"] = False llm_state["completed_changes_per_fcr"][current_fcr_index] += 1 - elif diff_string.count("\n+") + diff_string.count("\n-") > 20: - 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\n{self_review_prompt.format(current_task=llm_state['current_task'])}" - modify_files_dict[file_name]['contents'] = new_file_contents - llm_state["attempt_lazy_change"] = False # no longer attempt lazy change else: - 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'])}" + # automatically continue case modify_files_dict[file_name]['contents'] = new_file_contents llm_response, llm_state = finish_applying_changes(modify_files_dict, llm_state, current_fcr_index) elif tool_name == "create_file":