reflect multiple messages; do not strip edit error messages

This commit is contained in:
Paul Gauthier 2024-05-11 16:40:37 -07:00
parent 0f9e314bb2
commit 90c0a5b9a4
3 changed files with 15 additions and 10 deletions

View file

@ -738,6 +738,9 @@ class Coder:
add_rel_files_message = self.check_for_file_mentions(content)
if add_rel_files_message:
if self.reflected_message:
self.reflected_message += "\n\n" + add_rel_files_message
else:
self.reflected_message = add_rel_files_message
def update_cur_messages(self, edited):
@ -1099,13 +1102,13 @@ class Coder:
self.io.tool_error(f"Malformed response #{self.apply_update_errors}, retrying...")
self.io.tool_error("https://aider.chat/docs/faq.html#aider-isnt-editing-my-files")
for line in str(err).splitlines():
self.io.tool_error(line)
self.io.tool_error(line, strip=False)
return None, err
else:
self.io.tool_error(f"Malformed response #{self.apply_update_errors}, aborting.")
self.io.tool_error("https://aider.chat/docs/faq.html#aider-isnt-editing-my-files")
for line in str(err).splitlines():
self.io.tool_error(line)
self.io.tool_error(line, strip=False)
return False, None
except git.exc.GitCommandError as err:

View file

@ -475,7 +475,7 @@ Hope you like it!
print(list(find_original_update_blocks(edit)))
def find_similar_lines(search_lines, content_lines, threshold=0.8):
def find_similar_lines(search_lines, content_lines, threshold=0.9):
search_lines = search_lines.splitlines()
content_lines = content_lines.splitlines()

View file

@ -1,7 +1,7 @@
import base64
import os
from collections import defaultdict
from datetime import datetime
import base64
from pathlib import Path
from prompt_toolkit.completion import Completer, Completion
@ -16,8 +16,8 @@ from pygments.util import ClassNotFound
from rich.console import Console
from rich.text import Text
from .utils import is_image_file
from .dump import dump # noqa: F401
from .utils import is_image_file
class AutoCompleter(Completer):
@ -141,12 +141,11 @@ class InputOutput:
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
self.append_chat_history(f"\n# aider chat started at {current_time}\n\n")
def read_image(self, filename):
try:
with open(str(filename), "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
return encoded_string.decode('utf-8')
return encoded_string.decode("utf-8")
except FileNotFoundError:
self.tool_error(f"{filename}: file not found error")
return
@ -326,11 +325,14 @@ class InputOutput:
return res
def tool_error(self, message):
def tool_error(self, message, strip=True):
self.num_error_outputs += 1
if message.strip():
hist = f"{message.strip()}"
if strip:
hist = message.strip()
else:
hist = message
self.append_chat_history(hist, linebreak=True, blockquote=True)
message = Text(message)