seratch / slack-edge

Slack app development framework for edge functions with streamlined TypeScript support
https://github.com/seratch/slack-edge-app-template
MIT License
87 stars 5 forks source link

Interruption of Long Responses in Slack App Using Vercel Edge Functions with OpenAI's Chat API #5

Closed abc123931 closed 8 months ago

abc123931 commented 9 months ago

Hello,

I'm currently developing a Slack application that mentions and asks questions, receiving responses from ChatGPT. This app is built using Vercel Edge Functions and integrates with OpenAI's Chat API in stream mode. The process involves editing the messages using chat.update to create a streaming effect.

However, I'm encountering an issue where the processing of long responses gets interrupted after approximately 30 seconds. This seems to align with the behavior mentioned in an article regarding interruptions in processes handled by waitUntil.

I'm seeking advice or potential solutions to prevent this interruption and ensure longer responses are fully processed. Any suggestions or insights into this matter would be greatly appreciated.

Thank you for your assistance.

seratch commented 9 months ago

Hi @abc123931, thanks for writing in.

I don't have great knowledge on this topic but this discussion page may be helpful to you: https://github.com/orgs/vercel/discussions/3553 Apparently, there is no workaround so far. Therefore, executing the time-consuming code on a different runtime / platform asynchronously might be your only viable solution to this limitation.

I've also investigated the behavior of Cloudflare Workers in this situation. Unfortunately, it has the same limitation (this is not surpirising because Vercel Edge Functions is built upon CF Workers platform): https://community.cloudflare.com/t/waituntil-settimeout-how-long-will-waituntil-wait-for/368393

Consequently, just relying on any of these edge function platforms may not fulfill your needs as of today. Hope this clarifies things.

abc123931 commented 9 months ago

Hi @seratch Thank you for your response and the effort you put into researching this issue. I will consider alternative approaches.

seratch commented 8 months ago

Since this project does not have action items for this topic, let me close this issue now. If the platform offers an option to extend the time duration in the future, we are happy to support the use case!