aider icon indicating copy to clipboard operation
aider copied to clipboard

Uncaught AttributeError in sendchat.py line 30

Open bluchip6 opened this issue 1 year ago • 3 comments

Aider version: 0.56.0 Python version: 3.10.11 Platform: Windows-10-10.0.19045-SP0 Python implementation: CPython Virtual environment: No OS: Windows 10 (64bit) Git version: git version 2.30.0.windows.2

An uncaught exception occurred:

Traceback (most recent call last):
  File "runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "__main__.py", line 7, 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 1202, in send_message
    saved_message = self.auto_commit(edited)
  File "base_coder.py", line 1885, in auto_commit
    res = self.repo.commit(fnames=edited, context=context, aider_edits=True)
  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.AnthropicError,
AttributeError: module 'litellm.llms.anthropic' has no attribute 'AnthropicError'

bluchip6 avatar Sep 15 '24 23:09 bluchip6

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 aider venv for you.

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

This doc may be helpful -> https://aider.chat/docs/troubleshooting/imports.html

fry69 avatar Sep 16 '24 04:09 fry69

Same issue on my nix machine here - aider installed via nix unstable.aider-chat

Liu-Eroteme avatar Sep 16 '24 18:09 Liu-Eroteme

System packages sadly often get the dependencies wrong. Please find another way to install aider, pipx is known to work reliably.

fry69 avatar Sep 16 '24 18:09 fry69

Same issue on nix.

alexanderkjeldaas avatar Sep 17 '24 12:09 alexanderkjeldaas

Aider version: 0.56.0 Python version: 3.11.9 Platform: Linux-6.10.6-x86_64-with-glibc2.39 Python implementation: CPython Virtual environment: No OS: Linux 6.10.6 (64bit) Git version: git version 2.46.0

An uncaught 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 1413, in send
    raise kbi
  File "base_coder.py", line 1408, in send
    yield from self.show_send_output_stream(completion)
  File "base_coder.py", line 1482, in show_send_output_stream
    for chunk in completion:
  File "utils.py", line 10017, in __next__
    chunk = next(self.completion_stream)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "_streaming.py", line 43, in __next__
    return self._iterator.__next__()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "_streaming.py", line 58, in __stream__
    for sse in iterator:
  File "_streaming.py", line 50, in _iter_events
    yield from self._decoder.iter_bytes(self.response.iter_bytes())
  File "_streaming.py", line 280, in iter_bytes
    for chunk in self._iter_chunks(iterator):
  File "_streaming.py", line 291, in _iter_chunks
    for chunk in iterator:
  File "_models.py", line 829, in iter_bytes
    for raw_bytes in self.iter_raw():
  File "_models.py", line 883, in iter_raw
    for raw_stream_bytes in self.stream:
  File "_client.py", line 126, in __iter__
    for chunk in self._stream:
  File "default.py", line 113, in __iter__
    for part in self._httpcore_stream:
  File "connection_pool.py", line 367, in __iter__
    raise exc from None
  File "connection_pool.py", line 363, in __iter__
    for part in self._stream:
  File "http11.py", line 349, in __iter__
    raise exc
  File "http11.py", line 341, in __iter__
    for chunk in self._connection._receive_response_body(**kwargs):
  File "http11.py", line 210, in _receive_response_body
    event = self._receive_event(timeout=timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "http11.py", line 224, in _receive_event
    data = self._network_stream.read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sync.py", line 126, in read
    return self._sock.recv(max_bytes)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ssl.py", line 1295, in recv
    return self.read(buflen)
           ^^^^^^^^^^^^^^^^^
  File "ssl.py", line 1168, in read
    return self._sslobj.read(len)
           ^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".aider-wrapped", line 9, 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'

alexanderkjeldaas avatar Sep 17 '24 12:09 alexanderkjeldaas

These dependency/import error occur from installing aider via system packages, which do not respect the required dependencies aider needs.

Please install aider via pipx or venv.

This document may be helpful -> https://aider.chat/docs/troubleshooting/imports.html

Thank you.

fry69 avatar Sep 17 '24 12:09 fry69

The reporters here are using nix to manage versioning and global state on their computers. nixpkgs can build packages in various ways either using system packages, or converting existing dependencies into wrapped system packages etc. The inclusion of aider-chat into nixpkgs is quite fresh so maybe a solution can be found. This shouldn't be the only package among the 100.000 packages in nixpkgs that has this issue, so probably this can just be fixed.

Added a bug report in nixpkgs so the maintainer can take a look.

alexanderkjeldaas avatar Sep 17 '24 12:09 alexanderkjeldaas

Ah, I see that the original reporter was not using nix. Anyways for the nix-specific issue, I hope this can be solvable in nixpkgs.

alexanderkjeldaas avatar Sep 17 '24 12:09 alexanderkjeldaas

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