snowby666 / poe-api-wrapper

👾 A Python API wrapper for Poe.com. With this, you will have free access to GPT-4, Claude, Llama, Gemini, Mistral and more! 🚀
https://pypi.org/project/poe-api-wrapper/
GNU General Public License v3.0
953 stars 111 forks source link

bug report: "TypeError: 'coroutine' object is not subscriptable" #168

Closed lbqc closed 5 months ago

lbqc commented 5 months ago

Bug Report

TypeError: 'coroutine' object is not subscriptable

Description

When calling AsyncPoeApi.send_message methods with a specified chatId parameter, an error occurs:

TypeError: 'coroutine' object is not subscriptable

The error occurs in the code located at: envs\poe_wrapper39\lib\site-packages\poe_api_wrapper\async_api.py:494:

self.current_thread[bot] = await self.get_chat_history(bot=bot)['data'][bot]

Steps to Reproduce

  1. Call the AsyncPoeApi.send_message method with a specified chatId parameter.
  2. Call the AsyncPoeApi.delete_chat method with a specified chatId parameter.

Resolution

The issue was resolved by modifying the code as follows:

# self.current_thread[bot] = await self.get_chat_history(bot=bot)['data'][bot]
temp = await self.get_chat_history(bot=bot)
self.current_thread[bot] = temp['data'][bot]

and

# chatdata = await self.get_chat_history(bot=bot)['data'][bot]
temp = await self.get_chat_history(bot=bot)
chatdata = temp['data'][bot]

Environment

snowby666 commented 5 months ago

Thanks for your report. This is resolved.