Commit graph

438 commits

Author SHA1 Message Date
Daniel Vainsencher
c40b3fa310 Review comments 2024-06-12 18:28:55 -04:00
Paul Gauthier
6216a273fe drop context at the caller 2024-06-11 13:33:46 -07:00
Paul Gauthier
d2b9eec3e0 fixed bad url; fixed max_reflection logic 2024-06-08 12:57:36 -07:00
Paul Gauthier
1f1da4b1a2 refac all urls into urls.py 2024-06-08 12:53:54 -07:00
Paul Gauthier
09d3d02971 more conservative reflection if 2024-06-08 12:40:35 -07:00
Daniel Vainsencher
e6e360a4ef Added support for logging LLM history to a specified file. 2024-06-07 10:40:32 -04:00
Daniel Vainsencher
8896909e19 aider: Capitalize the "ASSISTANT" role when logging to the LLM history file.
# Aider chat conversation:

USER: When logging to llm history file, capitalize the ASSISTANT role.

ASSISTANT: To capitalize the "ASSISTANT" role when logging to the LLM history file, we need to modify the `send_new_user_message` method in `aider/coders/base_coder.py`.

Here is the *SEARCH/REPLACE* block:

aider/coders/base_coder.py
```python
<<<<<<< SEARCH
        with open('.aider.llm.history', 'a') as log_file:
            log_file.write(f"LLM RESPONSE {timestamp}\n")
            log_file.write(format_content("assistant", content) + "\n")
=======
        with open('.aider.llm.history', 'a') as log_file:
            log_file.write(f"LLM RESPONSE {timestamp}\n")
            log_file.write(format_content("ASSISTANT", content) + "\n")
>>>>>>> REPLACE
```
2024-06-07 09:39:03 -04:00
Daniel Vainsencher
2bd5daf2ad aider: Add logging of conversation between coder and LLM in .aider.llm.history file using new formatting functions in send_new_user_message.
# Aider chat conversation:

USER: We want to add logging of the conversation between coder and the LLM into a new file called .aider.llm.history. The formatting should be done using the new format_messages and format_content. Modify only the `send_new_user_message` function in base_coder, formatting and logging `messages` as soon as it is defined, and logging `content` before `tool_output`. Precede them by a single line saying "TO LLM {timestamp}" and "LLM RESPONSE {timestamp}" where the timestamp is uses ISO date format and has second precision.

ASSISTANT: To implement the logging of the conversation between the coder and the LLM, we will:

1. Format and log `messages` as soon as it is defined in `send_new_user_message`.
2. Log `content` before `tool_output`.
3. Precede the logs with a timestamp in ISO date format with second precision.

Here are the *SEARCH/REPLACE* blocks:

aider/coders/base_coder.py
```python
<<<<<<< SEARCH
        messages = self.format_messages()
=======
        import datetime
        from aider.utils import format_messages, format_content

        messages = self.format_messages()

        timestamp = datetime.datetime.now().isoformat(timespec='seconds')
        with open('.aider.llm.history', 'a') as log_file:
            log_file.write(f"TO LLM {timestamp}\n")
            log_file.write(format_messages(messages) + "\n")
>>>>>>> REPLACE
```

aider/coders/base_coder.py
```python
<<<<<<< SEARCH
        self.io.tool_output()
=======
        self.io.tool_output()

        timestamp = datetime.datetime.now().isoformat(timespec='seconds')
        with open('.aider.llm.history', 'a') as log_file:
            log_file.write(f"LLM RESPONSE {timestamp}\n")
            log_file.write(format_content("assistant", content) + "\n")
>>>>>>> REPLACE
```
2024-06-07 09:39:03 -04:00
Paul Gauthier
52ac35fcd2 restore --show-diffs functionality #607 2024-05-23 14:07:20 -07:00
Paul Gauthier
6345cd3734 cleanup 2024-05-23 13:43:35 -07:00
Paul Gauthier
fb76895eb1 Merge branch 'main' into swe-bench 2024-05-23 13:36:23 -07:00
Paul Gauthier
a405defcff ask for confirmation 2024-05-22 21:27:59 -07:00
Paul Gauthier
5032adf44b Add the url content 2024-05-22 21:25:34 -07:00
Paul Gauthier
dc8ae596c3 aider: Implement regex to find all URLs in the input string.
# Aider chat conversation:

USER: do the todo

ASSISTANT: To address the TODO comment, we need to implement a regex to find all URLs in the input string. Here are the changes:

1. Import the `re` module for regular expressions.
2. Implement the `check_for_urls` method to find and process URLs in the input string.

Here are the *SEARCH/REPLACE* blocks:

aider/coders/base_coder.py
```python
<<<<<<< SEARCH
import hashlib
=======
import hashlib
import re
>>>>>>> REPLACE
```

aider/coders/base_coder.py
```python
<<<<<<< SEARCH
        # todo use a regex to find all urls in inp

        return inp
=======
        url_pattern = re.compile(
            r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
        )
        urls = url_pattern.findall(inp)
        if urls:
            self.io.tool_output(f"Found URLs: {', '.join(urls)}")
        return inp
>>>>>>> REPLACE
```

This will implement the functionality to find all URLs in the input string using a regular expression.
2024-05-22 21:19:44 -07:00
Paul Gauthier
aca24976a7 Add method to check for URLs in input. 2024-05-22 21:19:43 -07:00
Paul Gauthier
1effd73e80 Only expand the repomap if we know it will fit into context window 2024-05-20 10:22:57 -07:00
Paul Gauthier
fa0aa60c97 Merge branch 'main' into swe-bench 2024-05-20 09:39:29 -07:00
Paul Gauthier
9c28bbc98e Refactored linting process and error handling in commands. 2024-05-20 08:55:49 -07:00
Paul Gauthier
e758b01fb6 Merge branch 'main' into swe-bench 2024-05-19 15:20:46 -07:00
Paul Gauthier
04539feccb bump deps to get grep-ast 0.3.1 2024-05-19 15:10:57 -07:00
Paul Gauthier
5745657991 ask to fix lint/test 2024-05-19 15:02:16 -07:00
Paul Gauthier
038806f694 max_reflex=3, auto fix lint/test 2024-05-19 14:24:06 -07:00
Paul Gauthier
ec7af731e0 confirm auto lint and test 2024-05-19 10:26:06 -07:00
Paul Gauthier
cb6e7cabb6 Added lint/test_outcome 2024-05-19 08:13:20 -07:00
Paul Gauthier
0b18f3b4ef Add check to skip setting up lint commands if none are provided. 2024-05-19 07:42:39 -07:00
Paul Gauthier
25e44f584b aider: Fixed extra blank lines and added missing whitespace after a comma.
# Aider chat conversation:

USER: # Fix any errors below, if possible.

## Running: flake8 aider/coders/base_coder.py

aider/coders/base_coder.py:43:1: E303 too many blank lines (3)
aider/coders/base_coder.py:334:17: E231 missing whitespace after ','

## See relevant lines below marked with █.

aider/coders/base_coder.py:
...⋮...
 40│
 41│
 42│
 43█def wrap_fence(name):
 44│    return f"<{name}>", f"</{name}>"
 45│
 46│
 47│class Coder:
 48│    abs_fnames = None
...⋮...
331│                self.io.tool_output(json.dumps(self.functions, indent=4))
332│
333│    def setup_lint_cmds(self, lint_cmds):
334█        for lang,cmd in lint_cmds.items():
335│            self.linter.set_linter(lang, cmd)
336│
337│    def show_announcements(self):
...⋮...

ASSISTANT: Here are the necessary changes to fix the flake8 errors:

1. Remove the extra blank lines before the `wrap_fence` function.
2. Add a missing whitespace after the comma in the `setup_lint_cmds` function.

aider/coders/base_coder.py
```python
<<<<<<< SEARCH
class ExhaustedContextWindow(Exception):
    pass

def wrap_fence(name):
=======
class ExhaustedContextWindow(Exception):
    pass

def wrap_fence(name):
>>>>>>> REPLACE
```

aider/coders/base_coder.py
```python
<<<<<<< SEARCH
        for lang,cmd in lint_cmds.items():
=======
        for lang, cmd in lint_cmds.items():
>>>>>>> REPLACE
```
2024-05-19 07:40:48 -07:00
Paul Gauthier
9bd78d7ff3 Refactored lint command parsing and setup logic. 2024-05-19 07:40:41 -07:00
Paul Gauthier
990dda1122 Added empty lines for better readability. 2024-05-19 07:35:27 -07:00
Paul Gauthier
9ee332f5d9 Added options for automatic linting and testing after changes. 2024-05-19 07:34:19 -07:00
Paul Gauthier
b26969ea90 Refactored linting to use absolute file path. 2024-05-17 19:22:17 -07:00
Paul Gauthier
0412b19f6b aider: Fix flake8 errors by removing unnecessary f-string prefixes in aider/coders/base_coder.py.
# Aider chat conversation:

USER: I ran this command:

 pre-commit run --files aider/coders/base_coder.py

And got this output:

isort....................................................................Passed
black....................................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

aider/coders/base_coder.py:1135:32: F541 f-string is missing placeholders
            self.io.tool_error(f"The LLM did not conform to the edit format.")
                               ^
aider/coders/base_coder.py:1148:32: F541 f-string is missing placeholders
            self.io.tool_error(f"Exception while updating files:")
                               ^

ASSISTANT: Please add `aider/coders/base_coder.py` to the chat so I can propose the necessary changes to fix the flake8 errors.

USER: I added these *read-write* files: aider/coders/base_coder.py

ASSISTANT: Here are the changes to fix the flake8 errors related to the f-strings missing placeholders in `aider/coders/base_coder.py`:

```diff
--- aider/coders/base_coder.py
+++ aider/coders/base_coder.py
@@ ... @@
-            self.io.tool_error(f"The LLM did not conform to the edit format.")
+            self.io.tool_error("The LLM did not conform to the edit format.")
@@ ... @@
-            self.io.tool_error(f"Exception while updating files:")
+            self.io.tool_error("Exception while updating files:")
```

These changes remove the unnecessary f-string prefixes since there are no variables or expressions to be evaluated inside the strings.
2024-05-17 19:11:49 -07:00
Paul Gauthier
8f194c8313 Add reflection tracking and limit to Coder class. 2024-05-17 19:11:48 -07:00
Paul Gauthier
4b0c38254e added lint reflection 2024-05-17 16:58:04 -07:00
Paul Gauthier
819fccc7a4 added temp param, prompt strong that files message is truth 2024-05-16 08:52:30 -07:00
Paul Gauthier
ecc46bd3e3 16x 2024-05-14 14:04:45 -07:00
Paul Gauthier
73e6949287 refac 2024-05-14 11:12:36 -07:00
Paul Gauthier
6638efbee4 better prompting for LLM to suggest files 2024-05-14 06:02:16 -07:00
Paul Gauthier
292250db4f prompt and token adjustments when no files in chat with repo 2024-05-13 12:30:42 -07:00
Paul Gauthier
edc70bdf84 Handle multiline tool_error() better 2024-05-13 11:42:22 -07:00
Paul Gauthier
ea05cf05e1 Added --restore-chat-history 2024-05-13 11:09:28 -07:00
Paul Gauthier
90c0a5b9a4 reflect multiple messages; do not strip edit error messages 2024-05-11 16:40:37 -07:00
Paul Gauthier
0f9e314bb2 emit edit errors as proper tool_error() markdown 2024-05-11 15:38:03 -07:00
Paul Gauthier
602a0c7c31 refac utils.split_chat_history_markdown 2024-05-11 07:52:06 -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
1098b428e6 prompt tweaks, retry on httpx.ReadTimeout 2024-05-11 07:47:53 -07:00
Paul Gauthier
3171789b1f look for mentions with trailing : 2024-05-10 19:38:05 -07:00
Paul Gauthier
4eec60f42c updated assistant auto-reply to no files 2024-05-09 11:56:11 -07:00
Paul Gauthier
444d17de93 reverted prompt closer to e9da401, added helpful assistant replies to repo and files messages 2024-05-09 11:27:13 -07:00
Paul Gauthier
7a98953fae split repo map and added files into 2 user messages 2024-05-08 14:13:50 -07:00
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