mishl-dev / Discord-AI-Chatbot

This Discord chatbot is incredibly versatile. Powered incredibly fast Groq API
GNU Affero General Public License v3.0
1.32k stars 417 forks source link

IndexError: list index out of range #128

Closed mishl-dev closed 1 year ago

mishl-dev commented 1 year ago

`Task exception was never retrieved future: <Task finished name='Task-36' coro=<on_message..generate_response_in_thread() done, defined at /workspace/Discord-AI-Chatbot/main.py:383> exception=IndexError('list index out of range')> Traceback (most recent call last): File "/workspace/Discord-AI-Chatbot/main.py", line 386, in generate_response_in_thread response = await generate_response(prompt) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/Discord-AI-Chatbot/main.py", line 142, in generate_response response = await aiassist.Completion.create(prompt=prompt) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/Discord-AI-Chatbot/model/aiassist.py", line 28, in create response = Completion.__load_json(content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/workspace/Discord-AI-Chatbot/model/aiassist.py", line 34, in __load_json split = decode_content.rsplit("\n", 1)[1]


IndexError: list index out of range`
mishl-dev commented 1 year ago

The error seems to be happening in the __load_json method of the aiassist.py file. It appears that the code is trying to split a string using the rsplit function and access the second element of the resulting list, but there might not be a second element in the list.

mishl-dev commented 1 year ago

Fixed in https://github.com/mishalhossin/Discord-AI-Chatbot/commit/14d6bb88100ca07e7b9bc8092a3186b440ec6cb3