mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
wip: Added ai_output
method to InputOutput
class and modified append_chat_history
method to handle linebreaks and trailing spaces.
This commit is contained in:
parent
4a8c4af902
commit
6a94c3756a
2 changed files with 14 additions and 6 deletions
|
@ -346,6 +346,7 @@ class Coder:
|
|||
except KeyboardInterrupt:
|
||||
interrupted = True
|
||||
|
||||
self.io.ai_output(self.resp)
|
||||
return self.resp, interrupted
|
||||
|
||||
def show_send_output(self, completion, silent):
|
||||
|
|
|
@ -135,16 +135,20 @@ class InputOutput:
|
|||
|
||||
prefix = "####"
|
||||
hist = inp.splitlines()
|
||||
hist = f"\n{prefix} ".join(hist)
|
||||
hist = f" \n{prefix} ".join(hist)
|
||||
|
||||
hist = f"""---
|
||||
{prefix} {hist}"""
|
||||
self.append_chat_history(hist)
|
||||
self.append_chat_history(hist, True)
|
||||
|
||||
return inp
|
||||
|
||||
# OUTPUT
|
||||
|
||||
def ai_output(self, content):
|
||||
hist = '\n' + content.strip() + '\n\n'
|
||||
self.append_chat_history(hist, False)
|
||||
|
||||
def confirm_ask(self, question, default="y"):
|
||||
if self.yes:
|
||||
res = "yes"
|
||||
|
@ -152,7 +156,7 @@ class InputOutput:
|
|||
res = prompt(question + " ", default=default)
|
||||
|
||||
hist = f"*{question.strip()} {res}*"
|
||||
self.append_chat_history(hist)
|
||||
self.append_chat_history(hist, True)
|
||||
|
||||
if not res:
|
||||
return
|
||||
|
@ -166,7 +170,7 @@ class InputOutput:
|
|||
def tool_error(self, message):
|
||||
if message.strip():
|
||||
hist = f"*{message.strip()}*"
|
||||
self.append_chat_history(hist)
|
||||
self.append_chat_history(hist, True)
|
||||
|
||||
message = Text(message)
|
||||
self.console.print(message, style="red")
|
||||
|
@ -175,13 +179,16 @@ class InputOutput:
|
|||
if messages:
|
||||
hist = " ".join(messages)
|
||||
hist = f"*{hist.strip()}*"
|
||||
self.append_chat_history(hist)
|
||||
self.append_chat_history(hist, True)
|
||||
|
||||
messages = list(map(Text, messages))
|
||||
self.console.print(*messages)
|
||||
|
||||
def append_chat_history(self, text, linebreak=True):
|
||||
def append_chat_history(self, text, linebreak):
|
||||
if linebreak:
|
||||
text = text.rstrip()
|
||||
text = text + " \n"
|
||||
if not text.endswith('\n'):
|
||||
text += '\n'
|
||||
with self.chat_history_file.open("a") as f:
|
||||
f.write(text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue