Commit graph

255 commits

Author SHA1 Message Date
Paul Gauthier
9ac8a60f5f Finish support for gpt-4-32k 2023-06-07 12:42:43 -07:00
Paul Gauthier
571896f0bd Added gpt-4-32k 2023-06-07 12:39:56 -07:00
Paul Gauthier
a874d617d3 rename 2023-06-07 12:29:51 -07:00
Paul Gauthier
9cef379abd refac 2023-06-07 12:28:45 -07:00
Paul Gauthier
c8216d9687 No need to force show_diffs=True for 3.5 2023-06-06 18:17:39 -07:00
Paul Gauthier
1faef90841 copy 2023-06-06 07:29:47 -07:00
Paul Gauthier
de0df5e7b1 fixed bug in check_model_availability 2023-06-06 07:28:12 -07:00
Paul Gauthier
8f70f1b251 renamed 2023-06-05 22:34:44 -07:00
Paul Gauthier
05c08b36a7 move cur_messages->done_messages, even with --no-auto-commit 2023-06-05 22:30:52 -07:00
Paul Gauthier
8abff61aff better handle malformed file block 2023-06-05 22:23:06 -07:00
Paul Gauthier
c44cc12b42 The --no-auto-commits flag implies --no-dirty-commits 2023-06-05 22:13:20 -07:00
Paul Gauthier
4727e5c616 rename 2023-06-05 22:12:27 -07:00
Paul Gauthier
ab5a6e2c19 better approach to redacting historical edits 2023-06-05 22:10:27 -07:00
Paul Gauthier
6081baa32b better 2023-06-05 21:37:56 -07:00
Paul Gauthier
2336af2886 better 2023-06-05 19:41:14 -07:00
Paul Gauthier
2f0d9279d2 works 2023-06-05 19:36:12 -07:00
Paul Gauthier
c8beac9a2d cleaned up 35/4 logic 2023-06-05 17:14:44 -07:00
Paul Gauthier
fcd8a6df73 Use the Models enum instead of .value 2023-06-05 17:06:34 -07:00
Paul Gauthier
c17e454608 Added /clear cmd 2023-06-05 11:31:47 -07:00
Paul Gauthier
95b32a74a9 Moved all model names into an enum 2023-06-05 09:19:29 -07:00
Paul Gauthier
41ac5b056d Merge branch 'call-graph' into gpt-35 2023-06-04 15:39:49 -07:00
Paul Gauthier
140b03314e Merge branch 'main' into call-graph 2023-06-04 15:39:42 -07:00
Paul Gauthier
6398e5ef18 Support worktrees 2023-06-04 15:37:20 -07:00
Paul Gauthier
56d2aa59ee 3.5 prompts 2023-06-04 13:59:43 -07:00
Paul Gauthier
2bdfdb11bb Don't add gpt-3.5 replies to the history if they contain edits 2023-06-04 13:44:04 -07:00
Paul Gauthier
05c4f5654f clean up initial status messages 2023-06-04 13:34:06 -07:00
Paul Gauthier
b9ce79909e copy 2023-06-04 13:22:38 -07:00
Paul Gauthier
94767f73a1 Merge branch 'call-graph' into gpt-35 2023-06-04 13:20:52 -07:00
Paul Gauthier
5cc28bae15 Merge branch 'main' into call-graph 2023-06-04 13:20:44 -07:00
Paul Gauthier
87df24bcd9 period 2023-06-04 13:20:35 -07:00
Paul Gauthier
e627d8282f apply edits from 3.5 2023-06-04 13:18:33 -07:00
Paul Gauthier
cdfc0a38ee refac 2023-06-04 11:50:56 -07:00
Paul Gauthier
9d821dbca6 cleanup 2023-06-04 11:45:59 -07:00
Paul Gauthier
b02000caa9 Force showing diffs and disabling ctags/repo-maps 2023-06-04 11:43:03 -07:00
Paul Gauthier
9088d139b2 refactor prompts 2023-06-04 11:36:50 -07:00
Paul Gauthier
106eab7a7a Merge branch 'main' into call-graph 2023-06-04 06:10:22 -07:00
Paul Gauthier
0abbf43466 just print 2023-06-04 06:04:32 -07:00
Paul Gauthier
df91e9ab1c aider: Implemented backoff library to handle rate limit issues with exponential backoff and a maximum of 5 retries.
# Context:
USER: Hello there,

thanks for making this open source!
I have a request: due to being still on the free credits of OpenAI API, I run into timeouts.

fetch_starred_repos.py
Add these files to the chat? y
RateLimitError: You exceeded your current quota, please check your plan and billing details.
Retry in 1 seconds.
...
Is it possible for you to implement this library to omit that?
https://pypi.org/project/backoff/

Thanks in advance.
Greetings from Germany

ASSISTANT: Sure, I can help you implement the `backoff` library to handle the rate limit issue. First, please make the `aider/coder.py` file *read-write* so I can propose changes to it.
USER: I added these *read-write* files: aider/coder.py
ASSISTANT: Great! First, you need to install the `backoff` library. You can do this by running:

```
pip install backoff
```

Next, I will show you the changes needed in the `aider/coder.py` file to implement the `backoff` library for handling rate limit issues.

1. Import the `backoff` library at the beginning of the file.
2. Replace the `send_with_retries` method with a new method that uses the `backoff` library.

Here are the changes:

```python
aider/coder.py
<<<<<<< ORIGINAL
import os
import sys
import time
import traceback
=======
import os
import sys
import traceback
import backoff
>>>>>>> UPDATED
```

```python
aider/coder.py
<<<<<<< ORIGINAL
    def send_with_retries(self, model, messages):
        while True:
            try:
                return openai.ChatCompletion.create(
                    model=model,
                    messages=messages,
                    temperature=0,
                    stream=True,
                )
            except RateLimitError as err:
                self.io.tool_error(f"RateLimitError: {err}")
            except requests.exceptions.ConnectionError as err:
                self.io.tool_error(f"ConnectionError: {err}")

            retry_after = 1
            self.io.tool_error(f"Retry in {retry_after} seconds.")
            time.sleep(retry_after)
=======
    @backoff.on_exception(
        backoff.expo,
        (RateLimitError, requests.exceptions.ConnectionError),
        max_tries=5,
        on_backoff=lambda details: self.io.tool_error(f"Retry in {details['wait']} seconds."),
    )
    def send_with_retries(self, model, messages):
        return openai.ChatCompletion.create(
            model=model,
            messages=messages,
            temperature=0,
            stream=True,
        )
>>>>>>> UPDATED
```

These changes will implement the `backoff` library to handle rate limit issues with exponential backoff and a maximum of 5 retries. If you want to adjust the number of retries, you can change the `max_tries` parameter in the `backoff.on_exception` decorator.
2023-06-04 05:53:06 -07:00
Paul Gauthier
ef22f44d19 final details on --map-tokens 2023-06-03 18:06:14 -07:00
Paul Gauthier
d996fbe1c3 aider: Updated the Coder class in aider/coder.py to accept the map_tokens parameter and pass it to the RepoMap class instead of use_ctags.
# Context:
USER: I added these *read-write* files: aider/coder.py
ASSISTANT: Great! Now I will modify the `aider/coder.py` file to accept and use the `map_tokens` parameter instead of `use_ctags`.

```python
aider/coder.py
<<<<<<< ORIGINAL
    def __init__(
        self,
        io,
        main_model="gpt-4",
        fnames=None,
        pretty=True,
        show_diffs=False,
        auto_commits=True,
        dirty_commits=True,
        dry_run=False,
        use_ctags=False,
        verbose=False,
        openai_api_key=None,
    ):
        ...
        self.repo_map = RepoMap(use_ctags, self.root, self.main_model, rm_io)
=======
    def __init__(
        self,
        io,
        main_model="gpt-4",
        fnames=None,
        pretty=True,
        show_diffs=False,
        auto_commits=True,
        dirty_commits=True,
        dry_run=False,
        map_tokens=1024,
        verbose=False,
        openai_api_key=None,
    ):
        ...
        self.repo_map = RepoMap(map_tokens, self.root, self.main_model, rm_io)
>>>>>>> UPDATED
```

This change updates the `Coder` class in `aider/coder.py` to accept the `map_tokens` parameter and pass it to the `RepoMap` class instead of `use_ctags`.
2023-06-03 17:47:45 -07:00
Paul Gauthier
c27483193b refac 2023-06-03 06:18:45 -07:00
Paul Gauthier
1882cf55db Handle ConnectionError 2023-06-03 06:16:33 -07:00
Paul Gauthier
7bc26e6762 Added --verbose support to repomap 2023-06-01 09:04:08 -07:00
Paul Gauthier
1f2aa1a6c8 Auto fallback to 3.5 2023-06-01 08:39:27 -07:00
Paul Gauthier
1b046e8111 aider: Added a new method to check the availability of OpenAI models and called it in the __init__ method to ensure the main_model is available in the list of OpenAI models.
# Context:
USER: in init, call check the list of available openai models and make sure the `main_model` is in there. if not, print an err msg
ASSISTANT:
^C KeyboardInterrupt
USER: in init, call check the list of available openai models and make sure the `main_model` is in there. if not, print an err msg
ASSISTANT: To check the list of available OpenAI models and make sure the `main_model` is in there, you need to modify the `__init__` method in the `Coder` class. Here's how you can do it:

1. Add a new method `check_model_availability` to the `Coder` class that takes the `main_model` as an argument and checks if it's available in the list of OpenAI models.
2. Call this method in the `__init__` method of the `Coder` class.

Here are the changes you need to make:

```python
aider/coder.py
<<<<<<< ORIGINAL
class Coder:
    abs_fnames = None
    repo = None
    last_aider_commit_hash = None
    last_asked_for_commit_time = 0

    def __init__(
=======
class Coder:
    abs_fnames = None
    repo = None
    last_aider_commit_hash = None
    last_asked_for_commit_time = 0

    def check_model_availability(self, main_model):
        available_models = openai.Model.list()
        model_ids = [model.id for model in available_models['data']]
        if main_model not in model_ids:
            raise ValueError(f"Model {main_model} is not available. Please choose from the available models: {model_ids}")

    def __init__(
>>>>>>> UPDATED
```

```python
aider/coder.py
<<<<<<< ORIGINAL
        self.main_model = main_model
        if main_model == "gpt-3.5-turbo":
            self.io.tool_error(
                f"aider doesn't work well with {main_model}, use gpt-4 for best results."
            )

        self.set_repo(fnames)
=======
        self.check_model_availability(main_model)
        self.main_model = main_model
        if main_model == "gpt-3.5-turbo":
            self.io.tool_error(
                f"aider doesn't work well with {main_model}, use gpt-4 for best results."
            )

        self.set_repo(fnames)
>>>>>>> UPDATED
```

These changes will add a new method `check_model_availability` to the `Coder` class and call it in the `__init__` method to ensure the `main_model` is available in the list of OpenAI models. If not, it will raise a `ValueError` with an appropriate error message.
2023-06-01 08:36:48 -07:00
Paul Gauthier
92cd2f3ce6 isort 2023-05-28 22:47:38 -07:00
Paul Gauthier
bd78789bd2 Fixed quote stripping of gpt3.5 commit messages 2023-05-27 17:05:57 -07:00
Paul Gauthier
cc9b21df06 renamed io.tool() -> io.tool_output() 2023-05-27 15:17:33 -07:00
Paul Gauthier
5ba084edec auto-complete filenames 2023-05-27 08:54:10 -07:00
Paul Gauthier
767c241e95 Refactor rel_fnames assignment in coder.py. 2023-05-27 08:48:39 -07:00