@goliapkg/tiktoken-wasm 5.0.1 → 5.1.1
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-3RD-PARTY +5 -2
- package/README.md +5 -5
- package/package.json +1 -1
- package/tiktoken_wasm.d.ts +4 -4
- package/tiktoken_wasm.js +4 -4
- package/tiktoken_wasm_bg.wasm +0 -0
package/LICENSE-3RD-PARTY
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# Third-Party Licenses
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
A build of this crate embeds tokenizer vocabularies published by other
|
|
4
|
+
parties. Since 5.1.0 the data itself ships in the tiktoken-vocab-* crates, one
|
|
5
|
+
per vendor, each carrying its vendor's license; this file lists all of them in
|
|
6
|
+
one place. The crate's own code is licensed MIT OR Apache-2.0 (LICENSE-MIT,
|
|
7
|
+
LICENSE-APACHE);
|
|
5
8
|
each vocabulary stays under its publisher's license, listed below. The full
|
|
6
9
|
texts are in the `licenses/` directory next to this file, and the attribution
|
|
7
10
|
notices the licenses require are collected in NOTICE.
|
package/README.md
CHANGED
|
@@ -18,17 +18,17 @@ npm install @goliapkg/tiktoken-wasm
|
|
|
18
18
|
```bash
|
|
19
19
|
# requires wasm-pack: cargo install wasm-pack
|
|
20
20
|
cd tiktoken-wasm
|
|
21
|
-
wasm-pack build --target web --release
|
|
21
|
+
wasm-pack build --target web --release --scope goliapkg
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Output is in `pkg/` — a complete npm-ready package containing:
|
|
25
25
|
- `tiktoken_wasm.js` — ES module with WASM loader
|
|
26
26
|
- `tiktoken_wasm_bg.wasm` — compiled WASM binary (8.96 MB, 8.22 MB gzipped, all 20 vocabularies)
|
|
27
|
+
- `tiktoken_wasm.d.ts` — TypeScript type definitions
|
|
27
28
|
|
|
28
29
|
Building it yourself, `--no-default-features --features vocab-o200k_base` (or
|
|
29
30
|
any other `vocab-*` / vendor group forwarded from `tiktoken`) drops that to
|
|
30
|
-
1.
|
|
31
|
-
- `tiktoken_wasm.d.ts` — TypeScript type definitions
|
|
31
|
+
1.96 MB / 1.22 MB gzipped.
|
|
32
32
|
|
|
33
33
|
## Usage
|
|
34
34
|
|
|
@@ -68,7 +68,7 @@ const countST: number = enc.countWithSpecialTokens('hi<|endoftext|>bye')
|
|
|
68
68
|
console.log(enc.vocabSize) // 100256
|
|
69
69
|
console.log(enc.numSpecialTokens) // 5
|
|
70
70
|
|
|
71
|
-
// by model name —
|
|
71
|
+
// by model name — OpenAI, Meta, DeepSeek, Qwen, Mistral, Moonshot, Zhipu, MiniMax
|
|
72
72
|
const enc2 = encodingForModel('gpt-4o')
|
|
73
73
|
const encName = modelToEncoding('llama-4-scout') // "llama4"
|
|
74
74
|
|
|
@@ -126,7 +126,7 @@ module.exports = {
|
|
|
126
126
|
|
|
127
127
|
### `listEncodings(): string[]`
|
|
128
128
|
|
|
129
|
-
List all available encoding names (
|
|
129
|
+
List all available encoding names (20 encodings).
|
|
130
130
|
|
|
131
131
|
### `getEncoding(name: string): Encoding`
|
|
132
132
|
|
package/package.json
CHANGED
package/tiktoken_wasm.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export function allModels(): ModelInfo[];
|
|
|
84
84
|
/**
|
|
85
85
|
* Get an encoding for a model name (e.g. `"gpt-4o"`, `"o3-mini"`, `"llama-4"`, `"deepseek-r1"`).
|
|
86
86
|
*
|
|
87
|
-
* Supports models from OpenAI, Meta, DeepSeek, Qwen, and
|
|
87
|
+
* Supports models from OpenAI, Meta, DeepSeek, Qwen, Mistral, Moonshot, Zhipu and MiniMax.
|
|
88
88
|
* Automatically resolves the model name to the correct encoding.
|
|
89
89
|
* Throws `Error` for unknown model names.
|
|
90
90
|
*/
|
|
@@ -93,7 +93,7 @@ export function encodingForModel(model: string): Encoding;
|
|
|
93
93
|
/**
|
|
94
94
|
* Estimate cost in USD for a given model, input token count, and output token count.
|
|
95
95
|
*
|
|
96
|
-
* Supports OpenAI, Anthropic
|
|
96
|
+
* Supports 153 models across 11 providers: OpenAI, Anthropic, Google, Meta, DeepSeek, Alibaba, Mistral, Moonshot, Zhipu, MiniMax and Voyage models.
|
|
97
97
|
* Throws `Error` for unknown model ids.
|
|
98
98
|
*/
|
|
99
99
|
export function estimateCost(model_id: string, input_tokens: number, output_tokens: number): number;
|
|
@@ -103,7 +103,7 @@ export function estimateCost(model_id: string, input_tokens: number, output_toke
|
|
|
103
103
|
*
|
|
104
104
|
* Supported encodings:
|
|
105
105
|
* - `"cl100k_base"` — GPT-4, GPT-3.5-turbo
|
|
106
|
-
* - `"o200k_base"` — GPT-4o, GPT-4.1, GPT-5.x, GPT-6.x, o1, o3
|
|
106
|
+
* - `"o200k_base"` — GPT-4o, GPT-4.1, GPT-5.x, GPT-6.x (unconfirmed), o1, o3, o4-mini
|
|
107
107
|
* - `"o200k_harmony"` — gpt-oss (harmony chat format)
|
|
108
108
|
* - `"p50k_base"` — text-davinci-002/003
|
|
109
109
|
* - `"p50k_edit"` — text-davinci-edit
|
|
@@ -113,7 +113,7 @@ export function estimateCost(model_id: string, input_tokens: number, output_toke
|
|
|
113
113
|
* - `"llama4"` — Meta Llama 4, Muse
|
|
114
114
|
* - `"deepseek_v3"` — DeepSeek V3/R1
|
|
115
115
|
* - `"qwen2"` — Qwen 2/2.5/3
|
|
116
|
-
* - `"qwen3_5"` — Qwen 3.5–3.8
|
|
116
|
+
* - `"qwen3_5"` — Qwen 3.5–3.8, Qwen 4 (unconfirmed)
|
|
117
117
|
* - `"mistral_v3"` — Mistral/Codestral/Pixtral
|
|
118
118
|
* - `"mistral_v15"` — Mistral Large 4
|
|
119
119
|
* - `"deepseek_v4"`, `"kimi_k2"`, `"kimi_k3"`, `"glm4"`, `"glm5"`, `"minimax_m2"`
|
package/tiktoken_wasm.js
CHANGED
|
@@ -286,7 +286,7 @@ export function allModels() {
|
|
|
286
286
|
/**
|
|
287
287
|
* Get an encoding for a model name (e.g. `"gpt-4o"`, `"o3-mini"`, `"llama-4"`, `"deepseek-r1"`).
|
|
288
288
|
*
|
|
289
|
-
* Supports models from OpenAI, Meta, DeepSeek, Qwen, and
|
|
289
|
+
* Supports models from OpenAI, Meta, DeepSeek, Qwen, Mistral, Moonshot, Zhipu and MiniMax.
|
|
290
290
|
* Automatically resolves the model name to the correct encoding.
|
|
291
291
|
* Throws `Error` for unknown model names.
|
|
292
292
|
* @param {string} model
|
|
@@ -313,7 +313,7 @@ export function encodingForModel(model) {
|
|
|
313
313
|
/**
|
|
314
314
|
* Estimate cost in USD for a given model, input token count, and output token count.
|
|
315
315
|
*
|
|
316
|
-
* Supports OpenAI, Anthropic
|
|
316
|
+
* Supports 153 models across 11 providers: OpenAI, Anthropic, Google, Meta, DeepSeek, Alibaba, Mistral, Moonshot, Zhipu, MiniMax and Voyage models.
|
|
317
317
|
* Throws `Error` for unknown model ids.
|
|
318
318
|
* @param {string} model_id
|
|
319
319
|
* @param {number} input_tokens
|
|
@@ -345,7 +345,7 @@ export function estimateCost(model_id, input_tokens, output_tokens) {
|
|
|
345
345
|
*
|
|
346
346
|
* Supported encodings:
|
|
347
347
|
* - `"cl100k_base"` — GPT-4, GPT-3.5-turbo
|
|
348
|
-
* - `"o200k_base"` — GPT-4o, GPT-4.1, GPT-5.x, GPT-6.x, o1, o3
|
|
348
|
+
* - `"o200k_base"` — GPT-4o, GPT-4.1, GPT-5.x, GPT-6.x (unconfirmed), o1, o3, o4-mini
|
|
349
349
|
* - `"o200k_harmony"` — gpt-oss (harmony chat format)
|
|
350
350
|
* - `"p50k_base"` — text-davinci-002/003
|
|
351
351
|
* - `"p50k_edit"` — text-davinci-edit
|
|
@@ -355,7 +355,7 @@ export function estimateCost(model_id, input_tokens, output_tokens) {
|
|
|
355
355
|
* - `"llama4"` — Meta Llama 4, Muse
|
|
356
356
|
* - `"deepseek_v3"` — DeepSeek V3/R1
|
|
357
357
|
* - `"qwen2"` — Qwen 2/2.5/3
|
|
358
|
-
* - `"qwen3_5"` — Qwen 3.5–3.8
|
|
358
|
+
* - `"qwen3_5"` — Qwen 3.5–3.8, Qwen 4 (unconfirmed)
|
|
359
359
|
* - `"mistral_v3"` — Mistral/Codestral/Pixtral
|
|
360
360
|
* - `"mistral_v15"` — Mistral Large 4
|
|
361
361
|
* - `"deepseek_v4"`, `"kimi_k2"`, `"kimi_k3"`, `"glm4"`, `"glm5"`, `"minimax_m2"`
|
package/tiktoken_wasm_bg.wasm
CHANGED
|
Binary file
|