From 2bdfdb11bb876dba2e60caf5378715c1d33b9517 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 4 Jun 2023 13:44:04 -0700 Subject: [PATCH] Don't add gpt-3.5 replies to the history if they contain edits --- aider/coder.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index 3096cf836..f11433753 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -110,6 +110,9 @@ class Coder: if self.repo_map.has_ctags: self.io.tool_output("Using ctags to build repo-map.") + for fname in self.get_inchat_relative_files(): + self.io.tool_output(f"Added {fname} to the chat.") + def find_common_root(self): if self.abs_fnames: common_prefix = os.path.commonpath(list(self.abs_fnames)) @@ -138,8 +141,6 @@ class Coder: if fname.is_dir(): continue - self.io.tool_output(f"Added {fname} to the chat.") - fname = fname.resolve() self.abs_fnames.add(str(fname)) @@ -313,18 +314,21 @@ class Coder: self.io.tool_error("\n\n^C KeyboardInterrupt") content += "\n^C KeyboardInterrupt" - self.cur_messages += [ - dict(role="assistant", content=content), - ] - self.io.tool_output() if interrupted: + self.cur_messages += [dict(role="assistant", content=content)] return edited, edit_error = self.apply_updates(content) if edit_error: return edit_error + if self.main_model == "gpt=4" or (self.main_model == "gpt-3.5-turbo" and not edited): + # Don't add assistant messages to the history if they contain "edits" + # Because those edits are actually fully copies of the file! + # That wastes too much context window. + self.cur_messages += [dict(role="assistant", content=content)] + if edited and self.auto_commits: self.auto_commit()