Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run the tiktokenizer from the app folder in next.js #14

Open
gablabelle opened this issue Aug 19, 2023 · 2 comments
Open

Can't run the tiktokenizer from the app folder in next.js #14

gablabelle opened this issue Aug 19, 2023 · 2 comments

Comments

@gablabelle
Copy link

Hello,

Trying to run tiktokenizer from the app folder and I'm getting the following error:

Error: Element type is invalid. Received a promise that resolves to: [object Promise]. Lazy element type must resolve to a class or function.

Here is the branch to reproduce the error.

Screenshot 2023-08-19 at 13 41 48

@gablabelle gablabelle changed the title Error: Element type is invalid. Received a promise that resolves to: [object Promise]. Lazy element type must resolve to a class or function. Can't run the tiktokenizer from the app folder in next.js Aug 19, 2023
@dqbd
Copy link
Owner

dqbd commented Nov 15, 2023

Hi @gablabelle! Thanks for the contribution. I've tried to use the new App Router as well, but it does seem like there's some upstream issue with React Server Components (RSC) and NextJS implementation which does not allow importing WASM modules / the WASM package of tiktoken.

One possible solution would be to replace tiktoken with js-tiktoken, if that's needed, but I'm still keen on experimenting with WASM and RSC 🙂

@gablabelle
Copy link
Author

Hi @gablabelle! Thanks for the contribution. I've tried to use the new App Router as well, but it does seem like there's some upstream issue with React Server Components (RSC) and NextJS implementation which does not allow importing WASM modules / the WASM package of tiktoken.

One possible solution would be to replace tiktoken with js-tiktoken, if that's needed, but I'm still keen on experimenting with WASM and RSC 🙂

I've since migrated to js-tiktoken and it works! 👍🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants