From fa3283802ac607ddf132f0bd29b033428111ddbd Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 11 Jul 2023 14:56:36 -0700 Subject: [PATCH] aider: Add --openai-api-type, --openai-api-version, and openai-api-deployment-id args, pass them into coder.create. # Aider chat conversation: USER: add --openai-api-type --openai-api-version and openai-api-deployment-id args. pass them into coder.create ASSISTANT: To add the `--openai-api-type`, `--openai-api-version`, and `--openai-api-deployment-id` arguments and pass them into `coder.create`, we need to modify the `aider/main.py` file. Here are the steps: 1. Add the new arguments to the argument parser in the `main` function. 2. Pass these arguments to the `coder.create` function. Here are the changes: ```python aider/main.py <<<<<<< ORIGINAL ########## model_group = parser.add_argument_group("Advanced Model Settings") model_group.add_argument( "--openai-api-base", metavar="OPENAI_API_BASE", default="https://api.openai.com/v1", help="Specify the OpenAI API base endpoint (default: https://api.openai.com/v1)", ) ======= ########## model_group = parser.add_argument_group("Advanced Model Settings") model_group.add_argument( "--openai-api-base", metavar="OPENAI_API_BASE", default="https://api.openai.com/v1", help="Specify the OpenAI API base endpoint (default: https://api.openai.com/v1)", ) model_group.add_argument( "--openai-api-type", metavar="OPENAI_API_TYPE", help="Specify the OpenAI API type", ) model_group.add_argument( "--openai-api-version", metavar="OPENAI_API_VERSION", help="Specify the OpenAI API version", ) model_group.add_argument( "--openai-api-deployment-id", metavar="OPENAI_API_DEPLOYMENT_ID", help="Specify the OpenAI API deployment ID", ) >>>>>>> UPDATED ``` ```python aider/main.py <<<<<<< ORIGINAL coder = Coder.create( main_model, args.edit_format, io, args.openai_api_key, args.openai_api_base, ## fnames=args.files, 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, ) ======= coder = Coder.create( main_model, args.edit_format, io, args.openai_api_key, args.openai_api_base, ## fnames=args.files, 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, openai_api_type=args.openai_api_type, openai_api_version=args.openai_api_version, openai_api_deployment_id=args.openai_api_deployment_id, ) >>>>>>> UPDATED ``` Please note that these changes assume that the `Coder.create` method and the `Coder` class are prepared to receive and handle these new arguments. If they are not, additional changes will be needed in the `Coder` class and its subclasses. --- aider/main.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/aider/main.py b/aider/main.py index b2a584aa7..c5732c415 100644 --- a/aider/main.py +++ b/aider/main.py @@ -78,6 +78,21 @@ def main(args=None, input=None, output=None): default="https://api.openai.com/v1", help="Specify the OpenAI API base endpoint (default: https://api.openai.com/v1)", ) + model_group.add_argument( + "--openai-api-type", + metavar="OPENAI_API_TYPE", + help="Specify the OpenAI API type", + ) + model_group.add_argument( + "--openai-api-version", + metavar="OPENAI_API_VERSION", + help="Specify the OpenAI API version", + ) + model_group.add_argument( + "--openai-api-deployment-id", + metavar="OPENAI_API_DEPLOYMENT_ID", + help="Specify the OpenAI API deployment ID", + ) model_group.add_argument( "--edit-format", metavar="EDIT_FORMAT", @@ -351,6 +366,9 @@ def main(args=None, input=None, output=None): code_theme=args.code_theme, stream=args.stream, use_git=args.git, + openai_api_type=args.openai_api_type, + openai_api_version=args.openai_api_version, + openai_api_deployment_id=args.openai_api_deployment_id, ) if args.dirty_commits: