Commit graph

1913 commits

Author SHA1 Message Date
Paul Gauthier
738c3b8e5e fall back to global repo map if files in chat are disjoint from rest of repo 2024-05-08 13:56:06 -07:00
Paul Gauthier
a9d9c6881d added gpt-3.5-turbo as explicit model 2024-05-08 13:52:20 -07:00
Paul Gauthier
48fd67485c add a user message during --show-prompts 2024-05-08 13:49:38 -07:00
Paul Gauthier
5bd875ffbf cleanup stray << HEAD 2024-05-08 13:45:18 -07:00
Paul Gauthier
9e7f2ec790 cleanup 2024-05-08 13:41:24 -07:00
Paul Gauthier
f256b43043 wip 2024-05-08 13:35:34 -07:00
Paul Gauthier
fb8ed21b13 refactored lazy_prompt in all coders 2024-05-08 13:07:35 -07:00
Paul Gauthier
3fcb5d9781 set version to 0.33.1-dev 2024-05-08 09:38:50 -07:00
Paul Gauthier
b0356ef507 version bump to 0.33.0 2024-05-08 09:38:14 -07:00
Paul Gauthier
44024c001d added aider.litellm 2024-05-08 08:09:23 -07:00
Paul Gauthier
9ff6770a04 refactored litellm to avoid duplicating workarounds 2024-05-08 08:05:15 -07:00
Paul Gauthier
b249177119 added settings for deepseek/deepseek-chat 2024-05-08 07:13:13 -07:00
Paul Gauthier
ecf6e4df3a set version to 0.32.1-dev 2024-05-07 16:36:51 -07:00
Paul Gauthier
6c17d94101 version bump to 0.32.0 2024-05-07 16:36:15 -07:00
Paul Gauthier
e9da4016c8 deepseek-chat with sys examples and sys reminder 2024-05-07 08:48:49 -07:00
Paul Gauthier
04b224962e send the reminder if unknown context window size 2024-05-07 08:42:33 -07:00
Paul Gauthier
e61857ef09 summarize as many messages as will fit into the summarizer context 2024-05-06 09:47:14 -07:00
Paul Gauthier
e51e0219ee aider: Add tqdm progress bar to summarize_chat_history_markdown loop.
# Aider chat conversation:

USER: add a tqdm to `summarize_chat_history_markdown` loop

ASSISTANT: ```diff
--- aider/history.py
+++ aider/history.py
@@ ... @@
 from aider.sendchat import simple_send_with_retries
+from tqdm import tqdm

 class ChatSummary:
     def __init__(self, model=None, max_tokens=1024):
@@ ... @@
     def summarize_chat_history_markdown(self, text):
         messages = []
         assistant = []
+        lines = text.splitlines(keepends=True)
+        for line in tqdm(lines, desc="Summarizing chat history"):
-        for line in text.splitlines(keepends=True):
             if line.startswith("# "):
                 continue
             if line.startswith(">"):
                 continue
             if line.startswith("#### /"):
                 continue

             if line.startswith("#### "):
                 if assistant:
                     assistant = "".join(assistant)
                     if assistant.strip():
                         messages.append(dict(role="assistant", content=assistant))
                     assistant = []

                 content = line[5:]
                 if content.strip() and content.strip() != "<blank>":
                     messages.append(dict(role="user", content=line[5:]))
                 continue

             assistant.append(line)

         summary = self.summarize(messages[-40:])
         return summary
```

This diff adds the `tqdm` progress bar to the `summarize_chat_history_markdown` method in the `aider/history.py` file. It wraps the loop that processes the chat history lines with `tqdm`, providing a description for the progress bar.
2024-05-06 09:31:32 -07:00
Paul Gauthier
64470955d4 pass max_chat_history_tokens into ChatSummary 2024-05-06 09:29:21 -07:00
Paul Gauthier
1747525418 aider: Added max_chat_history_tokens as an explicit argument to the Coder.__init__ method and passed args.max_chat_history_tokens when creating the Coder instance in main().
# Aider chat conversation:

USER: don't use kwargs, add it as an explicit arg

ASSISTANT: Here is the *SEARCH/REPLACE block* to add `max_chat_history_tokens` as an explicit argument instead of using `**kwargs`:

aider/coders/base_coder.py
```python
<<<<<<< SEARCH
    def __init__(
        self,
        main_model,
        io,
        fnames=None,
        git_dname=None,
        pretty=True,
        show_diffs=False,
        auto_commits=True,
        dirty_commits=True,
        dry_run=False,
        map_tokens=1024,
        verbose=False,
        assistant_output_color="blue",
        code_theme="default",
        stream=True,
        use_git=True,
        voice_language=None,
        aider_ignore_file=None,
        cur_messages=None,
        done_messages=None,
    ):
=======
    def __init__(
        self,
        main_model,
        io,
        fnames=None,
        git_dname=None,
        pretty=True,
        show_diffs=False,
        auto_commits=True,
        dirty_commits=True,
        dry_run=False,
        map_tokens=1024,
        verbose=False,
        assistant_output_color="blue",
        code_theme="default",
        stream=True,
        use_git=True,
        voice_language=None,
        aider_ignore_file=None,
        cur_messages=None,
        done_messages=None,
        max_chat_history_tokens=None,
    ):
>>>>>>> REPLACE
```

aider/main.py
```python
<<<<<<< SEARCH
        coder = Coder.create(
            main_model=main_model,
            edit_format=args.edit_format,
            io=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,
            aider_ignore_file=args.aiderignore,
        )
=======
        coder = Coder.create(
            main_model=main_model,
            edit_format=args.edit_format,
            io=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,
            aider_ignore_file=args.aiderignore,
            max_chat_history_tokens=args.max_chat_history_tokens,
        )
>>>>>>> REPLACE
```

This adds `max_chat_history_tokens` as an explicit argument to the `Coder.__init__` method, and passes `args.max_chat_history_tokens` when creating the `Coder` instance in `main()`.
2024-05-06 09:25:04 -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
eac8e4cb8f announce reload of chat history 2024-05-05 19:08:00 -07:00
Paul Gauthier
00c12efd3f cleanup 2024-05-05 19:04:24 -07:00
Paul Gauthier
b3e19cf5be reload history 2024-05-05 19:03:17 -07:00
Paul Gauthier
cd84cc0d3e refactored summarize_chat_history_markdown 2024-05-05 18:58:16 -07:00
Paul Gauthier
3e4fca2675 max_time not max_tries 2024-05-04 17:48:01 -07:00
Paul Gauthier
7c9c4fe788 should_giveup? 2024-05-04 17:43:26 -07:00
Paul Gauthier
0d43468aab added rules header 2024-05-04 08:07:15 -07:00
Paul Gauthier
7bcce6e8c6 move reminder after examples 2024-05-04 08:00:39 -07:00
Paul Gauthier
c9dbca9d0e gpt-4-0314 with examples as sys 2024-05-04 07:52:22 -07:00
Paul Gauthier
471d637694 updated llama3 2024-05-03 15:31:20 -07:00
Paul Gauthier
b5bb453378 examples_as_sys_msg 2024-05-03 15:24:36 -07:00
Paul Gauthier
f115236801 llama reminder_as_sys_msg=True 2024-05-03 15:11:22 -07:00
Paul Gauthier
5d32dd77fc Added diff-fenced coder 2024-05-03 13:50:15 -07:00
Paul Gauthier
921c7ceb80 Merge branch 'main' into gemini-editblock-and-examples 2024-05-03 13:17:23 -07:00
Paul Gauthier
1d7320e8a0 Added httpx.RemoteProtocolError to backoff #586 2024-05-03 08:48:19 -07:00
Paul Gauthier
250d89649b added test coverage #585 2024-05-02 13:01:41 -07:00
Paul Gauthier
0de6b36cde set version to 0.31.2-dev 2024-05-02 12:50:18 -07:00
Paul Gauthier
0f0e04b15f version bump to 0.31.1 2024-05-02 12:49:44 -07:00
Paul Gauthier
4482c24d34 Restore proper default to io.yes #585 2024-05-02 12:47:16 -07:00
Paul Gauthier
d64a457def Added --env-file param 2024-05-02 11:32:06 -07:00
Paul Gauthier
254481408e aider: Implemented loading .env file specified by command line argument.
# Aider chat conversation:

USER: do the todo

ASSISTANT: To implement the TODO item in `aider/main.py` about loading a .env file, we can make the following changes:

1. Add the python-dotenv package to the imports.
2. Load the .env file specified by args.env_file using dotenv.load_dotenv().

Here are the *SEARCH/REPLACE* blocks to make those changes:

aider/main.py
```python
<<<<<<< SEARCH
import configparser
import os
import sys
from pathlib import Path

import git
import litellm
from streamlit.web import cli
=======
import configparser
import os
import sys
from pathlib import Path

import git
import litellm
from dotenv import load_dotenv
from streamlit.web import cli
>>>>>>> REPLACE
```

aider/main.py
```python
<<<<<<< SEARCH
    # todo: load .env using filename args.env_file
=======
    if args.env_file:
        load_dotenv(args.env_file)
>>>>>>> REPLACE
```

This will load the environment variables from the specified .env file, if provided via the `--env-file` command line argument.

Note: You'll need to install the `python-dotenv` package for this to work, e.g. via `pip install python-dotenv`.
2024-05-02 11:29:12 -07:00
Paul Gauthier
8cfdd36620 Added support for loading environment variables from a custom .env file. 2024-05-02 11:29:11 -07:00
Paul Gauthier
7c2e9a394c browser blog post 2024-05-02 10:39:33 -07:00
Paul Gauthier
8a9ba47442 set version to 0.31.1-dev 2024-05-02 09:10:09 -07:00
Paul Gauthier
ec6054a53a version bump to 0.31.0 2024-05-02 09:09:35 -07:00
Paul Gauthier
b8313c5343 added docstrings 2024-05-01 15:14:14 -07:00
Paul Gauthier
e8666d3984 fix wholefile prompt 2024-05-01 15:06:31 -07:00
Paul Gauthier
f4b1797998 put filename back outside fences 2024-05-01 11:59:23 -07:00
Paul Gauthier
5ed9e8cb6d Merge remote-tracking branch 'origin/main' 2024-05-01 11:08:42 -07:00