From 8749adf5113b1c87f423c58ffc9692a2739cc4b2 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 14 Aug 2023 14:08:04 -0300 Subject: [PATCH] aider: Add --voice-language switch with default "en" and pass it into `Coder`. # Aider chat conversation: USER: add --voice-language switch with default "en" and pass it into `Coder` ASSISTANT: To add the `--voice-language` switch, we need to modify the `aider/main.py` file. We will add the argument in the `core_group` section of the argument parser. Then, we will pass this argument to the `Coder` class. Here are the changes: ```python aider/main.py <<<<<<< HEAD core_group.add_argument( "-3", action="store_const", dest="model", const=models.GPT35_16k.name, help=f"Use {models.GPT35_16k.name} model for the main chat (gpt-4 is better)", ) ======= core_group.add_argument( "-3", action="store_const", dest="model", const=models.GPT35_16k.name, help=f"Use {models.GPT35_16k.name} model for the main chat (gpt-4 is better)", ) core_group.add_argument( "--voice-language", metavar="VOICE_LANGUAGE", default="en", help="Specify the language for voice (default: en)", ) >>>>>>> updated ``` ```python aider/main.py <<<<<<< HEAD try: coder = Coder.create( main_model, args.edit_format, io, ## fnames=fnames, git_dname=git_dname, pretty=args.pretty, show_diffs=args.show_diffs, auto_commits=args.auto_commits, dirty_commits=args.dirty_commits, dry_run=args.dry_run, map_tokens=args.map_tokens, verbose=args.verbose, assistant_output_color=args.assistant_output_color, code_theme=args.code_theme, stream=args.stream, use_git=args.git, ) except ValueError as err: io.tool_error(str(err)) return 1 ======= try: coder = Coder.create( main_model, args.edit_format, io, ## fnames=fnames, git_dname=git_dname, pretty=args.pretty, show_diffs=args.show_diffs, auto_commits=args.auto_commits, dirty_commits=args.dirty_commits, dry_run=args.dry_run, map_tokens=args.map_tokens, verbose=args.verbose, assistant_output_color=args.assistant_output_color, code_theme=args.code_theme, stream=args.stream, use_git=args.git, voice_language=args.voice_language, ) except ValueError as err: io.tool_error(str(err)) return 1 >>>>>>> updated ``` Please note that the `Coder` class and its subclasses (`EditBlockCoder`, `EditBlockFunctionCoder`, `SingleWholeFileFunctionCoder`, `WholeFileCoder`, `WholeFileFunctionCoder`) need to be updated to accept and use the `voice_language` argument. These changes are not shown here as the `Coder` class and its subclasses are not provided in the *read-write* files. --- aider/main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/aider/main.py b/aider/main.py index d11adbf54..433b87948 100644 --- a/aider/main.py +++ b/aider/main.py @@ -148,6 +148,12 @@ def main(argv=None, input=None, output=None, force_git_root=None): const=models.GPT35_16k.name, help=f"Use {models.GPT35_16k.name} model for the main chat (gpt-4 is better)", ) + core_group.add_argument( + "--voice-language", + metavar="VOICE_LANGUAGE", + default="en", + help="Specify the language for voice (default: en)", + ) ########## model_group = parser.add_argument_group("Advanced Model Settings") @@ -494,6 +500,7 @@ def main(argv=None, input=None, output=None, force_git_root=None): code_theme=args.code_theme, stream=args.stream, use_git=args.git, + voice_language=args.voice_language, ) except ValueError as err: io.tool_error(str(err))