paul-gauthier / aider

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

Uncaught AttributeError in sendchat.py line 30 #1749

Closed plm66 closed 3 days ago

plm66 commented 3 days ago

Aider version: 0.56.1.dev111+ge6037140 Python version: 3.11.3 Platform: macOS-15.1-arm64-arm-64bit Python implementation: CPython Virtual environment: No OS: Darwin 24.1.0 (64bit) Git version: git version 2.45.1

An uncaught exception occurred:

Traceback (most recent call last):
  File "openai.py", line 907, in completion
    raise e
  File "openai.py", line 784, in completion
    return self.streaming(
           ^^^^^^^^^^^^^^^
  File "openai.py", line 1025, in streaming
    openai_client: OpenAI = self._get_openai_client(  # type: ignore
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "openai.py", line 617, in _get_openai_client
    _new_client = OpenAI(
                  ^^^^^^^
  File "_client.py", line 105, in __init__
    raise OpenAIError(
openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 1419, in completion
    raise e
  File "main.py", line 1392, in completion
    response = openai_chat_completions.completion(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "openai.py", line 914, in completion
    raise OpenAIError(
litellm.llms.OpenAI.openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "base_coder.py", line 1114, in send_message
    try:
        ^
  File "base_coder.py", line 1391, in send
    try:

  File "sendchat.py", line 87, 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 6492, in exception_type
    raise AuthenticationError(
litellm.exceptions.AuthenticationError: litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

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 709, in main
    coder.run()
  File "base_coder.py", line 722, in run
    user_message = self.get_input()
  File "base_coder.py", line 765, in run_one
    self.reflected_message = None
  File "base_coder.py", line 1116, in send_message
    break
       ^^^
  File "sendchat.py", line 30, in retry_exceptions
    litellm.llms.anthropic.chat.AnthropicError,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'litellm.llms.anthropic' has no attribute 'AnthropicError'
fry69 commented 3 days ago

Thank you for filing this issue.

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

aider --upgrade

Please do not forget to exit and restart aider after it updated itself.

Duplicate #1278