tiktoken
tiktoken copied to clipboard
Raise error when concurrent to call new Tiktoken
The context code is https://github.com/mckaywrigley/chatbot-ui/blob/main/pages/api/chat.ts#L21
The key problem is here:
In my frontend, I use promise.all to send 3 requests simultaneously to this backend API. I have noticed the following phenomena:
- When running this backend with "npm run dev", everything works fine.
- When running with "npm run build" and then "npm run start":
- If I make a separate request to this API after the backend is started, and then the frontend sends concurrent requests, everything works fine.
- If the frontend immediately sends concurrent requests to this backend API after it is started, it will result in the error shown in the image below.