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

Review GPToken #3

Open
syonfox opened this issue Mar 10, 2023 · 7 comments
Open

Review GPToken #3

syonfox opened this issue Mar 10, 2023 · 7 comments

Comments

@syonfox
Copy link
Owner

syonfox commented Mar 10, 2023

Making a new branch for development GPToken ... master seems to work for vanilla and browser and be stable

@Shackless
Copy link

I'm trying to use it in SvelteKit/TS and get this error:

import { countTokens as countTokensExt } from 'gptoken';

function whatever() {
   const num_tokens += countTokensExt("Oh Hello");
}

Error: Buffer is not defined:

image

@syonfox
Copy link
Owner Author

syonfox commented Mar 15, 2023 via email

@Shackless
Copy link

Oh yeah, I'm trying to run it in the browser (client-side). I installed the Buffer browser version but it sets window.buffer instead of window.Buffer (capital B). Would be great if you could get rid of this dependency and make your package standalone and runnable without Node.

@syonfox
Copy link
Owner Author

syonfox commented Mar 15, 2023

Have you tried including the bundled source in you client side? browser.js not index.js

I belive browserify does generate polyfills for any node thing used. see #4

@z0d14c
Copy link

z0d14c commented Mar 24, 2023

I also cannot use because of Buffer is not defined

@syonfox
Copy link
Owner Author

syonfox commented Mar 24, 2023

I also cannot use it because of Buffer is not defined

Can you give me any more information? Are you sure its not the same issue where you are including the node code in the browser instead of browser.js

@syonfox
Copy link
Owner Author

syonfox commented Sep 27, 2023

https://github.com/feross/buffer

With browserify, simply require('buffer') or use the Buffer global and you will get this module.

I am using Browserify so you should get a version with polyfill

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

3 participants