Closed rlin415 closed 1 year ago
Make sure when you import, you are using the right import methods.
For TypeScript:
import GPT3Tokenizer from 'gpt3-tokenizer';
For NodeJS using require
, you need to access the default
field:
const GPT3Tokenizer = require('gpt3-tokenizer').default;
If you take a look at the projects that uses this lib, you can find how other people are importing it. Hope this helps!
In ES Module you have to do GPT3Tokenizer.default even if using an import statement
so the call to fix the OP's issue would be: const tokenizer = new GPT3Tokenizer.default({ type: 'gpt3' });
Hi, I get an error when trying to instantiate
GPT3Tokenizer
.gpt3-tokenizer v1.1.4 Node.js v18.12.1