aider icon indicating copy to clipboard operation
aider copied to clipboard

Uncaught AttributeError in sendchat.py line 30

Open spectruma opened this issue 1 year ago • 1 comments

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'

spectruma avatar Sep 14 '24 11:09 spectruma

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).

fry69 avatar Sep 14 '24 12:09 fry69

This looks like a duplicate of #1278, so I'm going to close it so discussion can happen there. Please let me know if you think it's actually a distinct issue.

paul-gauthier avatar Sep 20 '24 18:09 paul-gauthier

What is the right version of LiteLLM to use right now? requirements file doesn't specify a version and it currently crashes with version 1.44.7

wordpad25 avatar Oct 27 '24 22:10 wordpad25