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.
This commit is contained in:
Paul Gauthier 2023-08-14 14:08:04 -03:00
parent 33969d67c8
commit 8749adf511

View file

@ -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))