-
Notifications
You must be signed in to change notification settings - Fork 1
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
Comments
Hmm does svelte kit not have Buffer is node the backend I was worried
changing that dependency might break some environment... Perhaps we need to
include a pollyfill or in svelte you need to install the buffer
dependency... You could try using the browser version too.
…On Wed., Mar. 15, 2023, 07:28 Shackless, ***@***.***> wrote:
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: image]
<https://user-images.githubusercontent.com/306996/225281639-35e08dfe-34df-42a9-abfd-8d05ff6b08d2.png>
—
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACHJVDO7KHCMCPGLNRPNUKTW4GKUNANCNFSM6AAAAAAVVY4WOI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
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. |
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 |
I also cannot use because of |
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 |
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 |
Making a new branch for development GPToken ... master seems to work for vanilla and browser and be stable
The text was updated successfully, but these errors were encountered: