diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 7a0b40181..52de85ed4 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -419,8 +419,8 @@ class Coder: ] main_sys = self.gpt_prompts.main_system - if self.main_model.max_context_tokens > 4 * 1024: - main_sys += "\n" + self.fmt_system_reminder() + # if self.main_model.max_context_tokens > 4 * 1024: + main_sys += "\n" + self.fmt_system_reminder() messages = [ dict(role="system", content=main_sys), @@ -481,10 +481,13 @@ class Coder: self.update_cur_messages(content, edited) if edited: - if self.auto_commits and not self.dry_run: + if self.repo and self.auto_commits and not self.dry_run: saved_message = self.auto_commit() + elif hasattr(self.gpt_prompts, "files_content_gpt_edits_no_repo"): + saved_message = self.gpt_prompts.files_content_gpt_edits_no_repo else: saved_message = None + self.move_back_cur_messages(saved_message) add_rel_files_message = self.check_for_file_mentions(content) diff --git a/aider/coders/base_prompts.py b/aider/coders/base_prompts.py index 756089bd1..720692c51 100644 --- a/aider/coders/base_prompts.py +++ b/aider/coders/base_prompts.py @@ -1,6 +1,8 @@ class CoderPrompts: files_content_gpt_edits = "I committed the changes with git hash {hash} & commit msg: {message}" + files_content_gpt_edits_no_repo = "I updated the files." + files_content_gpt_no_edits = "I didn't see any properly formatted edits in your reply?!" files_content_local_edits = "I edited the files myself." diff --git a/aider/coders/editblock_func_coder.py b/aider/coders/editblock_func_coder.py index 64c518bad..8b19ca683 100644 --- a/aider/coders/editblock_func_coder.py +++ b/aider/coders/editblock_func_coder.py @@ -64,6 +64,20 @@ class EditBlockFunctionCoder(Coder): self.gpt_prompts = EditBlockFunctionPrompts() super().__init__(*args, **kwargs) + def update_cur_messages(self, content, edited): + if self.partial_response_content: + self.cur_messages += [dict(role="assistant", content=self.partial_response_content)] + if self.partial_response_function_call: + self.cur_messages += [ + dict( + role="assistant", + content=None, + function_call=self.partial_response_function_call, + ) + ] + + dump(self.cur_messages) + def render_incremental_response(self, final=False): if self.partial_response_content: return self.partial_response_content @@ -87,8 +101,8 @@ class EditBlockFunctionCoder(Coder): edited = set() for edit in edits: path = get_arg(edit, "path") - original = get_arg(edit, "original_lines") - updated = get_arg(edit, "updated_lines") + original = "\n".join(get_arg(edit, "original_lines")) + "\n" + updated = "\n".join(get_arg(edit, "updated_lines")) + "\n" full_path = self.allowed_to_edit(path) if not full_path: diff --git a/aider/coders/wholefile_func_prompts.py b/aider/coders/wholefile_func_prompts.py index 69be4aa74..5f6b7baf3 100644 --- a/aider/coders/wholefile_func_prompts.py +++ b/aider/coders/wholefile_func_prompts.py @@ -23,3 +23,5 @@ NEVER return code outside the `write_file` function. # TODO: should this be present for using this with gpt-4? repo_content_prefix = None + + # TODO: fix the chat history, except we can't keep the whole file diff --git a/aider/utils.py b/aider/utils.py index 61e535bc6..b7486cfc9 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -25,6 +25,10 @@ def show_messages(messages, title=None): for msg in messages: role = msg["role"].upper() - content = msg["content"].splitlines() - for line in content: - print(role, line) + content = msg.get("content") + if content: + for line in content.splitlines(): + print(role, line) + content = msg.get("function_call") + if content: + print(role, content)