Commit graph

192 commits

Author SHA1 Message Date
Daniel Vainsencher
3e9f6dcca2
Merge branch 'main' into dvf_llm_log 2024-06-12 18:32:48 -04:00
Daniel Vainsencher
c40b3fa310 Review comments 2024-06-12 18:28:55 -04:00
Paul Gauthier
a07492b90a moved --vim to Other Settings 2024-06-12 11:30:26 -07:00
Krazer
486c5ce65c add support to load/override model settings 2024-06-11 17:15:48 -05:00
Paul Gauthier
fb3cc98da5 cleanup --model-metadata-file 2024-06-11 13:30:35 -07:00
paul-gauthier
2f6e360188
Merge pull request #666 from caseymcc/register_model
Allow models to be registered with litellm
2024-06-11 13:20:02 -07:00
Krazer
568d72ebe8 update docs 2024-06-11 14:09:45 -05:00
Krazer
acccbb1512 update command line arg 2024-06-11 13:14:22 -05:00
Krazer
d91707f73e all models to be registered with litellm 2024-06-11 13:07:19 -05:00
Paul Gauthier
05a74d67de finished --vim 2024-06-10 21:16:33 -07:00
Paul Gauthier
196c1314eb Add support for VI editing mode in the terminal. 2024-06-10 21:09:46 -07:00
develmusa
098944a133 Update help text for specifying the API key to mention Anthropic instead of OpenAI. 2024-06-09 12:35:42 +02:00
Daniel Vainsencher
e6e360a4ef Added support for logging LLM history to a specified file. 2024-06-07 10:40:32 -04:00
Paul Gauthier
30f4a905c1 renamed config/options and get_md_help() 2024-06-06 14:00:14 -07:00
Paul Gauthier
65c9a7866a improved handling of defaults 2024-06-06 13:40:16 -07:00
Paul Gauthier
645ace1d0e fix defaults in sample yml 2024-06-06 12:46:07 -07:00
Paul Gauthier
2d62e3fb1f add sample aider.conf.yml 2024-06-06 12:40:25 -07:00
Paul Gauthier
caca261587 output nice md usage 2024-06-06 12:26:06 -07:00
Paul Gauthier
e7aafd9590 aider: Add argument formatter to print arguments in a specified format.
# Aider chat conversation:

USER: Add an args formatter that prints out args like this:

## Output Settings:

### --dark-mode
Use colors suitable for a dark terminal background
Default: False

### --light-mode
Use colors suitable for a light terminal background
Default: False

...

ASSISTANT: To add an argument formatter that prints out arguments in the specified format, we need to:

1. Create a new formatter class.
2. Update the `get_help` function to use this new formatter.

Here are the changes:

1. Create a new file `aider/args_formatter.py` with the custom formatter class.
2. Update `aider/args.py` to use this new formatter.

Let's start with the new file:

aider/args_formatter.py
```python
<<<<<<< SEARCH
=======
import argparse

class CustomHelpFormatter(argparse.HelpFormatter):
    def start_section(self, heading):
        super().start_section(f"## {heading}:")

    def _format_action(self, action):
        parts = []
        if action.help:
            parts.append(f"### --{action.dest}")
            parts.append(action.help)
            if action.default is not argparse.SUPPRESS:
                parts.append(f"Default: {action.default}")
        return "\n".join(parts)

    def _format_action_invocation(self, action):
        return ""

    def _format_args(self, action, default_metavar):
        return ""
>>>>>>> REPLACE
```

Next, update `aider/args.py` to use this new formatter:

aider/args.py
```python
<<<<<<< SEARCH
from aider import __version__, models
=======
from aider import __version__, models
from aider.args_formatter import CustomHelpFormatter
>>>>>>> REPLACE
```

aider/args.py
```python
<<<<<<< SEARCH
        description="aider is GPT powered coding in your terminal",
=======
        description="aider is GPT powered coding in your terminal",
        formatter_class=CustomHelpFormatter,
>>>>>>> REPLACE
```

aider/args.py
```python
<<<<<<< SEARCH
    parser = get_parser([], None)
=======
    parser = get_parser([], None)
    parser.formatter_class = CustomHelpFormatter
>>>>>>> REPLACE
```
2024-06-06 11:38:45 -07:00
Paul Gauthier
9437fb28c4 removed configargparse.YAMLConfigFileParser 2024-06-05 21:14:54 -07:00
Paul Gauthier
6f9e0ce37f cog to update usage.md 2024-06-05 19:43:24 -07:00
Paul Gauthier
a857cbb7d1 added cmd line args 2024-06-05 16:59:30 -07:00
Paul Gauthier
57a2c61386 updated lint cmd descriptions 2024-05-20 09:01:22 -07:00
Paul Gauthier
9ee332f5d9 Added options for automatic linting and testing after changes. 2024-05-19 07:34:19 -07:00
Paul Gauthier
398a1300dc aider: Added --auto-lint/--no-auto-lint switch to the parser in aider/args.py.
# Aider chat conversation:

USER: add a --auto-lint/--no-auto-lint switch

ASSISTANT: To add the `--auto-lint/--no-auto-lint` switch, we need to:

1. Add the new argument to the parser in `aider/args.py`.

Here is the *SEARCH/REPLACE* block:

aider/args.py
```python
<<<<<<< SEARCH
    )
=======
    )
    group.add_argument(
        "--auto-lint",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable automatic linting after changes (default: True)",
    )
>>>>>>> REPLACE
```

USER:
# Fix any errors below

## Running: flake8 --select=E9,F821,F823,F831,F406,F407,F701,F702,F704,F706 --show-source aider/args.py

aider/args.py:17:5: F821 undefined name 'group'
    group.add_argument(
    ^

## See relevant line below marked with █.

/Users/gauthier/Projects/aider/aider/args.py:
...⋮...
  9│def get_parser(default_config_files, git_root):
 10│    parser = configargparse.ArgumentParser(
 11│        description="aider is GPT powered coding in your terminal",
 12│        add_config_file_help=True,
 13│        default_config_files=default_config_files,
 14│        config_file_parser_class=configargparse.YAMLConfigFileParser,
 15│        auto_env_var_prefix="AIDER_",
 16│    )
 17█    group.add_argument(
 18│        "--auto-lint",
 19│        action=argparse.BooleanOptionalAction,
 20│        default=True,
 21│        help="Enable/disable automatic linting after changes (default: True)",
...⋮...

ASSISTANT: To fix the error, we need to move the `--auto-lint` argument addition to the correct location within the `get_parser` function, after the `group` variable is defined.

Here is the corrected *SEARCH/REPLACE* block:

aider/args.py
```python
<<<<<<< SEARCH
    group.add_argument(
        "--auto-lint",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable automatic linting after changes (default: True)",
    )

    ##########
=======
    ##########
    group.add_argument(
        "--auto-lint",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable automatic linting after changes (default: True)",
    )
>>>>>>> REPLACE
```

USER:
# Fix any errors below

## Running: flake8 --select=E9,F821,F823,F831,F406,F407,F701,F702,F704,F706 --show-source aider/args.py

aider/args.py:18:5: F821 undefined name 'group'
    group.add_argument(
    ^

## See relevant line below marked with █.

/Users/gauthier/Projects/aider/aider/args.py:
...⋮...
  9│def get_parser(default_config_files, git_root):
 10│    parser = configargparse.ArgumentParser(
 11│        description="aider is GPT powered coding in your terminal",
 12│        add_config_file_help=True,
 13│        default_config_files=default_config_files,
 14│        config_file_parser_class=configargparse.YAMLConfigFileParser,
 15│        auto_env_var_prefix="AIDER_",
 16│    )
 17│    ##########
 18█    group.add_argument(
 19│        "--auto-lint",
 20│        action=argparse.BooleanOptionalAction,
 21│        default=True,
 22│        help="Enable/disable automatic linting after changes (default: True)",
...⋮...

ASSISTANT: The error is occurring because the `group` variable is not defined before it is used. We need to place the `--auto-lint` argument addition after the `group` variable is defined.

Here is the corrected *SEARCH/REPLACE* block:

aider/args.py
```python
<<<<<<< SEARCH
    ##########
    group.add_argument(
        "--auto-lint",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable automatic linting after changes (default: True)",
    )
=======
    group = parser.add_argument_group("Main")
>>>>>>> REPLACE
```

aider/args.py
```python
<<<<<<< SEARCH
    group.add_argument(
=======
    group.add_argument(
        "--auto-lint",
        action=argparse.BooleanOptionalAction,
        default=True,
        help="Enable/disable automatic linting after changes (default: True)",
    )
    group.add_argument(
>>>>>>> REPLACE
```
2024-05-19 06:23:28 -07:00
Paul Gauthier
76038e69d7 Added an argument for enabling/disabling automatic linting after changes. 2024-05-19 06:23:27 -07:00
Paul Gauthier
73dd873f86 Add option to enable/disable automatic linting after changes. 2024-05-19 06:23:20 -07:00
Paul Gauthier
6474139d04 Lint files before fixing errors and commit changes if necessary. 2024-05-18 21:13:19 -07:00
Paul Gauthier
7391903759 Removed redundant lint command option and added support for specifying lint commands for different languages. 2024-05-18 20:57:01 -07:00
Paul Gauthier
06bda2d730 aider: Added a --lint-cmd argument to allow users to specify a lint command multiple times.
# Aider chat conversation:

USER: add a --lint-cmd arg that takes a string like "python python-linter --with --args". allow the user to specify this args multiple times

ASSISTANT: To add a `--lint-cmd` argument that takes a string and allows the user to specify this argument multiple times, we need to:

1. Add the new argument to the parser.
2. Ensure it can be specified multiple times.

Here is the *SEARCH/REPLACE* block for `aider/args.py`:

aider/args.py
```python
<<<<<<< SEARCH
    )
=======
    )

    ##########
    group = parser.add_argument_group("Lint Settings")
    group.add_argument(
        "--lint-cmd",
        action="append",
        metavar="LINT_CMD",
        help="Specify a lint command to run. Can be specified multiple times.",
    )
>>>>>>> REPLACE
```
2024-05-18 20:52:21 -07:00
Paul Gauthier
bc06d8623c Updated lint command to commit after fixing problems. 2024-05-18 19:30:32 -07:00
Paul Gauthier
04084883e8 Added a new command to run the linter on dirty files, fix problems, and then commit. 2024-05-18 18:35:33 -07:00
Paul Gauthier
72613f3b27 switch naming from openai/gpt-4o to gpt-4o 2024-05-15 06:25:30 -07:00
Paul Gauthier
b2fbafe41b docs and --4-turbo updates 2024-05-13 11:24:52 -07:00
Paul Gauthier
ea05cf05e1 Added --restore-chat-history 2024-05-13 11:09:28 -07:00
Paul Gauthier
bfba56c5f1 added 4o as default 2024-05-13 10:57:26 -07:00
paul-gauthier
45b2ba8a10
Merge pull request #591 from paul-gauthier/restore-chat-history
Restore prior chat history on launch
2024-05-11 07:49:43 -07:00
Paul Gauthier
f256b43043 wip 2024-05-08 13:35:34 -07:00
Paul Gauthier
3a79b6230b aider: Added a --max-chat-history-tokens switch and passed it to ChatSummary in Coder.
# Aider chat conversation:

USER: add a --max-chat-history-tokens switch, pass it into Coder to `ChatSummary`

ASSISTANT: Here are the changes to add a --max-chat-history-tokens switch and pass it to ChatSummary in Coder:

aider/args.py
```python
<<<<<<< SEARCH
    parser.add_argument(
        "--map-tokens",
        type=int,
        default=1024,
        help="Number of tokens to use for the repo map. Set to 0 to disable.",
    )
=======
    parser.add_argument(
        "--map-tokens",
        type=int,
        default=1024,
        help="Number of tokens to use for the repo map. Set to 0 to disable.",
    )
    parser.add_argument(
        "--max-chat-history-tokens",
        type=int,
        default=None,
        help="Maximum number of tokens to use for chat history. If not specified, uses the model's max_chat_history_tokens.",
    )
>>>>>>> REPLACE
```

aider/coders/base_coder.py
```python
<<<<<<< SEARCH
        self.summarizer = ChatSummary(
            self.main_model.weak_model,
            self.main_model.max_chat_history_tokens,
        )
=======
        max_chat_history_tokens = self.main_model.max_chat_history_tokens
        if kwargs.get("max_chat_history_tokens") is not None:
            max_chat_history_tokens = kwargs["max_chat_history_tokens"]

        self.summarizer = ChatSummary(
            self.main_model.weak_model,
            max_chat_history_tokens,
        )
>>>>>>> REPLACE
```

aider/main.py
```python
<<<<<<< SEARCH
            map_tokens=args.map_tokens,
=======
            map_tokens=args.map_tokens,
            max_chat_history_tokens=args.max_chat_history_tokens,
>>>>>>> REPLACE
```

This adds the new command line argument `--max-chat-history-tokens` which defaults to None. If not specified, it will use the model's default `max_chat_history_tokens`.

It passes this argument from `main()` into the `Coder` constructor.

In the `Coder` constructor, it checks if `max_chat_history_tokens` was provided in the `kwargs`. If so, it uses that value, otherwise it falls back to the model's default.

Let me know if you have any other questions!

ASSISTANT: Here are the changes to add a --max-chat-history-tokens switch and pass it to ChatSummary in Coder:

aider/args.py
```python
<<<<<<< SEARCH
    parser.add_argument(
        "--map-tokens",
        type=int,
        default=1024,
        help="Number of tokens to use for the repo map. Set to 0 to disable.",
    )
=======
    parser.add_argument(
        "--map-tokens",
        type=int,
        default=1024,
        help="Number of tokens to use for the repo map. Set to 0 to disable.",
    )
    parser.add_argument(
        "--max-chat-history-tokens",
        type=int,
        default=None,
        help="Maximum number of tokens to use for chat history. If not specified, uses the model's max_chat_history_tokens.",
    )
>>>>>>> REPLACE
```

aider/coders/base_coder.py
```python
<<<<<<< SEARCH
        self.summarizer = ChatSummary(
            self.main_model.weak_model,
            self.main_model.max_chat_history_tokens,
        )
=======
        max_chat_history_tokens = self.main_model.max_chat_history_tokens
        if kwargs.get("max_chat_history_tokens") is not None:
            max_chat_history_tokens = kwargs["max_chat_history_tokens"]

        self.summarizer = ChatSummary(
            self.main_model.weak_model,
            max_chat_history_tokens,
        )
>>>>>>> REPLACE
```

aider/main.py
```python
<<<<<<< SEARCH
            map_tokens=args.map_tokens,
=======
            map_tokens=args.map_tokens,
            max_chat_history_tokens=args.max_chat_history_tokens,
>>>>>>> REPLACE
```

This adds the new command line argument `--max-chat-history-tokens` which defaults to None. If not specified, it will use the model's default `max_chat_history_tokens`.

It passes this argument from `main()` into the `Coder` constructor.

In the `Coder` constructor, it checks if `max_chat_history_tokens` was provided in the `kwargs`. If so, it uses that value, otherwise it falls back to the model's default.

Let me know if you have any other questions!

USER: InvalidEditBlock: edit failed!

aider/args.py does not contain the *exact chunk* of SEARCH lines you specified.
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The SEARCH block needs to be EXACTLY the same as the lines in aider/args.py with nothing missing!

aider/args.py does not contain these 6 exact lines in a row:
```
    parser.add_argument(
        "--map-tokens",
        type=int,
        default=1024,
        help="Number of tokens to use for the repo map. Set to 0 to disable.",
    )
```

ASSISTANT: I apologize for the mistake. Here is the corrected change for aider/args.py:

aider/args.py
```python
<<<<<<< SEARCH
    group.add_argument(
        "--map-tokens",
        type=int,
        default=1024,
        help="Max number of tokens to use for repo map, use 0 to disable (default: 1024)",
    )
=======
    group.add_argument(
        "--map-tokens",
        type=int,
        default=1024,
        help="Max number of tokens to use for repo map, use 0 to disable (default: 1024)",
    )
    group.add_argument(
        "--max-chat-history-tokens",
        type=int,
        default=None,
        help="Maximum number of tokens to use for chat history. If not specified, uses the model's max_chat_history_tokens.",
    )
>>>>>>> REPLACE
```
2024-05-06 09:23:37 -07:00
Paul Gauthier
d64a457def Added --env-file param 2024-05-02 11:32:06 -07:00
Paul Gauthier
542c091cf3 Added --gui functionality 2024-04-28 14:08:25 -07:00
Paul Gauthier
d889dfc879 added args.py 2024-04-28 13:25:31 -07:00