Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

litellm.exceptions.APIConnectionError: list index out of range #576

Closed
sudomain opened this issue Apr 25, 2024 · 4 comments
Closed

litellm.exceptions.APIConnectionError: list index out of range #576

sudomain opened this issue Apr 25, 2024 · 4 comments
Labels
question Further information is requested

Comments

@sudomain
Copy link

I get this error when trying to get aider to convert a ~50 line Bash script to Python. My Aider is installed via pipx in a Debian PRoot running in Termux.

Aider v0.30.1
Model: gemini/gemini-1.5-pro-latest with whole edit format
Git repo: .git with 67 files
Repo-map: using 1024 tokens
Added sss to the chat.
Use /help to see in-chat commands, run with --help to see cmd line args
──────────────────────────────────────────────────────────────────────────────────
sss> This is all written in Bash. I want to change it all to Python and use the prompt toolkit package to do so. Start by writing sss2.py and basing it off of sss

sss

Traceback (most recent call last):
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/litellm/utils.py", line 9735, in chunk_creator
    if hasattr(chunk.parts[0], "finish_reason"):
               ~~~~~~~~~~~^^^
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/proto/marshal/collections/repeated.py", line 125, in __getitem__
    return self._marshal.to_python(self._pb_type, self.pb[key])
                                                  ~~~~~~~^^^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/litellm/utils.py", line 9740, in chunk_creator
    if chunk.parts[0].finish_reason.name == "SAFETY":
       ~~~~~~~~~~~^^^
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/proto/marshal/collections/repeated.py", line 125, in __getitem__
    return self._marshal.to_python(self._pb_type, self.pb[key])
                                                  ~~~~~~~^^^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/litellm/utils.py", line 10218, in __next__
    response: Optional[ModelResponse] = self.chunk_creator(chunk=chunk)
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/litellm/utils.py", line 10149, in chunk_creator
    raise exception_type(
          ^^^^^^^^^^^^^^^
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/litellm/utils.py", line 8703, in exception_type
    raise e
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/litellm/utils.py", line 8678, in exception_type
    raise APIConnectionError(
litellm.exceptions.APIConnectionError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/userr/.local/bin/aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/aider/main.py", line 700, in main
    coder.run()
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/aider/coders/base_coder.py", line 397, in run
    new_user_message = self.run_loop()
                       ^^^^^^^^^^^^^^^
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/aider/coders/base_coder.py", line 481, in run_loop
    return self.send_new_user_message(inp)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/aider/coders/base_coder.py", line 536, in send_new_user_message
    interrupted = self.send(messages, functions=self.functions)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/aider/coders/base_coder.py", line 660, in send
    self.show_send_output_stream(completion)
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/aider/coders/base_coder.py", line 743, in show_send_output_stream
    for chunk in completion:
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/litellm/utils.py", line 10255, in __next__
    raise exception_type(
          ^^^^^^^^^^^^^^^
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/litellm/utils.py", line 8703, in exception_type
    raise e
  File "/home/userr/.local/pipx/venvs/aider-chat/lib/python3.11/site-packages/litellm/utils.py", line 8671, in exception_type
    raise APIConnectionError(
litellm.exceptions.APIConnectionError: list index out of ra
nge
@paul-gauthier
Copy link
Owner

Thanks for trying aider and filing this issue.

Are you using any sort of firewall or proxy that might be interfering with the Gemini API? As best I can tell, it looks like invalid responses are coming back from the API.

@paul-gauthier paul-gauthier added the question Further information is requested label Apr 29, 2024
@sudomain
Copy link
Author

sudomain commented Apr 29, 2024

The only thing I use along those lines is Netguard- a per-app firewall/internet permission manager. It shouldn't have affected it though because the app that aider is running in (Termux) has full access. Additionally I used aider successfully with other projects with this network config.

@krrishdholakia
Copy link

Hey @sudomain i've seen this with gemini before. I believe it's a misdirect b/c the responses often work on retrying. I'll map this error correctly

@paul-gauthier
Copy link
Owner

I think this has been resolved in recent versions of litellm/aider. I'm going to close this issue for now, but feel free to add a comment here and I will re-open or file a new issue any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants