paul-gauthier / aider

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

Uncaught AttributeError in sendchat.py line 30 #1530

Open spectruma opened 4 days ago

spectruma commented 4 days ago

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

An uncaught exception occurred:

Traceback (most recent call last):
  File "chat.py", line 722, in make_sync_call
    response = client.post(
               ^^^^^^^^^^^^
  File "http_handler.py", line 346, in post
    raise e
  File "http_handler.py", line 332, in post
    response.raise_for_status()
  File "_models.py", line 763, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'https://api.anthropic.com/v1/messages'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 1545, in completion
    response = anthropic_chat_completions.completion(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "chat.py", line 1114, in completion
    completion_stream = make_sync_call(
                        ^^^^^^^^^^^^^^^
  File "chat.py", line 726, in make_sync_call
    raise AnthropicError(
litellm.llms.anthropic.chat.AnthropicError: b'{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "base_coder.py", line 1124, in send_message
    yield from self.send(messages, functions=self.functions)
  File "base_coder.py", line 1396, in send
    hash_object, completion = send_completion(
                              ^^^^^^^^^^^^^^^^
  File "sendchat.py", line 86, in send_completion
    res = litellm.completion(**kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "utils.py", line 1092, in wrapper
    raise e
  File "utils.py", line 980, in wrapper
    result = original_function(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "main.py", line 2802, in completion
    raise exception_type(
          ^^^^^^^^^^^^^^^
  File "utils.py", line 8189, in exception_type
    raise e
  File "utils.py", line 6636, in exception_type
    raise AuthenticationError(
litellm.exceptions.AuthenticationError: litellm.AuthenticationError: AnthropicException - b'{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}'

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 698, in main
    coder.run()
  File "base_coder.py", line 735, in run
    self.run_one(user_message, preproc)
  File "base_coder.py", line 778, in run_one
    list(self.send_message(message))
  File "base_coder.py", line 1126, in send_message
    except retry_exceptions() as err:
           ^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 30, in retry_exceptions
    litellm.llms.anthropic.AnthropicError,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'litellm.llms.anthropic' has no attribute 'AnthropicError'
fry69 commented 4 days ago

Thank you for filing this issue.

Please install aider separately from all other Python modules, as it needs specific versions. At best use pipx to let it manage the aidervenv for you.

The error you see comes from the fact that you installed a newer LiteLLM version than aider supports (currently 1.44.7).