We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Sadly due to MongoDB limitations see here TextEncoder and TextDecoder.
This is the error I get
{"message":"'TextEncoder' is not defined","name":"ReferenceError"}
Not sure if there is a workaround e.g. passing in an override or if using https://www.npmjs.com/package/util would help?
I tried to bodge overriding global, but Mongo stop you doing that...
if (typeof TextEncoder === "undefined") { global.TextEncoder = class TextEncoder { encode(str) { const utf8 = unescape(encodeURIComponent(str)); const result = new Uint8Array(utf8.length); for (let i = 0; i < utf8.length; i++) { result[i] = utf8.charCodeAt(i); } return result; } }; }
So I am at an impasse and can't use the library in this instance
This is a code snippet (can't share the whole function)
import { encodingForModel } from 'js-tiktoken'; function getTokenToken(content, model) { const enc = encodingForModel(model); const tokens = enc.encode(content); return tokens.length; }
The text was updated successfully, but these errors were encountered:
Just to say i have forked and published a version where it works with the utils dep.
No idea if its compatible with all scenarios, I cap raise an MR if of interest
https://github.com/georgeherby/tiktoken-mongodb
Sorry, something went wrong.
No branches or pull requests
Sadly due to MongoDB limitations see here TextEncoder and TextDecoder.
This is the error I get
Not sure if there is a workaround e.g. passing in an override or if using https://www.npmjs.com/package/util would help?
I tried to bodge overriding global, but Mongo stop you doing that...
So I am at an impasse and can't use the library in this instance
This is a code snippet (can't share the whole function)
The text was updated successfully, but these errors were encountered: