Merge branch 'main' into gemini-editblock-and-examples

This commit is contained in:
Paul Gauthier 2024-05-01 09:02:08 -07:00
commit 0fb08896e3
6 changed files with 34 additions and 6 deletions

View file

@ -11,6 +11,7 @@ from json.decoder import JSONDecodeError
from pathlib import Path from pathlib import Path
import git import git
import litellm
import openai import openai
from jsonschema import Draft7Validator from jsonschema import Draft7Validator
from rich.console import Console, Text from rich.console import Console, Text
@ -28,6 +29,8 @@ from aider.utils import is_image_file
from ..dump import dump # noqa: F401 from ..dump import dump # noqa: F401
litellm.suppress_debug_info = True
class MissingAPIKeyError(ValueError): class MissingAPIKeyError(ValueError):
pass pass
@ -597,6 +600,9 @@ class Coder:
interrupted = True interrupted = True
except ExhaustedContextWindow: except ExhaustedContextWindow:
exhausted = True exhausted = True
except litellm.exceptions.BadRequestError as err:
self.io.tool_error(f"BadRequestError: {err}")
return
except openai.BadRequestError as err: except openai.BadRequestError as err:
if "maximum context length" in str(err): if "maximum context length" in str(err):
exhausted = True exhausted = True

View file

@ -67,6 +67,7 @@ mathweb/flask/app.py
return str(math.factorial(n)) return str(math.factorial(n))
>>>>>>> REPLACE >>>>>>> REPLACE
{fence[1]} {fence[1]}
<<<<<<< HEAD
""", """,
), ),
dict( dict(

View file

@ -115,7 +115,7 @@ You always COMPLETELY IMPLEMENT the needed code!
files_no_full_files = "I am not sharing any *read-write* files yet." 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*. 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*. To make a file *read-write*, ask the user to *add it to the chat*.
""" """

View file

@ -349,10 +349,12 @@ class Commands:
self.io.tool_error(f"Skipping {fname} that matches aiderignore spec.") self.io.tool_error(f"Skipping {fname} that matches aiderignore spec.")
continue continue
if fname.exists() and fname.is_file(): if fname.exists():
all_matched_files.add(str(fname)) if fname.is_file():
continue all_matched_files.add(str(fname))
# an existing dir will fall through and get recursed by glob 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) matched_files = self.glob_filtered_to_repo(word)
if matched_files: if matched_files:

View file

@ -25,7 +25,7 @@ litellm.suppress_debug_info = True
RateLimitError, RateLimitError,
APIConnectionError, APIConnectionError,
httpx.ConnectError, httpx.ConnectError,
litellm.exceptions.BadRequestError, litellm.exceptions.ServiceUnavailableError,
), ),
max_tries=10, max_tries=10,
on_backoff=lambda details: print( 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: if not stream and CACHE is not None and key in CACHE:
return hash_object, CACHE[key] return hash_object, CACHE[key]
# del kwargs['stream']
res = litellm.completion(**kwargs) res = litellm.completion(**kwargs)
if not stream and CACHE is not None: if not stream and CACHE is not None:

View file

@ -386,6 +386,23 @@ class TestCommands(TestCase):
self.assertIn(str(fname.resolve()), coder.abs_fnames) 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): def test_cmd_add_abs_filename(self):
with ChdirTemporaryDirectory(): with ChdirTemporaryDirectory():
io = InputOutput(pretty=False, yes=False) io = InputOutput(pretty=False, yes=False)