Commit graph

531 commits

Author SHA1 Message Date
Paul Gauthier
05cdd9f2ec rename 2024-04-19 15:20:41 -07:00
Paul Gauthier
f81b62dfea Added --require-model-info 2024-04-19 14:01:02 -07:00
Paul Gauthier
aac110f078 copy 2024-04-19 13:45:51 -07:00
Paul Gauthier
6cecbd02d6 Document new model support 2024-04-19 13:18:12 -07:00
Paul Gauthier
922559a15a Refactored error handling to display model name in case of unknown model. 2024-04-19 11:17:33 -07:00
Paul Gauthier
7ec4de865d Added --weak-model 2024-04-19 10:57:21 -07:00
Paul Gauthier
93bd187bf3 Added --opus 2024-04-18 17:09:43 -07:00
Paul Gauthier
93f4a46996 reorg 2024-04-18 09:29:26 -07:00
Paul Gauthier
79170839ee noop 2024-04-18 09:24:18 -07:00
Paul Gauthier
68888faa6f Configure model settings, adopt litellm bugfix 2024-04-18 09:22:32 -07:00
Paul Gauthier
c770fc4380 cleaned up client refs 2024-04-17 15:47:07 -07:00
Paul Gauthier
c9bb22d6d5 roughed in tokenizer, dropped openai, openrouter 2024-04-17 15:22:35 -07:00
Paul Gauthier
855e787175 removed skip-model-avail-check 2024-04-17 15:02:39 -07:00
Paul Gauthier
b0245d3930 rouged in litellm 2024-04-17 14:15:24 -07:00
Paul Gauthier
7699866802 Handle missing api key without exception #559 2024-04-15 12:29:49 -07:00
Paul Gauthier
5c10944054 Abstract the default model name so it applies to scripting #537 2024-04-11 06:42:38 -07:00
Paul Gauthier
7103029abb Only redact non-null values #505 2024-03-19 12:00:00 -07:00
Paul Gauthier
0f9efc881e catch configparser errors 2024-03-10 08:22:48 -07:00
Paul Gauthier
058c237a28 Use gpt4 turbo as the default model 2024-03-08 13:13:20 -08:00
Paul Gauthier
f565057ad4 Improved logic to check for git user name/email 2024-03-08 12:37:21 -08:00
Paul Gauthier
fbc3f38256 tweaked model args 2024-03-07 13:07:02 -08:00
Paul Gauthier
cd434cac5a New --35turbo switch and docs updates 2024-02-28 14:06:44 -08:00
Paul Gauthier
5c694db19d scrub the openai key from chat history md 2024-02-26 08:30:13 -08:00
Paul Gauthier
2cdf86b479 cleanup 2024-02-24 07:13:00 -08:00
Paul Gauthier
a3285edc4f aider: Add --openai-organization-id param to set OpenAI organization ID.
# Aider chat conversation:

USER: add --openai-organization-id param that sets OpenAI(organization=...)

ASSISTANT: ```diff
--- aider/main.py
+++ aider/main.py
@@ ... @@
     model_group.add_argument(
         "--openai-api-deployment-id",
         metavar="OPENAI_API_DEPLOYMENT_ID",
         env_var="OPENAI_API_DEPLOYMENT_ID",
         help="Specify the deployment_id",
     )
+    model_group.add_argument(
+        "--openai-organization-id",
+        metavar="OPENAI_ORGANIZATION_ID",
+        env_var="OPENAI_ORGANIZATION_ID",
+        help="Specify the OpenAI organization ID",
+    )
     model_group.add_argument(
         "--openrouter",
         dest="openai_api_base",
         action="store_const",
@@ ... @@
     if args.openai_api_type == "azure":
         client = openai.AzureOpenAI(
             api_key=args.openai_api_key,
             azure_endpoint=args.openai_api_base,
             api_version=args.openai_api_version,
             azure_deployment=args.openai_api_deployment_id,
         )
     else:
         kwargs = dict()
         if args.openai_api_base:
             kwargs["base_url"] = args.openai_api_base
             if "openrouter.ai" in args.openai_api_base:
                 kwargs["default_headers"] = {
                     "HTTP-Referer": "http://aider.chat",
                     "X-Title": "Aider",
                 }
+        if args.openai_organization_id:
+            kwargs["organization"] = args.openai_organization_id

         client = openai.OpenAI(api_key=args.openai_api_key, **kwargs)

@@ ... @@
     if args.verbose:
         show = scrub_sensitive_info(parser.format_values())
         io.tool_output(show)
         io.tool_output("Option settings:")
         for arg, val in sorted(vars(args).items()):
             io.tool_output(f"  - {arg}: {scrub_sensitive_info(str(val))}")
+        if args.openai_organization_id:
+            io.tool_output(f"  - openai_organization_id: {args.openai_organization_id}")
```
This diff adds a new command-line argument `--openai-organization-id` to the `aider/main.py` file, which allows the user to specify the OpenAI organization ID. It also ensures that if this argument is provided, it is passed to the `openai.OpenAI` client initialization as the `organization` parameter. Additionally, it outputs the organization ID if verbose mode is enabled.
2024-02-24 07:11:58 -08:00
Paul Gauthier
35f812859e Rationalized openai model attributes #458 2024-02-07 12:07:30 -08:00
Paul Gauthier
174702babe Updated gpt-4 turbo model switches 2024-02-03 08:39:19 -08:00
Paul Gauthier
1317ee1ace Added --openrouter 2024-01-31 17:33:50 -08:00
Paul Gauthier
e79732dcf7 Added env_vars for all the OPENAI_ env vars 2024-01-31 15:26:53 -08:00
Zachary Vorhies
c6ced90e51
fix https://github.com/paul-gauthier/aider/issues/452
Adds option to skip the check for an update, better supports tooling which wants to do it's own update mechanism and not have aider print it out unconditionally.
2024-01-22 18:52:06 -08:00
Paul Gauthier
6a77657d95 added --4turbo and --4 aliases 2024-01-10 07:48:17 -08:00
Paul Gauthier
bd1c8b625d aider: Add --check-update to make aider check for update and return status in the exit code.
# Aider chat conversation:

USER: add --check-update to make aider check for update and return status in the exit code.

ASSISTANT: To implement the `--check-update` option, I will make the following changes:

1. Add the `--check-update` argument to the argument parser in `aider/main.py`.
2. Modify the `check_version` function in `aider/versioncheck.py` to return a boolean indicating whether an update is available.
3. Use the returned value from `check_version` in `aider/main.py` to set the exit status code when `--check-update` is used.

Here are the diffs for those changes:

```diff
--- aider/versioncheck.py
+++ aider/versioncheck.py
@@ ... @@
 def check_version(print_cmd):
     try:
         response = requests.get("https://pypi.org/pypi/aider-chat/json")
         data = response.json()
         latest_version = data["info"]["version"]
         current_version = aider.__version__

-        if packaging.version.parse(latest_version) <= packaging.version.parse(current_version):
-            return
+        is_update_available = packaging.version.parse(latest_version) > packaging.version.parse(current_version)

-        print_cmd(f"Newer version v{latest_version} is available. To upgrade, run:")
-        py = sys.executable
-        print_cmd(f"{py} -m pip install --upgrade aider-chat")
+        if is_update_available:
+            print_cmd(f"Newer version v{latest_version} is available. To upgrade, run:")
+            py = sys.executable
+            print_cmd(f"{py} -m pip install --upgrade aider-chat")
+
+        return is_update_available
     except Exception as err:
         print_cmd(f"Error checking pypi for new version: {err}")
+        return False

--- aider/main.py
+++ aider/main.py
@@ ... @@
     other_group.add_argument(
         "--version",
         action="version",
         version=f"%(prog)s {__version__}",
         help="Show the version number and exit",
     )
+    other_group.add_argument(
+        "--check-update",
+        action="store_true",
+        help="Check for updates and return status in the exit code",
+        default=False,
+    )
     other_group.add_argument(
         "--apply",
         metavar="FILE",
@@ ... @@
     check_version(io.tool_error)

+    if args.check_update:
+        update_available = check_version(lambda msg: None)
+        sys.exit(0 if not update_available else 1)
+
     if "VSCODE_GIT_IPC_HANDLE" in os.environ:
         args.pretty = False
         io.tool_output("VSCode terminal detected, pretty output has been disabled.")
```

These changes will add the `--check-update` option to the command-line interface and use the `check_version` function to determine if an update is available, exiting with status code `0` if no update is available and `1` if an update is available.

USER: UnifiedDiffNoMatch: hunk failed to apply!

aider/versioncheck.py does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in aider/versioncheck.py!

aider/versioncheck.py does not contain these 17 exact lines in a row:
```
def check_version(print_cmd):
    try:
        response = requests.get("https://pypi.org/pypi/aider-chat/json")
        data = response.json()
        latest_version = data["info"]["version"]
        current_version = aider.__version__

        if packaging.version.parse(latest_version) <= packaging.version.parse(current_version):
            return

        print_cmd(f"Newer version v{latest_version} is available. To upgrade, run:")
        py = sys.executable
        print_cmd(f"{py} -m pip install --upgrade aider-chat")
    except Exception as err:
        print_cmd(f"Error checking pypi for new version: {err}")

-- aider/main.py
```

UnifiedDiffNoMatch: hunk failed to apply!

aider/versioncheck.py does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in aider/versioncheck.py!

aider/versioncheck.py does not contain these 9 exact lines in a row:
```
    other_group.add_argument(
        "--version",
        action="version",
        version=f"%(prog)s {__version__}",
        help="Show the version number and exit",
    )
    other_group.add_argument(
        "--apply",
        metavar="FILE",
```

UnifiedDiffNoMatch: hunk failed to apply!

aider/versioncheck.py does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in aider/versioncheck.py!

aider/versioncheck.py does not contain these 5 exact lines in a row:
```
    check_version(io.tool_error)

    if "VSCODE_GIT_IPC_HANDLE" in os.environ:
        args.pretty = False
        io.tool_output("VSCode terminal detected, pretty output has been disabled.")
```

ASSISTANT: I apologize for the confusion. Let's try again with the correct diffs.

Here are the diffs for the changes to `aider/versioncheck.py` and `aider/main.py`:

```diff
--- aider/versioncheck.py
+++ aider/versioncheck.py
@@ ... @@
 import sys

 import packaging.version
 import requests

 import aider

 def check_version(print_cmd):
     try:
         response = requests.get("https://pypi.org/pypi/aider-chat/json")
         data = response.json()
         latest_version = data["info"]["version"]
         current_version = aider.__version__

-        if packaging.version.parse(latest_version) <= packaging.version.parse(current_version):
-            return
+        is_update_available = packaging.version.parse(latest_version) > packaging.version.parse(current_version)

-        print_cmd(f"Newer version v{latest_version} is available. To upgrade, run:")
-        py = sys.executable
-        print_cmd(f"{py} -m pip install --upgrade aider-chat")
+        if is_update_available:
+            print_cmd(f"Newer version v{latest_version} is available. To upgrade, run:")
+            py = sys.executable
+            print_cmd(f"{py} -m pip install --upgrade aider-chat")
+
+        return is_update_available
     except Exception as err:
         print_cmd(f"Error checking pypi for new version: {err}")
+        return False
```

```diff
--- aider/main.py
+++ aider/main.py
@@ ... @@
     other_group.add_argument(
         "--version",
         action="version",
         version=f"%(prog)s {__version__}",
         help="Show the version number and exit",
     )
+    other_group.add_argument(
+        "--check-update",
+        action="store_true",
+        help="Check for updates and return status in the exit code",
+        default=False,
+    )
     other_group.add_argument(
         "--apply",
         metavar="FILE",
@@ ... @@
     check_version(io.tool_error)

+    if args.check_update:
+        update_available = check_version(lambda msg: None)
+        sys.exit(0 if not update_available else 1)
+
     if "VSCODE_GIT_IPC_HANDLE" in os.environ:
         args.pretty = False
         io.tool_output("VSCode terminal detected, pretty output has been disabled.")
```

These diffs should apply cleanly to the current contents of the files. The `check_version` function in `aider/versioncheck.py` now returns a boolean indicating whether an update is available, and `aider/main.py` has been updated to include the `--check-update` argument and to use the return value from `check_version` to set the exit status code.
2024-01-04 12:27:31 -08:00
Paul Gauthier
7113a30271 unified diffs 2023-12-17 12:54:34 -08:00
Paul Gauthier
ff96369ed6 cleanup 2023-12-06 14:09:32 -08:00
Paul Gauthier
922a56b194 Merge branch 'main' into openai-upgrade 2023-12-06 09:26:05 -08:00
Paul Gauthier
b85ed45504 add deployment_id to AzureOpenAI call per @itlackey 2023-12-06 09:22:04 -08:00
Paul Gauthier
57ab2cc9da Revert "implement deployment id"
This reverts commit b107db98fa.
2023-12-06 09:20:53 -08:00
Your Name
4692a689fe Improvements: flag -f (not -mf); unitest improvements. 2023-12-05 23:55:10 +01:00
Your Name
743179a4bd aider: Add --message-file flag to specify a file containing the message to send GPT, process reply, then exit (disables chat mode).
# Aider chat conversation:

USER: Am I correct that currently if one wants to launch aider from commandline , the way to go is to use --message flag that allows providing prompt as command line parameter?

ASSISTANT: Yes, you are correct. The `--message` or `-m` flag can be used to provide a single message to send to GPT, process the reply, and then exit the application. This flag disables the interactive chat mode and is suitable for scripting or when you want to issue a single command without entering the interactive chat session.

USER: Is there a way to run prompt from command line like `--message` or `-m` however by providing prompt as file ?

ASSISTANT: Currently, there is no direct command-line option in the `aider` tool to provide a prompt from a file. The `--message` or `-m` flag only accepts a string as an argument. If you want to provide a prompt from a file, you would need to read the content of the file and pass it as a string to the `--message` flag.

However, this functionality can be added to the `aider` tool by implementing a new command-line option that reads the content of a specified file and uses it as the prompt message.

Would you like me to implement this feature for you? If so, please provide the `aider/main.py` file, and I will suggest the necessary changes.

USER: How would you name such flag to match current convention and how would you describe it?

ASSISTANT: Following the current naming convention used in the `aider` tool, a suitable name for the flag that allows providing a prompt from a file could be `--message-file` or `-mf`. This flag would be described as:

"Specify a file containing the message to send to GPT, process the reply, then exit (disables chat mode)."

This description aligns with the existing `--message` flag while clearly indicating that the input is expected to be a file containing the message rather than a direct string input.

USER: could you please add such flag?

ASSISTANT: To add the `--message-file` flag to the `aider` tool, we need to modify the `aider/main.py` file. Please add the `aider/main.py` file to the chat so I can provide you with the necessary changes.

USER: could you please add such flag?

ASSISTANT: To add the `--message-file` flag to the `aider` tool, we need to modify the `aider/main.py` file. Please add the `aider/main.py` file to the chat so I can provide you with the necessary changes.

USER: could you please add such flag?

ASSISTANT: To add the `--message-file` flag to the `aider` tool, we need to modify the `aider/main.py` file. Please add the `aider/main.py` file to the chat so I can provide you with the necessary changes.

USER: I added these *read-write* files: /home/gw-t490/github/VariousForks/aider-patching-for-pull-requests/aider/main.py

ASSISTANT: Great, now that you've added the `aider/main.py` file, I will provide you with the necessary changes to implement the `--message-file` flag.

We will need to:

1. Add a new command-line argument `--message-file` to the argument parser.
2. Read the content of the file specified by `--message-file` and pass it to the `coder.run()` method.

Here are the *SEARCH/REPLACE* blocks for the changes:

aider/main.py
```python
<<<<<<< SEARCH
    other_group.add_argument(
        "--message",
        "--msg",
        "-m",
        metavar="COMMAND",
        help="Specify a single message to send GPT, process reply then exit (disables chat mode)",
    )
=======
    other_group.add_argument(
        "--message",
        "--msg",
        "-m",
        metavar="COMMAND",
        help="Specify a single message to send GPT, process reply then exit (disables chat mode)",
    )
    other_group.add_argument(
        "--message-file",
        "-mf",
        metavar="MESSAGE_FILE",
        help="Specify a file containing the message to send GPT, process reply, then exit (disables chat mode)",
    )
>>>>>>> REPLACE
```

aider/main.py
```python
<<<<<<< SEARCH
    if args.message:
        io.tool_output()
        coder.run(with_message=args.message)
    else:
        coder.run()
=======
    if args.message:
        io.tool_output()
        coder.run(with_message=args.message)
    elif args.message_file:
        try:
            with open(args.message_file, 'r', encoding='utf-8') as file:
                message_from_file = file.read()
            io.tool_output()
            coder.run(with_message=message_from_file)
        except FileNotFoundError:
            io.tool_error(f"Message file not found: {args.message_file}")
            return 1
        except IOError as e:
            io.tool_error(f"Error reading message file: {e}")
            return 1
    else:
        coder.run()
>>>>>>> REPLACE
```

These changes will add the `--message-file` flag to the argument parser and handle the case where a message file is provided. If the file is found and can be read, its content will be used as the message to send to GPT. If there is an error reading the file, an error message will be displayed, and the program will exit with a status code of 1.
2023-12-05 23:55:10 +01:00
Paul Gauthier
b107db98fa implement deployment id 2023-12-05 11:31:17 -08:00
Paul Gauthier
bf03f43b44 fixed benchmark 2023-12-05 11:21:11 -08:00
Paul Gauthier
fb07b784f6 move to gpt-3.5-turbo-1106 2023-12-05 10:28:27 -08:00
Paul Gauthier
6ebc142377 roughed in openai 1.x 2023-12-05 07:37:05 -08:00
Your Name
015ffa13e1 Fixes #374 - logging add_to_input_history if args.message is used.
Fixes https://github.com/paul-gauthier/aider/issues/374
2023-11-30 13:19:54 +01:00
Paul Gauthier
d868e96467 Abandon checking gitignore if can not read file 2023-11-03 08:33:32 -07:00
Paul Gauthier
c4f6ce6435 handle encoding error when checking .gitignore 2023-11-03 08:12:01 -07:00
Paul Gauthier
ac9160ae54 aider: Add --encoding argument and pass it to InputOutput.
# Aider chat conversation:

USER: add --encoding and pass it to `InputOutput`

ASSISTANT: To add the `--encoding` argument and pass it to `InputOutput`, we need to modify the `aider/main.py` file.

Here are the steps:

1. Add a new argument `--encoding` to the `argparse.ArgumentParser` in the `main` function.
2. Pass the `args.encoding` to the `InputOutput` class instantiation.

Here are the changes:

```python
aider/main.py
<<<<<<< HEAD
    ##########
    other_group = parser.add_argument_group("Other Settings")
    other_group.add_argument(
        "--version",
        action="version",
        version=f"%(prog)s {__version__}",
        help="Show the version number and exit",
    )
    other_group.add_argument(
        "--apply",
        metavar="FILE",
        help="Apply the changes from the given file instead of running the chat (debug)",
    )
    other_group.add_argument(
        "--yes",
        action="store_true",
        help="Always say yes to every confirmation",
        default=None,
    )
    other_group.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        help="Enable verbose output",
        default=False,
    )
    other_group.add_argument(
        "--show-repo-map",
        action="store_true",
        help="Print the repo map and exit (debug)",
        default=False,
    )
    other_group.add_argument(
        "--message",
        "--msg",
        "-m",
        metavar="COMMAND",
        help="Specify a single message to send GPT, process reply then exit (disables chat mode)",
    )
    other_group.add_argument(
        "-c",
        "--config",
        is_config_file=True,
        metavar="CONFIG_FILE",
        help=(
            "Specify the config file (default: search for .aider.conf.yml in git root, cwd"
            " or home directory)"
        ),
    )

    args = parser.parse_args(argv)
=======
    ##########
    other_group = parser.add_argument_group("Other Settings")
    other_group.add_argument(
        "--version",
        action="version",
        version=f"%(prog)s {__version__}",
        help="Show the version number and exit",
    )
    other_group.add_argument(
        "--apply",
        metavar="FILE",
        help="Apply the changes from the given file instead of running the chat (debug)",
    )
    other_group.add_argument(
        "--yes",
        action="store_true",
        help="Always say yes to every confirmation",
        default=None,
    )
    other_group.add_argument(
        "-v",
        "--verbose",
        action="store_true",
        help="Enable verbose output",
        default=False,
    )
    other_group.add_argument(
        "--show-repo-map",
        action="store_true",
        help="Print the repo map and exit (debug)",
        default=False,
    )
    other_group.add_argument(
        "--message",
        "--msg",
        "-m",
        metavar="COMMAND",
        help="Specify a single message to send GPT, process reply then exit (disables chat mode)",
    )
    other_group.add_argument(
        "--encoding",
        default="utf-8",
        help="Specify the encoding for input and output (default: utf-8)",
    )
    other_group.add_argument(
        "-c",
        "--config",
        is_config_file=True,
        metavar="CONFIG_FILE",
        help=(
            "Specify the config file (default: search for .aider.conf.yml in git root, cwd"
            " or home directory)"
        ),
    )

    args = parser.parse_args(argv)
>>>>>>> updated
```

```python
aider/main.py
<<<<<<< HEAD
    io = InputOutput(
        args.pretty,
        args.yes,
        args.input_history_file,
        args.chat_history_file,
        input=input,
        output=output,
        user_input_color=args.user_input_color,
        tool_output_color=args.tool_output_color,
        tool_error_color=args.tool_error_color,
        dry_run=args.dry_run,
    )
=======
    io = InputOutput(
        args.pretty,
        args.yes,
        args.input_history_file,
        args.chat_history_file,
        input=input,
        output=output,
        user_input_color=args.user_input_color,
        tool_output_color=args.tool_output_color,
        tool_error_color=args.tool_error_color,
        dry_run=args.dry_run,
        encoding=args.encoding,
    )
>>>>>>> updated
```

Please note that the `InputOutput` class should be able to handle the `encoding` argument. If it's not the case, we need to modify the `InputOutput` class as well.
2023-10-19 20:18:02 -07:00
Paul Gauthier
8561bfde33 copy 2023-10-18 13:13:42 -07:00
Paul Gauthier
88e42a124b copy 2023-10-18 12:47:26 -07:00
Paul Gauthier
dffeaac4d9 Added --commit command #283 2023-10-18 12:45:51 -07:00