You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
all destructure functions will not hold the correct reference to it's scope, not really know why, but executing them without using api (the reference) will throw an exception and it is hard to debug.
The following code works
import api from "gpt-tokenizer/esm/main"
import { ChatMessage } from "gpt-tokenizer/esm/GptEncoding"
api.modelName = 'YourModelName' // gpt-4
const chatTokens = api.encodeChat(historyChat, "gpt-4")
const currentTokenCount = chatTokens.length
const withinTokenLimit = api.isWithinTokenLimit(historyChat, tokenLimit)
Should we rework the documentation so it is clear that you should use the GptEncoding instance instead of the isolated functions? do you want me to open a PR?
Btw I'm using vite, and I'm not sure this could also be a bundling issue.
The text was updated successfully, but these errors were encountered:
From the documentation seems possible to import functions directly from gpt-tokenizer as:
But doing it and running that code will create an exception on the
GptEncoding
sincethis
inside of the execution will be undefined.on
clk100_base.js
:all destructure functions will not hold the correct reference to it's scope, not really know why, but executing them without using
api
(the reference) will throw an exception and it is hard to debug.The following code works
Should we rework the documentation so it is clear that you should use the
GptEncoding
instance instead of the isolated functions? do you want me to open a PR?Btw I'm using vite, and I'm not sure this could also be a bundling issue.
The text was updated successfully, but these errors were encountered: