@goliapkg/tiktoken-wasm 3.2.4 → 3.3.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/LICENSE +21 -0
- package/README.md +12 -2
- package/package.json +2 -2
- package/tiktoken_wasm.d.ts +5 -4
- package/tiktoken_wasm.js +8 -9
- package/tiktoken_wasm_bg.wasm +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GOLIA株式会社
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# @goliapkg/tiktoken-wasm
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@goliapkg/tiktoken-wasm)
|
|
4
|
-
[](
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
**English** | [简体中文](README.zh-CN.md) | [日本語](README.ja.md)
|
|
5
7
|
|
|
6
8
|
WebAssembly bindings for the [tiktoken](https://crates.io/crates/tiktoken) BPE tokenizer — run multi-provider tokenization directly in the browser or Node.js with near-native performance.
|
|
7
9
|
|
|
@@ -211,6 +213,14 @@ Call `await init()` once before any other API calls. This loads and compiles the
|
|
|
211
213
|
|
|
212
214
|
See [`examples/react-app`](../tiktoken/examples/react-app/) for a complete Vite + React demo application.
|
|
213
215
|
|
|
216
|
+
<!-- ECOSYSTEM BEGIN (generated — edit ecosystem.toml, not this block) -->
|
|
217
|
+
|
|
218
|
+
## Ecosystem
|
|
219
|
+
|
|
220
|
+
[tiktoken](https://crates.io/crates/tiktoken) · **@goliapkg/tiktoken-wasm** · [instructors](https://crates.io/crates/instructors) · [chunkedrs](https://crates.io/crates/chunkedrs) · [embedrs](https://crates.io/crates/embedrs)
|
|
221
|
+
|
|
222
|
+
<!-- ECOSYSTEM END -->
|
|
223
|
+
|
|
214
224
|
## License
|
|
215
225
|
|
|
216
|
-
[MIT](
|
|
226
|
+
[MIT](LICENSE)
|
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
|
+
"version": "3.3.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
"sideEffects": [
|
|
19
19
|
"./snippets/*"
|
|
20
20
|
]
|
|
21
|
-
}
|
|
21
|
+
}
|
package/tiktoken_wasm.d.ts
CHANGED
|
@@ -104,6 +104,7 @@ export function estimateCost(model_id: string, input_tokens: number, output_toke
|
|
|
104
104
|
* Supported encodings:
|
|
105
105
|
* - `"cl100k_base"` — GPT-4, GPT-3.5-turbo
|
|
106
106
|
* - `"o200k_base"` — GPT-4o, GPT-4.1, o1, o3
|
|
107
|
+
* - `"o200k_harmony"` — gpt-oss (harmony chat format)
|
|
107
108
|
* - `"p50k_base"` — text-davinci-002/003
|
|
108
109
|
* - `"p50k_edit"` — text-davinci-edit
|
|
109
110
|
* - `"r50k_base"` — GPT-3 (davinci, curie, etc.)
|
|
@@ -162,7 +163,6 @@ export interface InitOutput {
|
|
|
162
163
|
readonly encoding_encode: (a: number, b: number, c: number, d: number) => void;
|
|
163
164
|
readonly encoding_encodeWithSpecialTokens: (a: number, b: number, c: number, d: number) => void;
|
|
164
165
|
readonly encoding_name: (a: number, b: number) => void;
|
|
165
|
-
readonly encoding_numSpecialTokens: (a: number) => number;
|
|
166
166
|
readonly encoding_vocabSize: (a: number) => number;
|
|
167
167
|
readonly estimateCost: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
168
168
|
readonly getEncoding: (a: number, b: number, c: number) => void;
|
|
@@ -170,13 +170,14 @@ export interface InitOutput {
|
|
|
170
170
|
readonly listEncodings: (a: number) => void;
|
|
171
171
|
readonly modelToEncoding: (a: number, b: number, c: number) => void;
|
|
172
172
|
readonly modelinfo_cachedInputPer1m: (a: number, b: number) => void;
|
|
173
|
-
readonly modelinfo_contextWindow: (a: number) => number;
|
|
174
173
|
readonly modelinfo_id: (a: number, b: number) => void;
|
|
174
|
+
readonly modelinfo_provider: (a: number, b: number) => void;
|
|
175
|
+
readonly modelsByProvider: (a: number, b: number, c: number) => void;
|
|
176
|
+
readonly encoding_numSpecialTokens: (a: number) => number;
|
|
177
|
+
readonly modelinfo_contextWindow: (a: number) => number;
|
|
175
178
|
readonly modelinfo_inputPer1m: (a: number) => number;
|
|
176
179
|
readonly modelinfo_maxOutput: (a: number) => number;
|
|
177
180
|
readonly modelinfo_outputPer1m: (a: number) => number;
|
|
178
|
-
readonly modelinfo_provider: (a: number, b: number) => void;
|
|
179
|
-
readonly modelsByProvider: (a: number, b: number, c: number) => void;
|
|
180
181
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
181
182
|
readonly __wbindgen_export: (a: number, b: number, c: number) => void;
|
|
182
183
|
readonly __wbindgen_export2: (a: number, b: number) => number;
|
package/tiktoken_wasm.js
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export class Encoding {
|
|
10
10
|
static __wrap(ptr) {
|
|
11
|
-
ptr = ptr >>> 0;
|
|
12
11
|
const obj = Object.create(Encoding.prototype);
|
|
13
12
|
obj.__wbg_ptr = ptr;
|
|
14
13
|
EncodingFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
@@ -166,7 +165,6 @@ if (Symbol.dispose) Encoding.prototype[Symbol.dispose] = Encoding.prototype.free
|
|
|
166
165
|
*/
|
|
167
166
|
export class ModelInfo {
|
|
168
167
|
static __wrap(ptr) {
|
|
169
|
-
ptr = ptr >>> 0;
|
|
170
168
|
const obj = Object.create(ModelInfo.prototype);
|
|
171
169
|
obj.__wbg_ptr = ptr;
|
|
172
170
|
ModelInfoFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
@@ -346,6 +344,7 @@ export function estimateCost(model_id, input_tokens, output_tokens) {
|
|
|
346
344
|
* Supported encodings:
|
|
347
345
|
* - `"cl100k_base"` — GPT-4, GPT-3.5-turbo
|
|
348
346
|
* - `"o200k_base"` — GPT-4o, GPT-4.1, o1, o3
|
|
347
|
+
* - `"o200k_harmony"` — gpt-oss (harmony chat format)
|
|
349
348
|
* - `"p50k_base"` — text-davinci-002/003
|
|
350
349
|
* - `"p50k_edit"` — text-davinci-edit
|
|
351
350
|
* - `"r50k_base"` — GPT-3 (davinci, curie, etc.)
|
|
@@ -476,11 +475,11 @@ export function modelsByProvider(provider) {
|
|
|
476
475
|
function __wbg_get_imports() {
|
|
477
476
|
const import0 = {
|
|
478
477
|
__proto__: null,
|
|
479
|
-
|
|
478
|
+
__wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
|
|
480
479
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
481
480
|
return addHeapObject(ret);
|
|
482
481
|
},
|
|
483
|
-
|
|
482
|
+
__wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
|
|
484
483
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
485
484
|
},
|
|
486
485
|
__wbg_modelinfo_new: function(arg0) {
|
|
@@ -501,10 +500,10 @@ function __wbg_get_imports() {
|
|
|
501
500
|
|
|
502
501
|
const EncodingFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
503
502
|
? { register: () => {}, unregister: () => {} }
|
|
504
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_encoding_free(ptr
|
|
503
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_encoding_free(ptr, 1));
|
|
505
504
|
const ModelInfoFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
506
505
|
? { register: () => {}, unregister: () => {} }
|
|
507
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_modelinfo_free(ptr
|
|
506
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_modelinfo_free(ptr, 1));
|
|
508
507
|
|
|
509
508
|
function addHeapObject(obj) {
|
|
510
509
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
@@ -545,8 +544,7 @@ function getDataViewMemory0() {
|
|
|
545
544
|
}
|
|
546
545
|
|
|
547
546
|
function getStringFromWasm0(ptr, len) {
|
|
548
|
-
|
|
549
|
-
return decodeText(ptr, len);
|
|
547
|
+
return decodeText(ptr >>> 0, len);
|
|
550
548
|
}
|
|
551
549
|
|
|
552
550
|
let cachedUint32ArrayMemory0 = null;
|
|
@@ -651,8 +649,9 @@ if (!('encodeInto' in cachedTextEncoder)) {
|
|
|
651
649
|
|
|
652
650
|
let WASM_VECTOR_LEN = 0;
|
|
653
651
|
|
|
654
|
-
let wasmModule, wasm;
|
|
652
|
+
let wasmModule, wasmInstance, wasm;
|
|
655
653
|
function __wbg_finalize_init(instance, module) {
|
|
654
|
+
wasmInstance = instance;
|
|
656
655
|
wasm = instance.exports;
|
|
657
656
|
wasmModule = module;
|
|
658
657
|
cachedDataViewMemory0 = null;
|
package/tiktoken_wasm_bg.wasm
CHANGED
|
Binary file
|