@goliapkg/tiktoken-wasm 3.2.0 → 3.2.2
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 +19 -9
- package/package.json +3 -1
- package/tiktoken_wasm.d.ts +1 -61
- package/tiktoken_wasm.js +6 -635
- package/tiktoken_wasm_bg.js +646 -0
- package/tiktoken_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -137,7 +137,7 @@ Get a tokenizer by encoding name. Supported:
|
|
|
137
137
|
|
|
138
138
|
### `encodingForModel(model: string): Encoding`
|
|
139
139
|
|
|
140
|
-
Get a tokenizer by model name (e.g. `gpt-4o`, `llama-4-scout`, `deepseek-r1`, `qwen3-
|
|
140
|
+
Get a tokenizer by model name (e.g. `gpt-4o`, `llama-4-scout`, `deepseek-r1`, `qwen3-max`).
|
|
141
141
|
|
|
142
142
|
### `modelToEncoding(model: string): string | null`
|
|
143
143
|
|
|
@@ -189,17 +189,27 @@ Filter models by provider: `"OpenAI"`, `"Anthropic"`, `"Google"`, `"Meta"`, `"De
|
|
|
189
189
|
|
|
190
190
|
| Provider | Models |
|
|
191
191
|
|----------|--------|
|
|
192
|
-
| OpenAI | gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-4o, gpt-4o-mini, o3, o3-pro, o3-mini, o4-mini,
|
|
193
|
-
| Anthropic | claude-opus-4, claude-sonnet-4, claude-4.5
|
|
194
|
-
| Google | gemini-2.5-pro, gemini-2.5-flash, gemini-2.0-flash, gemini-1.5-pro, gemini-1.5-flash |
|
|
195
|
-
| Meta | llama-4-scout, llama-4-maverick, llama-3.
|
|
196
|
-
| DeepSeek | deepseek-
|
|
197
|
-
|
|
|
198
|
-
| Mistral | mistral-large, mistral-medium, mistral-small, codestral, pixtral-large |
|
|
192
|
+
| OpenAI | gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-4o, gpt-4o-mini, o1, o1-mini, o1-pro, o3, o3-pro, o3-mini, o4-mini, gpt-4-turbo, gpt-4, gpt-3.5-turbo, text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002 |
|
|
193
|
+
| Anthropic | claude-opus-4.6, claude-sonnet-4.6, claude-haiku-4.5, claude-opus-4.5, claude-sonnet-4.5, claude-opus-4, claude-sonnet-4, claude-3.5-haiku, claude-3.5-sonnet, claude-3-opus, claude-3-haiku |
|
|
194
|
+
| Google | gemini-2.5-pro, gemini-2.5-flash, gemini-2.0-flash, gemini-1.5-pro, gemini-1.5-flash, text-embedding-004 |
|
|
195
|
+
| Meta | llama-4-scout, llama-4-maverick, llama-3.1-405b, llama-3.1-70b, llama-3.1-8b, llama-3.3-70b |
|
|
196
|
+
| DeepSeek | deepseek-v3, deepseek-r1 |
|
|
197
|
+
| Alibaba | qwen3-max, qwen3-plus, qwen3-coder, qwen3-8b, qwen2.5-72b, qwen2.5-32b, qwen2.5-7b |
|
|
198
|
+
| Mistral | mistral-large, mistral-medium, mistral-small, mistral-nemo, codestral, pixtral-large, mixtral-8x7b |
|
|
199
|
+
|
|
200
|
+
## Notes
|
|
201
|
+
|
|
202
|
+
### Initialization
|
|
203
|
+
|
|
204
|
+
Call `await init()` once before any other API calls. This loads and compiles the WASM module. Subsequent calls are a no-op.
|
|
205
|
+
|
|
206
|
+
### Memory Management
|
|
207
|
+
|
|
208
|
+
`Encoding` instances hold references to globally cached data and are lightweight. Calling `.free()` releases the JS wrapper — the underlying encoding data remains cached for reuse. In short-lived scripts you can skip `.free()`; in long-running apps, call it when you're done with the instance.
|
|
199
209
|
|
|
200
210
|
## Demo
|
|
201
211
|
|
|
202
|
-
See [`examples/react-app`](../examples/react-app/) for a complete Vite + React demo application.
|
|
212
|
+
See [`examples/react-app`](../tiktoken/examples/react-app/) for a complete Vite + React demo application.
|
|
203
213
|
|
|
204
214
|
## License
|
|
205
215
|
|
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.2.
|
|
5
|
+
"version": "3.2.2",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -11,11 +11,13 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"tiktoken_wasm_bg.wasm",
|
|
13
13
|
"tiktoken_wasm.js",
|
|
14
|
+
"tiktoken_wasm_bg.js",
|
|
14
15
|
"tiktoken_wasm.d.ts"
|
|
15
16
|
],
|
|
16
17
|
"main": "tiktoken_wasm.js",
|
|
17
18
|
"types": "tiktoken_wasm.d.ts",
|
|
18
19
|
"sideEffects": [
|
|
20
|
+
"./tiktoken_wasm.js",
|
|
19
21
|
"./snippets/*"
|
|
20
22
|
]
|
|
21
23
|
}
|
package/tiktoken_wasm.d.ts
CHANGED
|
@@ -131,7 +131,7 @@ export function getModelInfo(model_id: string): ModelInfo;
|
|
|
131
131
|
*
|
|
132
132
|
* Returns an array of strings: `["cl100k_base", "o200k_base", ...]`
|
|
133
133
|
*/
|
|
134
|
-
export function listEncodings():
|
|
134
|
+
export function listEncodings(): string[];
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* Map a model name to its encoding name without loading the encoding.
|
|
@@ -147,63 +147,3 @@ export function modelToEncoding(model: string): string | undefined;
|
|
|
147
147
|
* Returns an empty array for unknown providers.
|
|
148
148
|
*/
|
|
149
149
|
export function modelsByProvider(provider: string): ModelInfo[];
|
|
150
|
-
|
|
151
|
-
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
152
|
-
|
|
153
|
-
export interface InitOutput {
|
|
154
|
-
readonly memory: WebAssembly.Memory;
|
|
155
|
-
readonly __wbg_encoding_free: (a: number, b: number) => void;
|
|
156
|
-
readonly __wbg_modelinfo_free: (a: number, b: number) => void;
|
|
157
|
-
readonly allModels: () => [number, number];
|
|
158
|
-
readonly encodingForModel: (a: number, b: number) => [number, number, number];
|
|
159
|
-
readonly encoding_count: (a: number, b: number, c: number) => number;
|
|
160
|
-
readonly encoding_countWithSpecialTokens: (a: number, b: number, c: number) => number;
|
|
161
|
-
readonly encoding_decode: (a: number, b: number, c: number) => [number, number];
|
|
162
|
-
readonly encoding_encode: (a: number, b: number, c: number) => [number, number];
|
|
163
|
-
readonly encoding_encodeWithSpecialTokens: (a: number, b: number, c: number) => [number, number];
|
|
164
|
-
readonly encoding_name: (a: number) => [number, number];
|
|
165
|
-
readonly encoding_numSpecialTokens: (a: number) => number;
|
|
166
|
-
readonly encoding_vocabSize: (a: number) => number;
|
|
167
|
-
readonly estimateCost: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
168
|
-
readonly getEncoding: (a: number, b: number) => [number, number, number];
|
|
169
|
-
readonly getModelInfo: (a: number, b: number) => [number, number, number];
|
|
170
|
-
readonly listEncodings: () => [number, number];
|
|
171
|
-
readonly modelToEncoding: (a: number, b: number) => [number, number];
|
|
172
|
-
readonly modelinfo_cachedInputPer1m: (a: number) => [number, number];
|
|
173
|
-
readonly modelinfo_contextWindow: (a: number) => number;
|
|
174
|
-
readonly modelinfo_id: (a: number) => [number, number];
|
|
175
|
-
readonly modelinfo_inputPer1m: (a: number) => number;
|
|
176
|
-
readonly modelinfo_maxOutput: (a: number) => number;
|
|
177
|
-
readonly modelinfo_outputPer1m: (a: number) => number;
|
|
178
|
-
readonly modelinfo_provider: (a: number) => [number, number];
|
|
179
|
-
readonly modelsByProvider: (a: number, b: number) => [number, number];
|
|
180
|
-
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
181
|
-
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
182
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
183
|
-
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
184
|
-
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
185
|
-
readonly __externref_table_dealloc: (a: number) => void;
|
|
186
|
-
readonly __wbindgen_start: () => void;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
193
|
-
* a precompiled `WebAssembly.Module`.
|
|
194
|
-
*
|
|
195
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
196
|
-
*
|
|
197
|
-
* @returns {InitOutput}
|
|
198
|
-
*/
|
|
199
|
-
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
203
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
204
|
-
*
|
|
205
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
206
|
-
*
|
|
207
|
-
* @returns {Promise<InitOutput>}
|
|
208
|
-
*/
|
|
209
|
-
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|