T3 stack + Python Script?

I'm developing a web app that basically takes a PDF, processes the text, calls ChatGPT API and outputs a table for the user to edit, drag/drop rows, etc.. I've set up the project using T3 stack & deploying on Vercel however my PDF processing script is in Python and it takes as input a PDF and returns JSON. I'm not sure what the best way to integrate this Python script whether to spin up a separate lambda for it or integrate it on the same lambda (and if so how do I integrate a Python script into a Nextjs project). I attempted a separate Lambda on Vercel but it hangs and ends up timing out. However, when I spun up EC2 on AWS Elastic beanstalk it worked fine but feels inefficient to be managing two different services (AWS ebs & Vercel). Eventually I don't want to have a separate Python script but for the meantime I have to work with what I got.
2 Replies
Mendy
Mendy14mo ago
Use gpt to translate the python script to ts
Zan
Zan14mo ago
i don't think you want to be tying up the service that handles API calls with something CPU expensive like processing files. I would factor that into a separate service and communicate with pub/sub