diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 5658cb913..3d11c2e84 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -11,6 +11,7 @@ from json.decoder import JSONDecodeError from pathlib import Path import git +import litellm import openai from jsonschema import Draft7Validator from rich.console import Console, Text @@ -28,6 +29,8 @@ from aider.utils import is_image_file from ..dump import dump # noqa: F401 +litellm.suppress_debug_info = True + class MissingAPIKeyError(ValueError): pass @@ -597,6 +600,9 @@ class Coder: interrupted = True except ExhaustedContextWindow: exhausted = True + except litellm.exceptions.BadRequestError as err: + self.io.tool_error(f"BadRequestError: {err}") + return except openai.BadRequestError as err: if "maximum context length" in str(err): exhausted = True diff --git a/aider/coders/editblock_prompts.py b/aider/coders/editblock_prompts.py index 05e358a6c..58ee25294 100644 --- a/aider/coders/editblock_prompts.py +++ b/aider/coders/editblock_prompts.py @@ -67,6 +67,7 @@ mathweb/flask/app.py return str(math.factorial(n)) >>>>>>> REPLACE {fence[1]} +<<<<<<< HEAD """, ), dict( diff --git a/aider/coders/udiff_prompts.py b/aider/coders/udiff_prompts.py index abff70413..ab659c262 100644 --- a/aider/coders/udiff_prompts.py +++ b/aider/coders/udiff_prompts.py @@ -115,7 +115,7 @@ You always COMPLETELY IMPLEMENT the needed code! files_no_full_files = "I am not sharing any *read-write* files yet." - repo_content_prefix = """Below here are summaries of other files present in this git repository. + repo_content_prefix = """Below here are summaries of some files present in this git repository. Do not propose changes to these files, they are *read-only*. To make a file *read-write*, ask the user to *add it to the chat*. """ diff --git a/aider/commands.py b/aider/commands.py index 40581b0f9..3b6f359d5 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -349,10 +349,12 @@ class Commands: self.io.tool_error(f"Skipping {fname} that matches aiderignore spec.") continue - if fname.exists() and fname.is_file(): - all_matched_files.add(str(fname)) - continue - # an existing dir will fall through and get recursed by glob + if fname.exists(): + if fname.is_file(): + all_matched_files.add(str(fname)) + continue + # an existing dir, escape any special chars so they won't be globs + word = re.sub(r"([\*\?\[\]])", r"[\1]", word) matched_files = self.glob_filtered_to_repo(word) if matched_files: diff --git a/aider/sendchat.py b/aider/sendchat.py index 2cbbfd2d9..6c613d072 100644 --- a/aider/sendchat.py +++ b/aider/sendchat.py @@ -25,7 +25,7 @@ litellm.suppress_debug_info = True RateLimitError, APIConnectionError, httpx.ConnectError, - litellm.exceptions.BadRequestError, + litellm.exceptions.ServiceUnavailableError, ), max_tries=10, on_backoff=lambda details: print( @@ -50,6 +50,8 @@ def send_with_retries(model_name, messages, functions, stream): if not stream and CACHE is not None and key in CACHE: return hash_object, CACHE[key] + # del kwargs['stream'] + res = litellm.completion(**kwargs) if not stream and CACHE is not None: diff --git a/tests/test_commands.py b/tests/test_commands.py index 1751a359d..8cc67b6d8 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -386,6 +386,23 @@ class TestCommands(TestCase): self.assertIn(str(fname.resolve()), coder.abs_fnames) + def test_cmd_add_dirname_with_special_chars(self): + with ChdirTemporaryDirectory(): + io = InputOutput(pretty=False, yes=False) + from aider.coders import Coder + + coder = Coder.create(self.GPT35, None, io) + commands = Commands(io, coder) + + dname = Path("with[brackets]") + dname.mkdir() + fname = dname / "filename.txt" + fname.touch() + + commands.cmd_add(str(dname)) + + self.assertIn(str(fname.resolve()), coder.abs_fnames) + def test_cmd_add_abs_filename(self): with ChdirTemporaryDirectory(): io = InputOutput(pretty=False, yes=False)