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

Poe: handle "Response timed out" exception #14

Closed
johnd0e opened this issue Aug 31, 2023 · 11 comments
Closed

Poe: handle "Response timed out" exception #14

johnd0e opened this issue Aug 31, 2023 · 11 comments

Comments

@johnd0e
Copy link

johnd0e commented Aug 31, 2023

At the moment this exception is thrown:

capybara : Traceback (most recent call last):
  File "D:\AI\poe-api-wrapper\poe_api_wrapper\api.py", line 481, in send_message
    message = self.message_queues[human_message_id].get(timeout=timeout)
  File "C:\Users\a\AppData\Local\Programs\Python\Python310\lib\queue.py", line 179, in get
    raise Empty
_queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\AI\poe-api-wrapper\example.py", line 3, in <module>
    Poe.chat_with_bot(token)
  File "D:\AI\poe-api-wrapper\poe_api_wrapper\api.py", line 935, in chat_with_bot
    for chunk in client.send_message(bot, message, chatId, suggest_replies=True, file_path=file_urls):
  File "D:\AI\poe-api-wrapper\poe_api_wrapper\api.py", line 485, in send_message
    raise RuntimeError("Response timed out.")
RuntimeError: Response timed out.

I suppose Poe should handle this, as it is pretty common case.

@snowby666
Copy link
Owner

I think it tends to be a problem with the poe.com website itself. Sometimes, even when I manually submit the question in the browser, the answer is not generated.

@johnd0e
Copy link
Author

johnd0e commented Sep 1, 2023

Sure it is poe.com problem.
And the subject of this issue is proper handling of this case, as it seems to be pretty common.

@snowby666
Copy link
Owner

I tried to reproduce this and caused the bot to enter a 'did not respond' loop, but I was only able to make it generate again by clearing the context and resending the message (kinda awkward). I suppose you could implement a try-except for that.

@7trail
Copy link

7trail commented Sep 1, 2023

Hello,

An issue I've been having is the POE backend not responding, but the api not catching the timeout and instead halting the program indefinitely. Do you think you might know what is causing this error? More details can be provided if needed.

@snowby666
Copy link
Owner

Hello,

An issue I've been having is the POE backend not responding, but the api not catching the timeout and instead halting the program indefinitely. Do you think you might know what is causing this error? More details can be provided if needed.

If your program is just halting but not in an inf loop then this may help:
You can inspect the api.py and will find that send_message has a timeout arg. You can set a lower value for this arg:

for chunk in client.send_message(bot, message, timeout=2):
      print(chunk['response'], end='', flush=True)

@johnd0e
Copy link
Author

johnd0e commented Sep 1, 2023

I suppose you could implement a try-except for that.

Do you mean something like this?

def main():
    try:
        Poe.chat_with_bot(token)
    except RuntimeError:
        main()

main()

This seems not to be a good solution, as then I must manually re-choose bot and thread (do I ever remember those?).
It would be much more convenient if Poe would recover from this error without user intervention, as it already knows both bot's name an thread's code.

@snowby666
Copy link
Owner

As I've mentioned above, I tried to reproduce this error, but my attempts to cancel and resend the message still results in "did not respond" loop. Currently, I could only clear the context and start over. Maybe this error has something to do with poe.com itself

@johnd0e
Copy link
Author

johnd0e commented Sep 1, 2023

Currently, I could only clear the context and start over.

Even if you are doing that on poe.com?

Currently, I could only clear the context and start over.

I understand. I this case instead of exception I would prefer to see such message:

Poe.com error. Please !clear context.

@snowby666
Copy link
Owner

snowby666 commented Sep 1, 2023

Currently, I could only clear the context and start over.

Even if you are doing that on poe.com?

Currently, I could only clear the context and start over.

I understand. I this case instead of exception I would prefer to see such message:

Poe.com error. Please !clear context.

Yeah. I think I will let the user to choose whether or not to clear the context if encounter this error. For now, if I can find another solution, I will implement it later

@johnd0e
Copy link
Author

johnd0e commented Sep 1, 2023

Thank you!

@snowby666
Copy link
Owner

This is temp fixed in the new version. The stability is improved but there may be some unexpected errors in the future.

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

No branches or pull requests

3 participants