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
Issues importing the package #1
Comments
Ahh, thanks for submitting the issue. Currently it is built with NodeJS only packages and I need to swap out implementation for the TextEncoder and TextDecoder in order for browser usage. I will spend some time this week to do it. I think there is an npm package called lib0 that can resolve the issue. If you have some extra time please give a hand and take a crack at it! Cheers! |
@Tymek Please try the latest v1.1.2, it should work on the browser now. Please let me know if there are any more issues! |
Hello @lhr0909 I have tested your update https://github.com/Niputi/vite-tests/tree/npm-gpt3-tokenizer
fyi. if you want to export more stuff later, it's better export code as named exports instead of defaults as default and named exports dont go well together |
This is what worked for me (node tokenizer.mjsimport GPT3Tokenizer from 'gpt3-tokenizer'
const tokenizer = new GPT3Tokenizer.default({ type: 'gpt3' })
const str = "hello 👋 world 🌍";
const encoded = tokenizer.encode(str);
const decoded = tokenizer.decode(encoded.bpe);
console.log(encoded);
console.log(decoded); |
No matching export in "browser-external:util" for import "TextEncoder"
in Vite (SvelteKit).Edit: this might be related: vitejs/vite#6493
The text was updated successfully, but these errors were encountered: