I’ve built a ChatGPT-enabled Remix application for a client, and it works great when run locally, but fails when run deployed on Netlify.
My suspicion in that the “ActionFunction” that calls the ChatGPT API is timing out because their API is REALLY slow-- to the tune of a minute or two to respond usually. I need the action to just wait for it and then take some actions (i.e., stuff the results into an API).
Now, I read that there’s a -background
trick to get things to run asynchronously in the background. Is there some way to get a Remix action to take advantage of that? If I rename the API route filename something-background.ts
does that do it?
Can anyone suggest any other method for me to allow these ChatGPT calls to run asynchronously within the context of this Remix deploy.
I know that I can do twenty other approaches if I just fire up a lambda in AWS, for instance, but I’d love to keep this all contained in this one site deployment. It’s really just a matter of giving the ActionFunction a few minutes to wait for the ChatGPT API to reply.
Open to suggestions!