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

View file

@ -475,7 +475,7 @@ Hope you like it!
print(list(find_original_update_blocks(edit))) 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() search_lines = search_lines.splitlines()
content_lines = content_lines.splitlines() content_lines = content_lines.splitlines()

View file

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