seratch / ChatGPT-in-Slack

Swift demonstration of how to build a Slack app that enables end-users to interact with a ChatGPT bot
MIT License
437 stars 162 forks source link

Avoid timing out when bot is still writing #41

Closed diego-cowboy closed 1 year ago

diego-cowboy commented 1 year ago

There seems to be a bug for the timeout logic, the timeout doesn't reset when new data chunk are received. Since this fix, I've not seen this bug anymore. This is very useful when dealing with large response.

seratch commented 1 year ago

Hi @diego-cowboy, thanks for sending this PR! However, this is not a bug. The timeout means that the whole interaction with OpenAI API takes longer than the timeout duration time. In this scenario, the app tells an end-user that OpenAI didn't respond within the expected time: https://github.com/seratch/ChatGPT-in-Slack/blob/fcf38095584c63260e9ea1d7a4c963e4e16ccdb0/app/bolt_listeners.py#L161-L180

If yo want to avoid the timeout, you can set a longer value for OPENAI_TIMEOUT_SECONDS env variable. The default value is 30 (seconds). You can go with a much longer duration.

Let me close this PR. Thanks agan for sending it.