@goliapkg/tiktoken-wasm 3.5.1 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -122,20 +122,28 @@ module.exports = {
122
122
 
123
123
  ### `listEncodings(): string[]`
124
124
 
125
- List all available encoding names (11 encodings).
125
+ List all available encoding names (17 encodings).
126
126
 
127
127
  ### `getEncoding(name: string): Encoding`
128
128
 
129
129
  Get a tokenizer by encoding name. Supported:
130
130
  - `cl100k_base` — GPT-4, GPT-3.5-turbo
131
- - `o200k_base` — GPT-4o, GPT-4.1, o1, o3
131
+ - `o200k_base` — GPT-4o, GPT-4.1, GPT-5–5.6, o1, o3, o4-mini
132
+ - `o200k_harmony` — gpt-oss (harmony chat format)
132
133
  - `p50k_base` — text-davinci-002/003
133
134
  - `p50k_edit` — text-davinci-edit
134
135
  - `r50k_base` — GPT-3 (davinci, curie, etc.)
136
+ - `gpt2` — GPT-2 (alias for `r50k_base`)
135
137
  - `llama3` — Meta Llama 3/4
136
138
  - `deepseek_v3` — DeepSeek V3/R1
137
139
  - `qwen2` — Qwen 2/2.5/3
138
- - `mistral_v3` — Mistral/Codestral/Pixtral
140
+ - `mistral_v3` — Mistral/Codestral/Pixtral (Tekken)
141
+ - `deepseek_v4` — DeepSeek V4 Pro/Flash
142
+ - `kimi_k2` — Kimi K2/K2.5/K2.6
143
+ - `kimi_k3` — Kimi K3
144
+ - `glm4` — GLM-4.5/4.6/4.7
145
+ - `glm5` — GLM-5/5.2
146
+ - `minimax_m2` — MiniMax M2 family
139
147
 
140
148
  ### `encodingForModel(model: string): Encoding`
141
149
 
@@ -161,7 +169,7 @@ Map a model name to its encoding name without loading the encoding.
161
169
 
162
170
  ### `estimateCost(modelId, inputTokens, outputTokens): number`
163
171
 
164
- Estimate API cost in USD. Supports 68 models across 7 providers.
172
+ Estimate API cost in USD. Supports 107 models across 10 providers.
165
173
 
166
174
  ### `getModelInfo(modelId): ModelInfo`
167
175
 
@@ -169,7 +177,7 @@ Get model metadata with full TypeScript typing.
169
177
 
170
178
  ### `allModels(): ModelInfo[]`
171
179
 
172
- List all 68 supported models with pricing info.
180
+ List all 107 supported models with pricing info.
173
181
 
174
182
  ### `modelsByProvider(provider): ModelInfo[]`
175
183
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@goliapkg/tiktoken-wasm",
3
3
  "type": "module",
4
4
  "description": "WASM bindings for the tiktoken BPE tokenizer",
5
- "version": "3.5.1",
5
+ "version": "3.7.0",
6
6
  "license": "MIT OR Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",
package/tiktoken_wasm.js CHANGED
@@ -275,7 +275,7 @@ export function allModels() {
275
275
  wasm.allModels(retptr);
276
276
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
277
277
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
278
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
278
+ var v1 = getArrayJsValueFromWasm0(r0, r1);
279
279
  wasm.__wbindgen_export(r0, r1 * 4, 4);
280
280
  return v1;
281
281
  } finally {
@@ -416,7 +416,7 @@ export function listEncodings() {
416
416
  wasm.listEncodings(retptr);
417
417
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
418
418
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
419
- var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
419
+ var v1 = getArrayJsValueFromWasm0(r0, r1);
420
420
  wasm.__wbindgen_export(r0, r1 * 4, 4);
421
421
  return v1;
422
422
  } finally {
@@ -441,7 +441,7 @@ export function modelToEncoding(model) {
441
441
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
442
442
  let v2;
443
443
  if (r0 !== 0) {
444
- v2 = getStringFromWasm0(r0, r1).slice();
444
+ v2 = getStringFromWasm0(r0, r1);
445
445
  wasm.__wbindgen_export(r0, r1 * 1, 1);
446
446
  }
447
447
  return v2;
@@ -466,7 +466,7 @@ export function modelsByProvider(provider) {
466
466
  wasm.modelsByProvider(retptr, ptr0, len0);
467
467
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
468
468
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
469
- var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
469
+ var v2 = getArrayJsValueFromWasm0(r0, r1);
470
470
  wasm.__wbindgen_export(r0, r1 * 4, 4);
471
471
  return v2;
472
472
  } finally {
@@ -476,11 +476,11 @@ export function modelsByProvider(provider) {
476
476
  function __wbg_get_imports() {
477
477
  const import0 = {
478
478
  __proto__: null,
479
- __wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
479
+ __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
480
480
  const ret = Error(getStringFromWasm0(arg0, arg1));
481
481
  return addHeapObject(ret);
482
482
  },
483
- __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
483
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
484
484
  throw new Error(getStringFromWasm0(arg0, arg1));
485
485
  },
486
486
  __wbg_modelinfo_new: function(arg0) {
@@ -663,11 +663,15 @@ function __wbg_finalize_init(instance, module) {
663
663
 
664
664
  async function __wbg_load(module, imports) {
665
665
  if (typeof Response === 'function' && module instanceof Response) {
666
+ if (!module.ok) {
667
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
668
+ }
669
+
666
670
  if (typeof WebAssembly.instantiateStreaming === 'function') {
667
671
  try {
668
672
  return await WebAssembly.instantiateStreaming(module, imports);
669
673
  } catch (e) {
670
- const validResponse = module.ok && expectedResponseType(module.type);
674
+ const validResponse = expectedResponseType(module.type);
671
675
 
672
676
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
673
677
  console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
Binary file