Commit graph

1487 commits

Author SHA1 Message Date
Paul Gauthier
d54f883698 do not include added files in the repo map #315 2023-11-15 13:06:22 -08:00
Paul Gauthier
95fe1be4c5 /add and /drop should work on untracked files in a repo (without committing them) 2023-11-15 13:06:22 -08:00
Paul Gauthier
4aba307ebd defend against no tokenizer 2023-11-14 13:09:50 -08:00
Paul Gauthier
d2f924d6d1 fixed /tokens 2023-11-14 13:03:25 -08:00
Paul Gauthier
9cbe114a74 positivity 2023-11-14 11:34:36 -08:00
Paul Gauthier
253354da98 stronger elide prompt 2023-11-14 11:16:39 -08:00
Paul Gauthier
60ca8f8c0d properly render the main sys prompt 2023-11-14 11:07:35 -08:00
Paul Gauthier
bbc174a8fb just use the Rules as the reminder 2023-11-14 11:01:29 -08:00
Paul Gauthier
e0fea58276 Put back 2nd reminder 2023-11-14 10:46:16 -08:00
Paul Gauthier
26a340e21f move the single format reminder into the top sys prompt 2023-11-14 10:38:39 -08:00
Paul Gauthier
df236e4dec stronger prompt to include comments, docstrings 2023-11-14 10:30:02 -08:00
Paul Gauthier
3986da7210 just use a single S/R format system prompt 2023-11-14 10:25:08 -08:00
Paul Gauthier
c24a4a4392 refactor into Model.token_count() 2023-11-14 10:11:13 -08:00
Paul Gauthier
90f57664a6 aider: Refactor cmd_tokens to use main_model.token_count() instead of calling tokenizer directly.
# Aider chat conversation:

USER: in `cmd_tokens` make use of main_model.token_count() rather than calling tokenizer directly

ASSISTANT: To make this change, we need to modify `aider/commands.py`. Specifically, we will update the `cmd_tokens` method to use `self.coder.main_model.token_count()` instead of calling `self.tokenizer.encode()` directly.

Here is the *SEARCH/REPLACE* block for the change:

aider/commands.py
<source>python
<<<<<<< SEARCH
        tokens = len(self.tokenizer.encode(json.dumps(msgs)))
=======
        tokens = self.coder.main_model.token_count(json.dumps(msgs))
>>>>>>> REPLACE
</source>

aider/commands.py
<source>python
<<<<<<< SEARCH
            tokens = len(self.tokenizer.encode(msgs))
=======
            tokens = self.coder.main_model.token_count(msgs)
>>>>>>> REPLACE
</source>

aider/commands.py
<source>python
<<<<<<< SEARCH
                tokens = len(self.tokenizer.encode(repo_content))
=======
                tokens = self.coder.main_model.token_count(repo_content)
>>>>>>> REPLACE
</source>

aider/commands.py
<source>python
<<<<<<< SEARCH
            tokens = len(self.tokenizer.encode(content))
=======
            tokens = self.coder.main_model.token_count(content)
>>>>>>> REPLACE
</source>

These changes will ensure that the `cmd_tokens` method uses the `token_count` method from the `main_model` to calculate the number of tokens, which is a more abstracted and potentially model-specific way of counting tokens.
2023-11-14 10:04:00 -08:00
Paul Gauthier
c63885fe8c More rules, instructions 2023-11-13 15:28:01 -08:00
Paul Gauthier
8a3d4bf14c added second example showing new file 2023-11-13 15:07:15 -08:00
Paul Gauthier
50f457d753 prompt with clear example using multiple S/R blocks on the same file 2023-11-13 14:59:19 -08:00
Paul Gauthier
0253588616 set version to 0.17.1-dev 2023-11-06 20:27:37 -08:00
Paul Gauthier
393878120e version bump to 0.17.0 2023-11-06 20:27:12 -08:00
Paul Gauthier
5098be6172 Add context windows and pricing for 1106 models 2023-11-06 20:18:40 -08:00
Paul Gauthier
af71638b06 less simple, but docker image builds 2023-11-03 14:53:22 -07:00
Paul Gauthier
208fc7ae78 simpler 2023-11-03 14:45:49 -07:00
Paul Gauthier
87ab5495a7 Simplify scripting aider 2023-11-03 14:29:45 -07:00
Paul Gauthier
1fe48fd161 Updated /help messages 2023-11-03 09:23:04 -07: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
f3d3815201 Armor AutoCompleter against unicode errors #305 2023-11-03 07:26:21 -07:00
Paul Gauthier
d720bfe459 Properly test if /added file is already in the repo #314 2023-11-02 15:50:30 -07:00
Paul Gauthier
2609ec1b06 find_original_update_blocks now accepts fence param, raises on mangled <source>filename.ext #317 2023-11-02 12:05:39 -07:00
Paul Gauthier
f0711d4b96 Disable pretty when the fence is an html tag not triple-backticks 2023-11-02 10:52:55 -07:00
Paul Gauthier
b3bc8b0f2b Ask for concise S/R blocks 2023-11-02 10:09:18 -07:00
Paul Gauthier
5c9275191e aider: Refused to add blocked file by .gitignore and printed error message.
# Aider chat conversation:

USER: crash when /add a file which is blocked by .gitignore; we should catch the error, print a tool_error an

d refuse to /add the file
. > /add tmp/wordpress.py

Traceback (most recent call last):
  File "/home/m/.local/bin/aider", line 8, in <module>
    sys.exit(main())
  File "/home/m/.local/lib/python3.10/site-packages/aider/main.py", line 564, in main
    coder.run()
  File "/home/m/.local/lib/python3.10/site-packages/aider/coders/base_coder.py", line 319, in run
    new_user_message = self.run_loop()
  File "/home/m/.local/lib/python3.10/site-packages/aider/coders/base_coder.py", line 398, in run_loop
    return self.commands.run(inp)
  File "/home/m/.local/lib/python3.10/site-packages/aider/commands.py", line 73, in run
    return self.do_run(matching_commands[0][1:], rest_inp)
  File "/home/m/.local/lib/python3.10/site-packages/aider/commands.py", line 51, in do_run
    return cmd_method(args)
  File "/home/m/.local/lib/python3.10/site-packages/aider/commands.py", line 316, in cmd_add
    self.coder.repo.repo.git.add(abs_file_path)
  File "/home/m/.local/lib/python3.10/site-packages/git/cmd.py", line 741, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "/home/m/.local/lib/python3.10/site-packages/git/cmd.py", line 1315, in _call_process
    return self.execute(call, **exec_kwargs)
  File "/home/m/.local/lib/python3.10/site-packages/git/cmd.py", line 1109, in execute
    raise GitCommandError(redacted_command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
  cmdline: git add /home/m/Private/Projects/Freelance/nbdter69/pars_porntube/tmp/wordpress.py
  stderr: 'The following paths are ignored by one of your .gitignore files:
tmp
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"'

ASSISTANT: To handle this issue, we need to modify the `cmd_add` method in the `Commands` class in the `aider/commands.py` file. We will add a check to see if the file is ignored by git before trying to add it. If it is ignored, we will print an error message and skip adding the file.

Here is the *SEARCH/REPLACE block* for the change:

<source>python
aider/commands.py
<<<<<<< SEARCH
        for matched_file in all_matched_files:
            abs_file_path = self.coder.abs_root_path(matched_file)

            if not abs_file_path.startswith(self.coder.root):
                self.io.tool_error(
                    f"Can not add {abs_file_path}, which is not within {self.coder.root}"
                )
                continue

            if self.coder.repo and matched_file not in git_files:
                self.coder.repo.repo.git.add(abs_file_path)
                git_added.append(matched_file)

            if abs_file_path in self.coder.abs_fnames:
                self.io.tool_error(f"{matched_file} is already in the chat")
            else:
                content = self.io.read_text(abs_file_path)
                if content is None:
                    self.io.tool_error(f"Unable to read {matched_file}")
                else:
                    self.coder.abs_fnames.add(abs_file_path)
                    self.io.tool_output(f"Added {matched_file} to the chat")
                    added_fnames.append(matched_file)
=======
        for matched_file in all_matched_files:
            abs_file_path = self.coder.abs_root_path(matched_file)

            if not abs_file_path.startswith(self.coder.root):
                self.io.tool_error(
                    f"Can not add {abs_file_path}, which is not within {self.coder.root}"
                )
                continue

            if self.coder.repo and matched_file not in git_files:
                try:
                    self.coder.repo.repo.git.add(abs_file_path)
                    git_added.append(matched_file)
                except git.exc.GitCommandError as e:
                    self.io.tool_error(f"Unable to add {matched_file}: {str(e)}")
                    continue

            if abs_file_path in self.coder.abs_fnames:
                self.io.tool_error(f"{matched_file} is already in the chat")
            else:
                content = self.io.read_text(abs_file_path)
                if content is None:
                    self.io.tool_error(f"Unable to read {matched_file}")
                else:
                    self.coder.abs_fnames.add(abs_file_path)
                    self.io.tool_output(f"Added {matched_file} to the chat")
                    added_fnames.append(matched_file)
>>>>>>> REPLACE
</source>
2023-11-02 10:08:25 -07:00
paul-gauthier
b507ea087f
Merge pull request #310 from omri123/autocommit-bugfix
Do not autocommit after add if autocommit is disabled
2023-11-02 09:40:15 -07:00
Paul Gauthier
4e2e03dfef Pick up refs in elisp 2023-11-02 09:32:55 -07:00
Paul Gauthier
f0c575e413 use io.read_text to avoid unicode errors in repomap #305 2023-11-02 09:30:59 -07:00
Paul Gauthier
5df4f2f1a4 removed empty r tags file 2023-11-01 15:01:55 -07:00
Paul Gauthier
f6288d51b4 set version to 0.16.4-dev 2023-11-01 07:36:19 -07:00
Paul Gauthier
8fedf5f12e version bump to 0.16.3 2023-11-01 07:35:53 -07:00
Omri Bloch
e8c4b3cf81 Do not autocommit after add if autocommit is disabled 2023-11-01 10:28:45 +02:00
Paul Gauthier
05b0597f8b use grep-ast==0.2.4 to fully fix c-sharp bug 2023-10-31 16:48:44 -07:00
Paul Gauthier
007f54de16 set version to 0.16.3-dev 2023-10-31 15:10:39 -07:00
Paul Gauthier
0c9363062c version bump to 0.16.2 2023-10-31 15:10:14 -07:00
Paul Gauthier
4c31062b69 set version to 0.16.2-dev 2023-10-31 14:14:31 -07:00
Paul Gauthier
d710124d1d version bump to 0.16.1 2023-10-31 14:14:02 -07:00
Paul Gauthier
f4b59c923d set version to 0.16.1-dev 2023-10-29 13:24:51 -07:00
Paul Gauthier
92ea4c09a3 version bump to 0.16.0 2023-10-29 13:24:22 -07:00
Paul Gauthier
b6142af12b make sure **.txt does not crash chat #293 2023-10-25 15:52:26 -07:00
Paul Gauthier
15d3a5d581 Switch from "edit block" to "search/replace block"
Succeeded in tricky task in the grep-ast codebase:
- checkout ed714ffe58734 / tricky-search-and-replace-state
- "read and parse .gitignore once, not each time we recurse `enumerate_files`"
- was having a lot of trouble creating a head/updated block that matched the actual source code
- new search/replace block does much better

Benchmark had *best* try 1 result and *lowest* num_error_outputs ever seen on gpt-4-0613.
Low num_error_outputs means it's less likely to elide/... code in the before block (original/search).

──────────── tmp.benchmarks/2023-10-25-22-03-19--search-and-replace-and-think ─────────────
test-cases: 133
model: gpt-4
edit_format: diff
commit_hash: c9c2ddb
num_error_outputs: 6
num_user_asks: 0
num_exhausted_context_windows 0
test_timeouts: 2

50.4% correct after try 0
66.2% correct after try 1
2023-10-25 15:24:03 -07:00
Paul Gauthier
5edf20915f updated sample map 2023-10-22 15:06:35 -07:00
Paul Gauthier
3299d90317 Handle successive editblocks from same file w/o filename #267 2023-10-22 11:28:22 -07:00