Aider-AI / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
20.74k stars 1.91k forks source link

Uncaught APIError in utils.py line 8123 #2107

Open SShadowS opened 2 hours ago

SShadowS commented 2 hours ago

Aider version: 0.59.1 Python version: 3.11.9 Platform: Windows-10-10.0.26100-SP0 Python implementation: CPython Virtual environment: Yes OS: Windows 10 (64bit) Git version: git version 2.46.2.windows.1

An uncaught exception occurred:

Traceback (most recent call last):
  File "openai.py", line 907, in completion
    raise e
  File "openai.py", line 840, in completion
    return convert_to_model_response_object(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "utils.py", line 5720, in convert_to_model_response_object
    raise raised_exception
Exception

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 1999, in completion
    response = openai_chat_completions.completion(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "openai.py", line 914, in completion
    raise OpenAIError(
litellm.llms.OpenAI.openai.OpenAIError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "__main__.py", line 7, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 757, in main
    coder.run()
  File "base_coder.py", line 730, in run
    self.run_one(user_message, preproc)
  File "base_coder.py", line 773, in run_one
    list(self.send_message(message))
  File "base_coder.py", line 1197, in send_message
    self.reply_completed()
  File "architect_coder.py", line 40, in reply_completed
    editor_coder.run(with_message=content, preproc=False)
  File "base_coder.py", line 724, in run
    self.run_one(with_message, preproc)
  File "base_coder.py", line 773, in run_one
    list(self.send_message(message))
  File "base_coder.py", line 1212, in send_message
    saved_message = self.auto_commit(edited)
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "base_coder.py", line 1895, in auto_commit
    res = self.repo.commit(fnames=edited, context=context, aider_edits=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 110, in commit
    commit_message = self.get_commit_message(diffs, context)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 195, in get_commit_message
    commit_message = simple_send_with_retries(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 44, in wrapper
    return decorated_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "_sync.py", line 105, in retry
    ret = target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 102, in simple_send_with_retries
    _hash, response = send_completion(**kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 83, in send_completion
    res = litellm.completion(**kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "utils.py", line 1086, in wrapper
    raise e
  File "utils.py", line 974, in wrapper
    result = original_function(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "main.py", line 2847, in completion
    raise exception_type(
          ^^^^^^^^^^^^^^^
  File "utils.py", line 8194, in exception_type
    raise e
  File "utils.py", line 8123, in exception_type
    raise APIError(
litellm.exceptions.APIError: litellm.APIError: APIError: OpenrouterException - 
SShadowS commented 2 hours ago

Additional info: image

Moukrea commented 1 hour ago

Aider version: 0.59.1 Python version: 3.10.12 Platform: Linux-6.5.0-1027-oem-x86_64-with-glibc2.35 Python implementation: CPython Virtual environment: No OS: Linux 6.5.0-1027-oem (64bit) Git version: git version 2.34.1

An uncaught exception occurred:

Traceback (most recent call last):
  File "openai.py", line 907, in completion
    raise e
  File "openai.py", line 840, in completion
    return convert_to_model_response_object(
  File "utils.py", line 5720, in convert_to_model_response_object
    raise raised_exception
Exception

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 1999, in completion
    response = openai_chat_completions.completion(
  File "openai.py", line 914, in completion
    raise OpenAIError(
litellm.llms.OpenAI.openai.OpenAIError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "aider", line 8, in <module>
    sys.exit(main())
  File "main.py", line 757, in main
    coder.run()
  File "base_coder.py", line 730, in run
    self.run_one(user_message, preproc)
  File "base_coder.py", line 773, in run_one
    list(self.send_message(message))
  File "base_coder.py", line 1212, in send_message
    saved_message = self.auto_commit(edited)
  File "base_coder.py", line 1895, in auto_commit
    res = self.repo.commit(fnames=edited, context=context, aider_edits=True)
  File "repo.py", line 110, in commit
    commit_message = self.get_commit_message(diffs, context)
  File "repo.py", line 195, in get_commit_message
    commit_message = simple_send_with_retries(
  File "sendchat.py", line 44, in wrapper
    return decorated_func(*args, **kwargs)
  File "_sync.py", line 105, in retry
    ret = target(*args, **kwargs)
  File "sendchat.py", line 102, in simple_send_with_retries
    _hash, response = send_completion(**kwargs)
  File "sendchat.py", line 83, in send_completion
    res = litellm.completion(**kwargs)
  File "utils.py", line 1086, in wrapper
    raise e
  File "utils.py", line 974, in wrapper
    result = original_function(*args, **kwargs)
  File "main.py", line 2847, in completion
    raise exception_type(
  File "utils.py", line 8194, in exception_type
    raise e
  File "utils.py", line 8123, in exception_type
    raise APIError(
litellm.exceptions.APIError: litellm.APIError: APIError: OpenrouterException - 

This issue occurs at every prompts I throw at it ever since I updated to latest version

Moukrea commented 57 minutes ago

I have a temporary solution, it wasn't related to the update on my side, it was because I was using a multi-line env variable for commit messages... Making it single line fixed the issue.

aider erroring out at every prompts:

AIDER_COMMIT_PROMPT="You are an expert software engineer that generates concise, \
one-line Git commit messages based on the provided diffs.
Review the provided context and diffs which are about to be committed to a git repo.
Review the diffs carefully.
Generate a one-line commit message for those changes.
The commit message should be structured as follows: <type>[optional scope]: <description>
Use these for <type>: fix, feat, build, chore, ci, docs, style, refactor, perf, test

A scope may be provided to a commit's type, to provide additional contextual information \
and is contained within parenthesis, e.g., feat(parser): add ability to parse arrays.

Ensure the commit message:
- Starts with the appropriate prefix.
- Is in the imperative mood (e.g., 'add feature' not 'added feature' or 'adding feature').
- Is all in lowercase
- Does not exceed 50 characters.

Reply only with the one-line commit message, without any additional text, explanations, \
or line breaks.
"

aider not failing anymore:

AIDER_COMMIT_PROMPT="You are an expert software engineer that generates concise, one-line Git commit messages based on the provided diffs. Review the provided context and diffs which are about to be committed to a git repo. Review the diffs carefully. Generate a one-line commit message for those changes. The commit message should be structured as follows: <type>[optional scope]: <description> Use these for <type>: fix, feat, build, chore, ci, docs, style, refactor, perf, test A scope may be provided to a commit's type, to provide additional contextual information and is contained within parenthesis, e.g., feat(parser): add ability to parse arrays. Ensure the commit message: - Starts with the appropriate prefix. - Is in the imperative mood (e.g., 'add feature' not 'added feature' or 'adding feature'). - Is all in lowercase - Does not exceed 50 characters. Reply only with the one-line commit message, without any additional text, explanations, or line breaks."