dqbd / tiktoken

JS port and JS/WASM bindings for openai/tiktoken
MIT License
649 stars 49 forks source link

Cloudflare worker Uncaught ReferenceError: FinalizationRegistry is not defined #46

Closed EiffelFly closed 11 months ago

EiffelFly commented 1 year ago

Hi, thanks for building this tool! I had encountered a problem when I tried to run this repo in cloudflare worker.

you could go to this repo to reproduce repo

Then you will see the issue happening.

It is quite hard to find the solution on the web, so I am curious about how do you test the package on Cloudflare worker and make it work.

KittenYang commented 1 year ago

same here

KittenYang commented 1 year ago

back to this repo: https://github.com/niieani/gpt-tokenizer

dqbd commented 1 year ago

Hi! This does seem to be a regression caused by 1.0.7, will address this issue in later versions.

In the meantime, js-tiktoken is a pure JS version of the package, which should be more suitable for edge runtimes such as Cloudflare Workers.

EiffelFly commented 1 year ago

@dqbd I can confirm js-toktoken is working correctly in edge-runtime due to langchainjs use this package under the hood!! Thanks for the head up.

iwasrobbed commented 1 year ago

Thanks @dqbd ! I was a bit confused as well since the readme still points towards using the wasm version

Is the plan to maintain both wasm and JS going forward?

dqbd commented 11 months ago

Yep! Both of the libraries have their advantages and disadvantages and the plan is to support both for the foreseeable future.

gablabelle commented 9 months ago

@dqbd I'm having the same issue on Vercel (edge function). Since you've closed the issue, what was the resolution of the problem? Migrate to js-tiktoken I guess? ;-)

poweroutlet2 commented 7 months ago

Still running into this error using Vercel edge functions. Any updates here? Using js-tiktoken seems to make the edge function size >1MB