Aider-AI / aider

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

Uncaught AttributeError in sendchat.py line 30 #1687

Closed rahimnathwani closed 3 weeks ago

rahimnathwani commented 4 weeks ago

Aider version: 0.56.0 Python version: 3.12.2 Platform: macOS-14.6.1-arm64-arm-64bit Python implementation: CPython Virtual environment: No OS: Darwin 23.6.0 (64bit) Git version: git version 2.46.0

An uncaught exception occurred:

Traceback (most recent call last):
  File "aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 698, in main
    return 1
  File "base_coder.py", line 735, in run
    return self.io.get_input(
                ^^^^^^^^^^^^^^
  File "base_coder.py", line 778, in run_one
    def check_for_urls(self, inp):
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "base_coder.py", line 1202, in send_message
  File "base_coder.py", line 1885, in auto_commit
    self.io.tool_error(f"Unable to commit: {str(err)}")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 102, in commit
    commit_message = self.get_commit_message(diffs, context)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 187, in get_commit_message
    commit_message = simple_send_with_retries(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 38, in wrapper
    retry_exceptions(),
    ^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 30, in retry_exceptions
    litellm.llms.anthropic.chat.AnthropicError,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'litellm.llms.anthropic' has no attribute 'AnthropicError'
fry69 commented 4 weeks ago

Thank you for filing this issue.

The fix is in the latest version (0.57.1), please update aider with

aider --upgrade

Duplicate #1278

rahimnathwani commented 4 weeks ago

Hmm... there's something I don't understand about aider's auto-update behaviour.

When I ran aider, it asked whether I wanted to update. I said yes.

After I quit aider, I checked which version I had installed:

% pip freeze|grep aider
aider-chat==0.57.1

But the bug report I filed said I was still using the old version.

So it seems like aider auto-updates on start, but continues to run the old version unless I quit and restart?

fry69 commented 4 weeks ago

So it seems like aider auto-updates on start, but continues to run the old version unless I quit and restart?

This is a possibility. Thank you for this comment.

fry69 commented 4 weeks ago

According to the source, aider should have told you to exit and restart after updating, see here -> https://github.com/paul-gauthier/aider/blob/main/aider/versioncheck.py#L58

Or did the old version instantly throw the error before it had a chance to complete the update etc? It may be that the error and long stack trace covered this message up?

rahimnathwani commented 4 weeks ago

Honestly when I start aider, I don't read the intro text. I type aider App.js index.html, and wait for the > prompt. If I don't see that prompt, only then do I read the preceding text to see what I should do.

I realise this isn't ideal. But it's probably common.

I will read more carefully from now on :)

fry69 commented 4 weeks ago

I will read more carefully from now on :)

Not your fault, I looked at the upgrade routine and it might just have continued if the actual upgrade failed, trying to fix it, see #1688

fry69 commented 4 weeks ago

This failed automatic test is interesting, it seems the success part never gets reached after the pip upgrade call? -> https://github.com/paul-gauthier/aider/actions/runs/11004313751/job/30554988710?pr=1688

fry69 commented 3 weeks ago

Sometimes the fix is very simple -> https://github.com/paul-gauthier/aider/commit/82ebb7713a200e4e7135e560efc43faca3f0ef1e