From cea9d2ae71edb9644953a72d1b3ddd5adfaa959a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 13 May 2023 07:12:02 -0700 Subject: [PATCH] aider: Updated InputOutput class to accept input and output arguments and passed them to prompt_toolkit.prompt() function. # Context: USER: we need to pass those into InputOutput and to prompt_toolkit right? ASSISTANT: Yes, you're right. We need to pass the `input` and `output` arguments to the `InputOutput` class and then to the `prompt_toolkit.prompt()` function. Here's how to modify the `aider/getinput.py` and `aider/main.py` files: In `aider/getinput.py`, update the `InputOutput` class to accept `input` and `output` arguments: ```python aider/getinput.py <<<<<<< ORIGINAL class InputOutput: def __init__(self, pretty, yes, input_history_file, chat_history_file): ======= class InputOutput: def __init__(self, pretty, yes, input_history_file, chat_history_file, input=None, output=None): self.input = input self.output = output >>>>>>> UPDATED ``` Now, update the `prompt()` function calls in the `get_input()` method to use the `input` and `output` arguments: ```python aider/getinput.py <<<<<<< ORIGINAL line = prompt( show, completer=completer_instance, history=FileHistory(self.input_history_file), style=style, reserve_space_for_menu=4, complete_style=CompleteStyle.MULTI_COLUMN, ) ======= line = prompt( show, completer=completer_instance, history=FileHistory(self.input_history_file), style=style, reserve_space_for_menu=4, complete_style=CompleteStyle.MULTI_COLUMN, input=self.input, output=self.output, ) >>>>>>> UPDATED ``` In `aider/main.py`, pass the `input` and `output` arguments to the `InputOutput` class: ```python aider/main.py <<<<<<< ORIGINAL io = InputOutput(args.pretty, args.yes, args.input_history_file, args.chat_history_file) ======= io = InputOutput(args.pretty, args.yes, args.input_history_file, args.chat_history_file, input=input, output=output) >>>>>>> UPDATED ``` These changes will ensure that the `input` and `output` arguments are passed to the `InputOutput` class and then to the `prompt_toolkit.prompt()` function. --- aider/getinput.py | 6 +++++- aider/main.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/aider/getinput.py b/aider/getinput.py index 4840cbb7f..487b438d2 100644 --- a/aider/getinput.py +++ b/aider/getinput.py @@ -54,7 +54,9 @@ class FileContentCompleter(Completer): class InputOutput: - def __init__(self, pretty, yes, input_history_file, chat_history_file): + def __init__(self, pretty, yes, input_history_file, chat_history_file, input=None, output=None): + self.input = input + self.output = output self.pretty = pretty self.yes = yes self.input_history_file = input_history_file @@ -123,6 +125,8 @@ class InputOutput: style=style, reserve_space_for_menu=4, complete_style=CompleteStyle.MULTI_COLUMN, + input=self.input, + output=self.output, ) if line.strip() == "{" and not multiline_input: multiline_input = True diff --git a/aider/main.py b/aider/main.py index 048fe6ae9..0376cae9f 100644 --- a/aider/main.py +++ b/aider/main.py @@ -88,7 +88,7 @@ def main(args=None, input=None, output=None): fnames = args.files pretty = args.pretty - io = InputOutput(args.pretty, args.yes, args.input_history_file, args.chat_history_file) + io = InputOutput(args.pretty, args.yes, args.input_history_file, args.chat_history_file, input=input, output=output) coder = Coder( args.model, fnames, pretty, args.show_diffs, args.auto_commits, io,