ghc-proxy 0.7.2 → 0.8.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/README.md +33 -16
- package/dist/main.mjs +41 -20
- package/package.json +3 -2
- package/dist/GptEncoding-DdY2evDX.mjs.map +0 -1
- package/dist/cl100k_base-ChJqEXhP.mjs.map +0 -1
- package/dist/file-type-BwbWtW7C.mjs.map +0 -1
- package/dist/main.mjs.map +0 -1
- package/dist/o200k_base-DXNwToXP.mjs.map +0 -1
- package/dist/p50k_base-BDWEQNXM.mjs.map +0 -1
- package/dist/p50k_base-Cab7w92R.mjs.map +0 -1
- package/dist/p50k_edit-DkrRw_em.mjs.map +0 -1
- package/dist/prompt-DsMdjS4d.mjs.map +0 -1
- package/dist/r50k_base-1vVxWqTY.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -59,8 +59,8 @@ Create or edit `~/.claude/settings.json` (this applies globally to all projects)
|
|
|
59
59
|
"env": {
|
|
60
60
|
"ANTHROPIC_BASE_URL": "http://localhost:4141",
|
|
61
61
|
"ANTHROPIC_AUTH_TOKEN": "dummy-token",
|
|
62
|
-
"ANTHROPIC_MODEL": "claude-opus-
|
|
63
|
-
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-
|
|
62
|
+
"ANTHROPIC_MODEL": "claude-opus-5",
|
|
63
|
+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5",
|
|
64
64
|
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4.5",
|
|
65
65
|
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
|
|
66
66
|
},
|
|
@@ -87,7 +87,7 @@ bunx ghc-proxy@latest start
|
|
|
87
87
|
| `ANTHROPIC_DEFAULT_HAIKU_MODEL` | The model used for Haiku-tier (fast/cheap) tasks |
|
|
88
88
|
| `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | Disables telemetry and non-essential network traffic |
|
|
89
89
|
|
|
90
|
-
> **Tip:** The model names above (e.g. `claude-opus-
|
|
90
|
+
> **Tip:** The model names above (e.g. `claude-opus-5`) are mapped to actual Copilot models by the proxy. See [Model Mapping](#model-mapping) below for details.
|
|
91
91
|
|
|
92
92
|
See the [Claude Code settings docs](https://docs.anthropic.com/en/docs/claude-code/settings#environment-variables) for more options.
|
|
93
93
|
|
|
@@ -120,6 +120,10 @@ bunx ghc-proxy@latest selfcheck # Probe the packaged bundle (loads every to
|
|
|
120
120
|
| `--proxy-env` | -- | `false` | Use `HTTP_PROXY`/`HTTPS_PROXY` from env (Node.js only; Bun reads proxy env natively) |
|
|
121
121
|
| `--idle-timeout` | -- | `120` | Bun server idle timeout in seconds (`0` disables; Bun max is `255`; streaming routes disable idle timeout automatically) |
|
|
122
122
|
| `--upstream-timeout` | -- | `1800` | Upstream request timeout in seconds (0 to disable) |
|
|
123
|
+
| `--upstream-queue-concurrency` | -- | `10` | Maximum concurrent Copilot upstream requests |
|
|
124
|
+
| `--upstream-queue-retries` | -- | `5` | Maximum retries for transient upstream responses (`408`, `429`, `500`, `502`, `503`, `504`, `529`) |
|
|
125
|
+
| `--upstream-queue-base-delay` | -- | `2` | Base delay in seconds for upstream retry backoff when `Retry-After` is absent |
|
|
126
|
+
| `--upstream-queue-max-delay` | -- | `60` | Maximum delay in seconds for upstream retry backoff |
|
|
123
127
|
| `--ghe-domain` | `--ghe` | -- | GitHub Enterprise Cloud company domain (e.g. `company.ghe.com`). Required for GHE.com device login on first run; persisted automatically for later runs. |
|
|
124
128
|
|
|
125
129
|
## Rate Limiting
|
|
@@ -184,10 +188,11 @@ All fields are optional. The full schema:
|
|
|
184
188
|
|
|
185
189
|
| Field | Type | Default | Description |
|
|
186
190
|
|-------|------|---------|-------------|
|
|
191
|
+
| `githubToken` | `string` | -- | Persisted GitHub token. Normally written automatically by `auth` / `--github-token`; you rarely set this by hand |
|
|
187
192
|
| `modelRewrites` | `{ from, to }[]` | -- | Glob-pattern model substitution rules (see [Model Rewrites](#model-rewrites)) |
|
|
188
193
|
| `modelFallback` | `object` | -- | Override default model fallbacks (see [Customizing Fallbacks](#customizing-fallbacks)) |
|
|
189
|
-
| `modelFallback.claudeOpus` | `string` | `claude-opus-
|
|
190
|
-
| `modelFallback.claudeSonnet` | `string` | `claude-sonnet-
|
|
194
|
+
| `modelFallback.claudeOpus` | `string` | `claude-opus-5` | Fallback for `claude-opus-*` models |
|
|
195
|
+
| `modelFallback.claudeSonnet` | `string` | `claude-sonnet-5` | Fallback for `claude-sonnet-*` models |
|
|
191
196
|
| `modelFallback.claudeHaiku` | `string` | `claude-haiku-4.5` | Fallback for `claude-haiku-*` models |
|
|
192
197
|
| `smallModel` | `string` | -- | Target model for compact request routing (see [Small-Model Routing](#small-model-routing)) |
|
|
193
198
|
| `compactUseSmallModel` | `boolean` | `false` | Route compact/summarization requests to `smallModel` |
|
|
@@ -199,7 +204,12 @@ All fields are optional. The full schema:
|
|
|
199
204
|
| `responsesApiParameterFiltersReplaceDefault` | `boolean` | `false` | Disable the built-in reasoning-model default rule so only your `responsesApiParameterFilters` apply |
|
|
200
205
|
| `responsesOfficialEmulator` | `boolean` | `false` | Enable local OpenAI-style Responses state emulation for `previous_response_id`, `conversation`, retrieve, input_items, delete, and input_tokens |
|
|
201
206
|
| `responsesOfficialEmulatorTtlSeconds` | `number` | `14400` | In-memory TTL for locally emulated Responses state |
|
|
202
|
-
| `modelReasoningEfforts` | `Record<string, string>` | -- | Per-model reasoning effort defaults for Anthropic-to-Responses translation |
|
|
207
|
+
| `modelReasoningEfforts` | `Record<string, string>` | -- | Per-model reasoning effort defaults for Anthropic-to-Responses translation. Each value must be one of `none`, `minimal`, `low`, `medium`, `high`, or `xhigh` |
|
|
208
|
+
| `upstreamQueueConcurrency` | `number` | `10` | Maximum concurrent Copilot upstream requests |
|
|
209
|
+
| `upstreamQueueMaxRetries` | `number` | `5` | Maximum retries for transient upstream responses (`408`, `429`, `500`, `502`, `503`, `504`, `529`) |
|
|
210
|
+
| `upstreamQueueBaseDelaySeconds` | `number` | `2` | Base delay (seconds) for upstream retry backoff when `Retry-After` is absent |
|
|
211
|
+
| `upstreamQueueMaxDelaySeconds` | `number` | `60` | Maximum delay (seconds) for upstream retry backoff |
|
|
212
|
+
| `gheDomain` | `string` | -- | GitHub Enterprise Cloud company domain (persisted automatically after GHE.com auth) |
|
|
203
213
|
|
|
204
214
|
Example:
|
|
205
215
|
|
|
@@ -209,8 +219,8 @@ Example:
|
|
|
209
219
|
{ "from": "claude-haiku-*", "to": "gpt-4.1-mini" }
|
|
210
220
|
],
|
|
211
221
|
"modelFallback": {
|
|
212
|
-
"claudeOpus": "claude-opus-
|
|
213
|
-
"claudeSonnet": "claude-sonnet-
|
|
222
|
+
"claudeOpus": "claude-opus-5",
|
|
223
|
+
"claudeSonnet": "claude-sonnet-5"
|
|
214
224
|
},
|
|
215
225
|
"smallModel": "gpt-4.1-mini",
|
|
216
226
|
"compactUseSmallModel": true,
|
|
@@ -240,8 +250,8 @@ When Claude Code sends a request for a model like `claude-sonnet-4.6`, the proxy
|
|
|
240
250
|
|
|
241
251
|
| Prefix | Default Fallback |
|
|
242
252
|
|--------|-----------------|
|
|
243
|
-
| `claude-opus-*` | `claude-opus-
|
|
244
|
-
| `claude-sonnet-*` | `claude-sonnet-
|
|
253
|
+
| `claude-opus-*` | `claude-opus-5` |
|
|
254
|
+
| `claude-sonnet-*` | `claude-sonnet-5` |
|
|
245
255
|
| `claude-haiku-*` | `claude-haiku-4.5` |
|
|
246
256
|
|
|
247
257
|
### Customizing Fallbacks
|
|
@@ -249,8 +259,8 @@ When Claude Code sends a request for a model like `claude-sonnet-4.6`, the proxy
|
|
|
249
259
|
You can override the defaults with **environment variables**:
|
|
250
260
|
|
|
251
261
|
```bash
|
|
252
|
-
MODEL_FALLBACK_CLAUDE_OPUS=claude-opus-
|
|
253
|
-
MODEL_FALLBACK_CLAUDE_SONNET=claude-sonnet-
|
|
262
|
+
MODEL_FALLBACK_CLAUDE_OPUS=claude-opus-5
|
|
263
|
+
MODEL_FALLBACK_CLAUDE_SONNET=claude-sonnet-5
|
|
254
264
|
MODEL_FALLBACK_CLAUDE_HAIKU=claude-haiku-4.5
|
|
255
265
|
```
|
|
256
266
|
|
|
@@ -259,8 +269,8 @@ Or in the proxy's **config file** (`~/.local/share/ghc-proxy/config.json`):
|
|
|
259
269
|
```json
|
|
260
270
|
{
|
|
261
271
|
"modelFallback": {
|
|
262
|
-
"claudeOpus": "claude-opus-
|
|
263
|
-
"claudeSonnet": "claude-sonnet-
|
|
272
|
+
"claudeOpus": "claude-opus-5",
|
|
273
|
+
"claudeSonnet": "claude-sonnet-5",
|
|
264
274
|
"claudeHaiku": "claude-haiku-4.5"
|
|
265
275
|
}
|
|
266
276
|
}
|
|
@@ -364,10 +374,11 @@ This keeps the existing chat pipeline stable while allowing newer Copilot models
|
|
|
364
374
|
|
|
365
375
|
| Method | Path | Description |
|
|
366
376
|
|--------|------|-------------|
|
|
377
|
+
| `GET` | `/health` | Liveness/readiness probe — returns `{ status, copilotToken, modelsLoaded, version }` |
|
|
367
378
|
| `GET` | `/usage` | Copilot quota / usage monitoring |
|
|
368
379
|
| `GET` | `/token` | Inspect the current Copilot token |
|
|
369
380
|
|
|
370
|
-
> **Note:** The `/v1/` prefix is optional for OpenAI-compatible endpoints (`/chat/completions`, `/responses`, `/models`, `/embeddings`). Anthropic endpoints (`/v1/messages`, `/v1/messages/count_tokens`) require the `/v1` prefix.
|
|
381
|
+
> **Note:** The `/v1/` prefix is optional for OpenAI-compatible endpoints (`/chat/completions`, `/responses`, `/models`, `/embeddings`). Anthropic endpoints (`/v1/messages`, `/v1/messages/count_tokens`) require the `/v1` prefix. The utility endpoints (`/health`, `/usage`, `/token`) are root-only and not exposed under `/v1`.
|
|
371
382
|
|
|
372
383
|
## Responses Compatibility
|
|
373
384
|
|
|
@@ -443,12 +454,18 @@ docker run -p 4141:4141 -v $(pwd)/copilot-data:/root/.local/share/ghc-proxy ghc-
|
|
|
443
454
|
|
|
444
455
|
Authentication and settings are persisted in `copilot-data/config.json` so they survive container restarts.
|
|
445
456
|
|
|
446
|
-
You can also pass a GitHub token via environment variable:
|
|
457
|
+
You can also pass a GitHub token via environment variable. The container [entrypoint](entrypoint.sh) forwards `GH_TOKEN` to `start --github-token`, so this is Docker-specific — the proxy binary itself does not read `GH_TOKEN` from the environment (outside Docker, use the `--github-token` flag or a persisted `config.json`):
|
|
447
458
|
|
|
448
459
|
```bash
|
|
449
460
|
docker run -p 4141:4141 -e GH_TOKEN=your_token ghcr.io/wxxb789/ghc-proxy
|
|
450
461
|
```
|
|
451
462
|
|
|
463
|
+
To run the one-time device-code auth flow inside the container instead (writes the token into the mounted data volume):
|
|
464
|
+
|
|
465
|
+
```bash
|
|
466
|
+
docker run -it -v $(pwd)/copilot-data:/root/.local/share/ghc-proxy ghc-proxy --auth
|
|
467
|
+
```
|
|
468
|
+
|
|
452
469
|
Docker Compose:
|
|
453
470
|
|
|
454
471
|
```yaml
|
package/dist/main.mjs
CHANGED
|
@@ -5980,6 +5980,31 @@ var HTTPError = class extends Error {
|
|
|
5980
5980
|
return Response.json(this.body, { status: this.status });
|
|
5981
5981
|
}
|
|
5982
5982
|
};
|
|
5983
|
+
const TRANSIENT_UPSTREAM_STATUSES = new Set([
|
|
5984
|
+
408,
|
|
5985
|
+
429,
|
|
5986
|
+
500,
|
|
5987
|
+
502,
|
|
5988
|
+
503,
|
|
5989
|
+
504,
|
|
5990
|
+
529
|
|
5991
|
+
]);
|
|
5992
|
+
/**
|
|
5993
|
+
* Upstream statuses worth retrying: request-scoped faults (timeouts, gateway
|
|
5994
|
+
* errors) plus capacity limits. Shared by `UpstreamRequestQueue` and the
|
|
5995
|
+
* Copilot token refresh so both agree on what "transient" means.
|
|
5996
|
+
*/
|
|
5997
|
+
function isTransientUpstreamStatus(status) {
|
|
5998
|
+
return TRANSIENT_UPSTREAM_STATUSES.has(status);
|
|
5999
|
+
}
|
|
6000
|
+
/**
|
|
6001
|
+
* Capacity signals that apply to the whole account or service rather than one
|
|
6002
|
+
* request. Only these warrant global back-pressure — applying a queue-wide
|
|
6003
|
+
* cooldown to a request-scoped 5xx turns one bad request into a proxy stall.
|
|
6004
|
+
*/
|
|
6005
|
+
function isCapacityLimitStatus(status) {
|
|
6006
|
+
return status === 429 || status === 529;
|
|
6007
|
+
}
|
|
5983
6008
|
function throwInvalidRequestError(message, param, code) {
|
|
5984
6009
|
throw new HTTPError(400, { error: {
|
|
5985
6010
|
message,
|
|
@@ -6014,7 +6039,9 @@ function isStructuredErrorPayload(value) {
|
|
|
6014
6039
|
return typeof value === "object" && value !== null && "error" in value && typeof value.error === "object" && value.error !== null;
|
|
6015
6040
|
}
|
|
6016
6041
|
function upstreamErrorType(status) {
|
|
6017
|
-
|
|
6042
|
+
if (status === 429) return "rate_limit_error";
|
|
6043
|
+
if (status === 529) return "overloaded_error";
|
|
6044
|
+
return "upstream_error";
|
|
6018
6045
|
}
|
|
6019
6046
|
function createFallbackUpstreamError(message, response, rawText) {
|
|
6020
6047
|
return { error: {
|
|
@@ -6957,8 +6984,10 @@ var UpstreamRequestQueue = class {
|
|
|
6957
6984
|
lease.release();
|
|
6958
6985
|
throw error;
|
|
6959
6986
|
}
|
|
6960
|
-
|
|
6961
|
-
|
|
6987
|
+
const { status } = response;
|
|
6988
|
+
const isCapacityLimit = isCapacityLimitStatus(status);
|
|
6989
|
+
if (!(isTransientUpstreamStatus(status) && context.retryable === true && attempt < this.options.maxRetries)) {
|
|
6990
|
+
if (isCapacityLimit) this.applyCooldown(this.getRetryDelayMs(response, 0));
|
|
6962
6991
|
return {
|
|
6963
6992
|
response,
|
|
6964
6993
|
release: lease.release
|
|
@@ -6966,10 +6995,10 @@ var UpstreamRequestQueue = class {
|
|
|
6966
6995
|
}
|
|
6967
6996
|
const delayMs = this.getRetryDelayMs(response, attempt);
|
|
6968
6997
|
await discardResponse(response);
|
|
6998
|
+
if (isCapacityLimit) this.applyCooldown(delayMs);
|
|
6969
6999
|
lease.release();
|
|
6970
|
-
this.applyCooldown(delayMs);
|
|
6971
7000
|
this.logger.warn([
|
|
6972
|
-
|
|
7001
|
+
`Upstream ${status};`,
|
|
6973
7002
|
`retrying ${formatRequestContext(context)}`,
|
|
6974
7003
|
`in ${formatDurationMs(delayMs)}`,
|
|
6975
7004
|
`(attempt ${attempt + 1}/${this.options.maxRetries})`
|
|
@@ -7244,16 +7273,8 @@ async function setupGitHubToken(options) {
|
|
|
7244
7273
|
function isAuthError(error) {
|
|
7245
7274
|
return error instanceof HTTPError && (error.status === 401 || error.status === 403);
|
|
7246
7275
|
}
|
|
7247
|
-
const TRANSIENT_HTTP_STATUSES = new Set([
|
|
7248
|
-
408,
|
|
7249
|
-
429,
|
|
7250
|
-
500,
|
|
7251
|
-
502,
|
|
7252
|
-
503,
|
|
7253
|
-
504
|
|
7254
|
-
]);
|
|
7255
7276
|
function isTransientHttpError(error) {
|
|
7256
|
-
return
|
|
7277
|
+
return isTransientUpstreamStatus(error.status);
|
|
7257
7278
|
}
|
|
7258
7279
|
async function logUser() {
|
|
7259
7280
|
const user = await createGitHubClient().getGitHubUser();
|
|
@@ -7364,7 +7385,7 @@ const checkUsage = defineCommand({
|
|
|
7364
7385
|
});
|
|
7365
7386
|
//#endregion
|
|
7366
7387
|
//#region src/util/version.ts
|
|
7367
|
-
const VERSION = "0.
|
|
7388
|
+
const VERSION = "0.8.1";
|
|
7368
7389
|
//#endregion
|
|
7369
7390
|
//#region src/debug.ts
|
|
7370
7391
|
function getRuntimeInfo() {
|
|
@@ -29431,8 +29452,8 @@ function generateEnvScript(envVars, commandToRun = "") {
|
|
|
29431
29452
|
//#endregion
|
|
29432
29453
|
//#region src/lib/model-resolver.ts
|
|
29433
29454
|
const DEFAULT_FALLBACKS = {
|
|
29434
|
-
claudeOpus: "claude-opus-
|
|
29435
|
-
claudeSonnet: "claude-sonnet-
|
|
29455
|
+
claudeOpus: "claude-opus-5",
|
|
29456
|
+
claudeSonnet: "claude-sonnet-5",
|
|
29436
29457
|
claudeHaiku: "claude-haiku-4.5"
|
|
29437
29458
|
};
|
|
29438
29459
|
function getModelFallbackConfig() {
|
|
@@ -53194,15 +53215,15 @@ const start = defineCommand({
|
|
|
53194
53215
|
},
|
|
53195
53216
|
"upstream-queue-retries": {
|
|
53196
53217
|
type: "string",
|
|
53197
|
-
description: "Maximum retries for upstream
|
|
53218
|
+
description: "Maximum retries for transient upstream responses (default: 5)"
|
|
53198
53219
|
},
|
|
53199
53220
|
"upstream-queue-base-delay": {
|
|
53200
53221
|
type: "string",
|
|
53201
|
-
description: "Base delay in seconds for upstream
|
|
53222
|
+
description: "Base delay in seconds for upstream retry backoff when Retry-After is absent (default: 2)"
|
|
53202
53223
|
},
|
|
53203
53224
|
"upstream-queue-max-delay": {
|
|
53204
53225
|
type: "string",
|
|
53205
|
-
description: "Maximum delay in seconds for upstream
|
|
53226
|
+
description: "Maximum delay in seconds for upstream retry backoff (default: 60)"
|
|
53206
53227
|
},
|
|
53207
53228
|
"ghe-domain": {
|
|
53208
53229
|
alias: "ghe",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ghc-proxy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.1",
|
|
5
5
|
"description": "GitHub Copilot to OpenAI/Anthropic API proxy - Use Copilot with Claude Code, Cursor, and more",
|
|
6
6
|
"author": "wxxb789 <wxxb789@outlook.com>",
|
|
7
7
|
"homepage": "https://github.com/wxxb789/ghc-proxy",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"ghc-proxy": "./dist/main.mjs"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"dist"
|
|
22
|
+
"dist/**/*.mjs"
|
|
23
23
|
],
|
|
24
24
|
"engines": {
|
|
25
25
|
"bun": ">=1.3",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"smoke:cache": "bun run scripts/smoke/cache-control.ts",
|
|
42
42
|
"smoke:packaged": "bun run scripts/smoke/packaged-cli.ts",
|
|
43
43
|
"smoke:translation": "bun run scripts/smoke/translation.ts",
|
|
44
|
+
"serve": "NODE_ENV=production bun run ./src/main.ts start --wait --idle-timeout=255 --upstream-timeout=1800",
|
|
44
45
|
"start": "NODE_ENV=production bun run ./src/main.ts",
|
|
45
46
|
"typecheck": "npx tsc --project tsconfig.json"
|
|
46
47
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GptEncoding-DdY2evDX.mjs","names":["o200k_base","encodingsMap"],"sources":["../node_modules/gpt-tokenizer/esm/constants.js","../node_modules/gpt-tokenizer/esm/utfUtil.js","../node_modules/gpt-tokenizer/esm/util.js","../node_modules/gpt-tokenizer/esm/BytePairEncodingCore.js","../node_modules/gpt-tokenizer/esm/functionCalling.js","../node_modules/gpt-tokenizer/esm/modelsChatEnabled.gen.js","../node_modules/gpt-tokenizer/esm/modelsMap.js","../node_modules/gpt-tokenizer/esm/specialTokens.js","../node_modules/gpt-tokenizer/esm/mapping.js","../node_modules/gpt-tokenizer/esm/encodingParams/constants.js","../node_modules/gpt-tokenizer/esm/encodingParams/cl100k_base.js","../node_modules/gpt-tokenizer/esm/encodingParams/o200k_base.js","../node_modules/gpt-tokenizer/esm/encodingParams/o200k_harmony.js","../node_modules/gpt-tokenizer/esm/encodingParams/p50k_base.js","../node_modules/gpt-tokenizer/esm/encodingParams/p50k_edit.js","../node_modules/gpt-tokenizer/esm/encodingParams/r50k_base.js","../node_modules/gpt-tokenizer/esm/modelParams.js","../node_modules/gpt-tokenizer/esm/GptEncoding.js"],"sourcesContent":["export const ALL_SPECIAL_TOKENS = 'all';\nexport const DEFAULT_MERGE_CACHE_SIZE = 100_000;\n//# sourceMappingURL=constants.js.map","/* eslint-disable no-bitwise */\n/* eslint-disable no-magic-numbers */\nexport const isAscii = (codePoint) => codePoint <= 0x7f;\nconst HIGH_SURROGATE_START = 55_296;\nconst HIGH_SURROGATE_END = 56_319;\nexport function endsWithIncompleteUtfPairSurrogate(string) {\n if (string.length === 0)\n return false;\n // Check if the last character is a high surrogate\n // eslint-disable-next-line unicorn/prefer-code-point\n const lastCharCode = string.charCodeAt(string.length - 1);\n return (lastCharCode >= HIGH_SURROGATE_START && lastCharCode <= HIGH_SURROGATE_END);\n}\nfunction isValidUTF8(bytes) {\n let i = 0;\n while (i < bytes.length) {\n const byte1 = bytes[i];\n let numBytes = 0;\n let codePoint = 0;\n // Determine the number of bytes in the current UTF-8 character\n if (byte1 <= 0x7f) {\n // 1-byte character (ASCII)\n numBytes = 1;\n codePoint = byte1;\n }\n else if ((byte1 & 0xe0) === 0xc0) {\n // 2-byte character\n numBytes = 2;\n codePoint = byte1 & 0x1f;\n if (byte1 <= 0xc1)\n return false; // Overlong encoding not allowed\n }\n else if ((byte1 & 0xf0) === 0xe0) {\n // 3-byte character\n numBytes = 3;\n codePoint = byte1 & 0x0f;\n }\n else if ((byte1 & 0xf8) === 0xf0) {\n // 4-byte character\n numBytes = 4;\n codePoint = byte1 & 0x07;\n if (byte1 > 0xf4)\n return false; // Code points above U+10FFFF not allowed\n }\n else {\n // Invalid first byte of UTF-8 character\n return false;\n }\n // Ensure there are enough continuation bytes\n if (i + numBytes > bytes.length)\n return false;\n // Process the continuation bytes\n for (let j = 1; j < numBytes; j++) {\n const byte = bytes[i + j];\n if (byte === undefined || (byte & 0xc0) !== 0x80)\n return false; // Continuation bytes must start with '10'\n codePoint = (codePoint << 6) | (byte & 0x3f);\n }\n // Check for overlong encodings\n if (numBytes === 2 && codePoint < 0x80)\n return false; // Overlong 2-byte sequence\n if (numBytes === 3 && codePoint < 2_048)\n return false; // Overlong 3-byte sequence\n if (numBytes === 4 && codePoint < 65_536)\n return false; // Overlong 4-byte sequence\n // Check for surrogate halves (U+D800 to U+DFFF)\n if (codePoint >= 55_296 && codePoint <= 57_343)\n return false;\n // Check for code points above U+10FFFF\n if (codePoint > 1_114_111)\n return false;\n // Move to the next character\n i += numBytes;\n }\n return true;\n}\nconst textDecoder = new TextDecoder('utf8', { fatal: false });\nexport function tryConvertToString(arr) {\n if (!isValidUTF8(arr)) {\n return undefined;\n }\n return textDecoder.decode(arr);\n}\n// Helper function to compare two Uint8Arrays lexicographically\nexport function compareUint8Arrays(a, b) {\n const len = Math.min(a.length, b.length);\n for (let i = 0; i < len; i++) {\n if (a[i] !== b[i]) {\n return a[i] - b[i];\n }\n }\n return a.length - b.length;\n}\n//# sourceMappingURL=utfUtil.js.map","export function getMaxValueFromMap(map) {\n let max = 0;\n map.forEach((val) => {\n max = Math.max(max, val);\n });\n return max;\n}\nexport function escapeRegExp(string) {\n return string.replace(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&'); // $& means the whole matched string\n}\nexport function getSpecialTokenRegex(tokens) {\n const escapedTokens = [...tokens].map(escapeRegExp);\n const inner = escapedTokens.join('|');\n return new RegExp(`(${inner})`);\n}\n//# sourceMappingURL=util.js.map","/* eslint-disable no-continue */\nimport { DEFAULT_MERGE_CACHE_SIZE } from './constants.js';\nimport { compareUint8Arrays, isAscii, tryConvertToString } from './utfUtil.js';\nimport { escapeRegExp } from './util.js';\nconst emptyBuffer = new Uint8Array(0);\nexport const decoder = new TextDecoder('utf8');\nexport class BytePairEncodingCore {\n mergeableBytePairRankCount;\n /**\n * an array where the index is the BPE rank,\n * and the value is the string or the array of bytes that it decodes to\n * it may contain holes if token is unused\n */\n bytePairRankDecoder;\n bytePairNonUtfRankDecoder = new Map();\n bytePairNonUtfSortedEncoder;\n /**\n * a reverse map of the bytePairRankDecoder,\n * where the key is the string and the value is the rank\n * values that cannot be represented as a string are present in `bytePairNonUtfSortedEncoder`\n */\n bytePairStringRankEncoder;\n tokenSplitRegex;\n specialTokensEncoder;\n specialTokensDecoder;\n specialTokenPatternRegex;\n textEncoder = new TextEncoder();\n mergeCache;\n mergeCacheSize;\n constructor({ bytePairRankDecoder, specialTokensEncoder, tokenSplitRegex, mergeCacheSize = DEFAULT_MERGE_CACHE_SIZE, }) {\n this.bytePairRankDecoder = bytePairRankDecoder;\n this.bytePairStringRankEncoder = new Map();\n this.mergeCacheSize = mergeCacheSize;\n if (mergeCacheSize > 0) {\n this.mergeCache = new Map();\n }\n // size without array holes (which may be present in the encoder)\n this.mergeableBytePairRankCount = Object.keys(bytePairRankDecoder).length;\n const binaryLookup = [];\n // forEach skips array holes:\n bytePairRankDecoder.forEach((value, rank) => {\n if (typeof value === 'string') {\n this.bytePairStringRankEncoder.set(value, rank);\n return;\n }\n const byteArray = new Uint8Array(value);\n binaryLookup.push([byteArray, rank]);\n this.bytePairNonUtfRankDecoder.set(rank, byteArray);\n });\n this.bytePairNonUtfSortedEncoder = binaryLookup.sort((a, b) => compareUint8Arrays(a[0], b[0]));\n this.specialTokensEncoder =\n specialTokensEncoder ?? new Map();\n this.specialTokensDecoder = specialTokensEncoder\n ? new Map([...specialTokensEncoder].map(([key, value]) => [value, key]))\n : new Map();\n this.tokenSplitRegex = tokenSplitRegex;\n const escapedSpecialTokens = [...this.specialTokensEncoder.keys()].map(escapeRegExp);\n const allSpecialTokensRegex = escapedSpecialTokens.join('|');\n try {\n this.specialTokenPatternRegex = new RegExp(allSpecialTokensRegex, 'y');\n }\n catch {\n throw new Error('Invalid regular expression pattern.');\n }\n }\n setMergeCacheSize(newSize) {\n if (this.mergeCacheSize === 0 && newSize > 0) {\n this.mergeCache = new Map();\n }\n this.mergeCacheSize = newSize;\n if (newSize === 0) {\n this.mergeCache = undefined;\n }\n }\n clearMergeCache() {\n this.mergeCache?.clear();\n }\n *encodeNativeGenerator(text, allowedSpecial) {\n let startIndex = 0;\n let lastTokenLength = 0;\n while (true) {\n const nextSpecialMatch = this.findNextSpecialToken(text, allowedSpecial, startIndex);\n const nextSpecialStartIndex = nextSpecialMatch?.[0];\n const endIndex = nextSpecialStartIndex ?? text.length;\n const textBeforeSpecial = startIndex === 0 && endIndex === text.length\n ? text\n : text.slice(startIndex, endIndex);\n for (const [match] of textBeforeSpecial.matchAll(this.tokenSplitRegex)) {\n const token = this.getBpeRankFromString(match);\n if (token !== undefined) {\n lastTokenLength = 1;\n yield [token];\n continue;\n }\n const tokens = this.bytePairEncode(match);\n lastTokenLength = tokens.length;\n yield tokens;\n }\n if (nextSpecialStartIndex !== undefined) {\n const specialToken = nextSpecialMatch[1];\n const specialTokenValue = this.specialTokensEncoder.get(specialToken);\n if (specialTokenValue === undefined) {\n throw new Error(`Special token \"${specialToken}\" is not in the special token encoder.`);\n }\n yield [specialTokenValue];\n startIndex = nextSpecialStartIndex + specialToken.length;\n lastTokenLength = 1;\n }\n else {\n break;\n }\n }\n return lastTokenLength;\n }\n encodeNative(text, allowedSpecial) {\n let startIndex = 0;\n const tokensArray = []; // Flat list to collect the tokens\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const nextSpecialMatch = this.findNextSpecialToken(text, allowedSpecial, startIndex);\n const nextSpecialStartIndex = nextSpecialMatch?.[0];\n const endIndex = nextSpecialStartIndex ?? text.length;\n const textBeforeSpecial = startIndex === 0 && endIndex === text.length\n ? text\n : text.slice(startIndex, endIndex);\n for (const [match] of textBeforeSpecial.matchAll(this.tokenSplitRegex)) {\n const token = this.getBpeRankFromString(match);\n if (token !== undefined) {\n tokensArray.push(token);\n continue;\n }\n const tokens = this.bytePairEncode(match);\n tokensArray.push(...tokens);\n }\n if (nextSpecialStartIndex !== undefined) {\n const specialToken = nextSpecialMatch[1];\n const specialTokenValue = this.specialTokensEncoder.get(specialToken);\n if (specialTokenValue === undefined) {\n throw new Error(`Special token \"${specialToken}\" is not in the special token encoder.`);\n }\n tokensArray.push(specialTokenValue);\n startIndex = nextSpecialStartIndex + specialToken.length;\n }\n else {\n break;\n }\n }\n return tokensArray;\n }\n countNative(text, allowedSpecial) {\n let startIndex = 0;\n let tokensCount = 0;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const nextSpecialMatch = this.findNextSpecialToken(text, allowedSpecial, startIndex);\n const nextSpecialStartIndex = nextSpecialMatch?.[0];\n const endIndex = nextSpecialStartIndex ?? text.length;\n const textBeforeSpecial = startIndex === 0 && endIndex === text.length\n ? text\n : text.slice(startIndex, endIndex);\n for (const [match] of textBeforeSpecial.matchAll(this.tokenSplitRegex)) {\n const token = this.getBpeRankFromString(match);\n if (token !== undefined) {\n tokensCount++;\n continue;\n }\n const tokens = this.bytePairEncode(match);\n tokensCount += tokens.length;\n }\n if (nextSpecialStartIndex !== undefined) {\n const specialToken = nextSpecialMatch[1];\n const specialTokenValue = this.specialTokensEncoder.get(specialToken);\n if (specialTokenValue === undefined) {\n throw new Error(`Special token \"${specialToken}\" is not in the special token encoder.`);\n }\n tokensCount++;\n startIndex = nextSpecialStartIndex + specialToken.length;\n }\n else {\n break;\n }\n }\n return tokensCount;\n }\n *decodeNativeGenerator(tokens) {\n for (const token of tokens) {\n const tokenBytes = this.tryDecodeToken(token);\n if (tokenBytes) {\n yield tokenBytes;\n }\n }\n }\n decodeNative(tokens) {\n let decoded = '';\n let intBuffer = emptyBuffer;\n for (const token of tokens) {\n const tokenBytes = this.tryDecodeToken(token);\n if (tokenBytes === undefined) {\n throw new Error(`Token ${token} is not in the byte pair encoder.`);\n }\n if (typeof tokenBytes === 'string') {\n if (intBuffer !== emptyBuffer) {\n decoded += decoder.decode(intBuffer, { stream: true });\n intBuffer = emptyBuffer;\n }\n decoded += tokenBytes;\n }\n else {\n const newBuffer = new Uint8Array(intBuffer.length + tokenBytes.length);\n newBuffer.set(intBuffer);\n newBuffer.set(tokenBytes, intBuffer.length);\n intBuffer = newBuffer;\n }\n }\n if (intBuffer !== emptyBuffer) {\n decoded += decoder.decode(intBuffer, { stream: true });\n }\n return decoded;\n }\n async *decodeNativeAsyncIterable(tokens) {\n for await (const token of tokens) {\n const tokenBytesOrString = this.tryDecodeToken(token);\n if (tokenBytesOrString) {\n yield tokenBytesOrString;\n }\n }\n }\n getBpeRankFromString(key) {\n return this.bytePairStringRankEncoder.get(key);\n }\n getBpeRankFromStringOrThrow(key) {\n const value = this.getBpeRankFromString(key);\n if (value === undefined) {\n throw new Error(`The byte-pair encoding does not contain a value for: ${key}`);\n }\n return value;\n }\n getBpeRankFromBytes(key) {\n const keyAsString = tryConvertToString(key);\n if (keyAsString !== undefined) {\n return this.getBpeRankFromString(keyAsString);\n }\n // Perform binary search on the binary keys\n const index = this.binarySearch(key);\n if (index !== -1) {\n return this.bytePairNonUtfSortedEncoder[index][1];\n }\n return undefined;\n }\n getBpeRankFromBytesOrThrow(key) {\n const value = this.getBpeRankFromBytes(key);\n if (value === undefined) {\n throw new Error(`The byte-pair encoding does not contain a value for: ${key.toString()}`);\n }\n return value;\n }\n // Binary search on the binary keys\n binarySearch(key) {\n let low = 0;\n let high = this.bytePairNonUtfSortedEncoder.length - 1;\n while (low <= high) {\n // eslint-disable-next-line no-bitwise\n const mid = (low + high) >>> 1;\n const midKey = this.bytePairNonUtfSortedEncoder[mid][0];\n let cmp = 0;\n const maxLength = Math.min(midKey.length, key.length);\n for (let i = 0; i < maxLength; i++) {\n cmp = midKey[i] - key[i];\n if (cmp !== 0)\n break;\n }\n if (cmp === 0) {\n cmp = midKey.length - key.length;\n }\n if (cmp === 0) {\n return mid;\n }\n if (cmp < 0) {\n low = mid + 1;\n }\n else {\n high = mid - 1;\n }\n }\n return -1;\n }\n findNextSpecialToken(text, allowedSpecial, startIndex) {\n let searchIndex = startIndex;\n // eslint-disable-next-line no-constant-condition\n while (true) {\n this.specialTokenPatternRegex.lastIndex = searchIndex;\n const nextSpecialMatch = this.specialTokenPatternRegex.exec(text);\n if (!nextSpecialMatch) {\n return undefined;\n }\n const specialToken = nextSpecialMatch[0];\n if (allowedSpecial?.has(specialToken)) {\n const specialTokenStartIndex = nextSpecialMatch.index + searchIndex;\n return [specialTokenStartIndex, specialToken];\n }\n searchIndex = nextSpecialMatch.index + searchIndex + 1;\n }\n }\n tryDecodeToken(tokenRank) {\n const value = this.bytePairRankDecoder[tokenRank];\n if (typeof value === 'string') {\n return value;\n }\n if (typeof value === 'object') {\n const fromBinary = this.bytePairNonUtfRankDecoder.get(tokenRank);\n if (fromBinary) {\n return fromBinary;\n }\n }\n return this.specialTokensDecoder.get(tokenRank);\n }\n addToMergeCache(key, value) {\n if (!this.mergeCache)\n return;\n if (this.mergeCache.size >= this.mergeCacheSize) {\n // Remove least recently used item (first item)\n const firstKey = this.mergeCache.keys().next().value;\n this.mergeCache.delete(firstKey);\n }\n this.mergeCache.set(key, value);\n }\n bytePairEncode(input) {\n if (input.length === 1 && isAscii(input.codePointAt(0))) {\n return [this.getBpeRankFromStringOrThrow(input)];\n }\n if (this.mergeCache?.has(input)) {\n const result = this.mergeCache.get(input);\n // Move to end to mark as recently used\n this.mergeCache.delete(input);\n this.mergeCache.set(input, result);\n return result;\n }\n const inputBytes = this.textEncoder.encode(input);\n const result = this.bytePairMerge(inputBytes);\n this.addToMergeCache(input, result);\n return result;\n }\n bytePairMerge(\n // Input array of bytes to process\n piece) {\n // 'starts' holds the start indices of each partition\n const starts = [];\n // 'ranks' holds the BPE ranks of each partition pair\n const ranks = [];\n // Helper function to get the rank of a byte pair starting at 'startIndex'\n const getRank = (startIndex, pairStart = starts[startIndex], pairEnd = starts[startIndex + 2]) => {\n if (pairEnd === undefined) {\n // No valid pair exists\n return Number.POSITIVE_INFINITY;\n }\n // Extract the byte pair\n const key = piece.subarray(pairStart, pairEnd);\n // Retrieve the BPE rank of this byte pair (if it exists)\n const rank = this.getBpeRankFromBytes(key);\n return rank ?? Number.POSITIVE_INFINITY;\n };\n // Initialize the 'starts' array with all possible start indices\n for (let i = 0; i <= piece.length; i++) {\n starts.push(i);\n if (i < piece.length - 1) {\n // Initialize the BPE values for all adjacent pairs\n ranks.push(getRank(i, i, i + 2));\n }\n else {\n // Initialize BPE values to infinity for the last pair\n ranks.push(Number.POSITIVE_INFINITY);\n }\n }\n // Iteratively merge byte pairs until no more useful merges can be done\n while (starts.length > 1) {\n let lowestRank = Number.POSITIVE_INFINITY;\n let lowestPartitionIndex = -1;\n // Find the partition with the minimum rank\n for (let i = 0; i < ranks.length - 1; i++) {\n const rank = ranks[i];\n if (rank < lowestRank) {\n lowestRank = rank;\n lowestPartitionIndex = i;\n }\n }\n // If no valid pair is left to merge, exit the loop\n if (lowestRank === Number.POSITIVE_INFINITY ||\n lowestPartitionIndex === -1) {\n break;\n }\n // Merge the pair at 'lowestPartitionIndex' by removing the next start index\n starts.splice(lowestPartitionIndex + 1, 1);\n // Remove the BPE value of the merged pair\n ranks.splice(lowestPartitionIndex, 1);\n // Update the current merged pair's rank\n ranks[lowestPartitionIndex] = getRank(lowestPartitionIndex);\n // Update the rank of the previous pair, if it exists\n if (lowestPartitionIndex > 0) {\n ranks[lowestPartitionIndex - 1] = getRank(lowestPartitionIndex - 1);\n }\n }\n // Create the final output by applying the transform function to each partitioned range\n const output = [];\n for (let i = 0; i < starts.length - 1; i++) {\n const pairStart = starts[i];\n const pairEnd = starts[i + 1];\n const bpeValue = this.getBpeRankFromBytesOrThrow(piece.subarray(pairStart, pairEnd));\n output.push(bpeValue);\n }\n return output;\n }\n}\n//# sourceMappingURL=BytePairEncodingCore.js.map","export const MESSAGE_TOKEN_OVERHEAD = 3;\nexport const MESSAGE_NAME_TOKEN_OVERHEAD = 1;\nexport const FUNCTION_ROLE_TOKEN_DISCOUNT = 2;\nexport const FUNCTION_CALL_METADATA_TOKEN_OVERHEAD = 3;\nexport const FUNCTION_DEFINITION_TOKEN_OVERHEAD = 9;\nexport const COMPLETION_REQUEST_TOKEN_OVERHEAD = 3;\nexport const FUNCTION_CALL_NAME_TOKEN_OVERHEAD = 4;\nexport const FUNCTION_CALL_NONE_TOKEN_OVERHEAD = 1;\nexport const SYSTEM_FUNCTION_TOKEN_DEDUCTION = 4;\nconst NEWLINE = '\\n';\nexport function countMessageTokens(message, countStringTokens) {\n let tokens = 0;\n if (message.role) {\n tokens += countStringTokens(message.role);\n }\n if (message.content) {\n tokens += countStringTokens(message.content);\n }\n if (message.name) {\n tokens += countStringTokens(message.name) + MESSAGE_NAME_TOKEN_OVERHEAD;\n }\n if (message.function_call) {\n const { name, arguments: args } = message.function_call;\n if (name) {\n tokens += countStringTokens(name);\n }\n if (args) {\n tokens += countStringTokens(args);\n }\n tokens += FUNCTION_CALL_METADATA_TOKEN_OVERHEAD;\n }\n tokens += MESSAGE_TOKEN_OVERHEAD;\n if (message.role === 'function') {\n tokens -= FUNCTION_ROLE_TOKEN_DISCOUNT;\n }\n return tokens;\n}\nexport function formatObjectProperties(obj, indent, formatType) {\n if (!obj.properties) {\n return '';\n }\n const lines = [];\n const requiredParams = new Set(obj.required ?? []);\n const indentString = ' '.repeat(indent);\n for (const [name, param] of Object.entries(obj.properties)) {\n if (param.description && indent < 2) {\n lines.push(`${indentString}// ${param.description}`);\n }\n const isRequired = requiredParams.has(name);\n const formattedType = formatType(param, indent);\n lines.push(`${indentString}${name}${isRequired ? '' : '?'}: ${formattedType},`);\n }\n return lines.join('\\n');\n}\nexport function formatFunctionType(param, indent) {\n switch (param.type) {\n case 'string':\n return (param.enum?.map((value) => JSON.stringify(value)).join(' | ') ??\n 'string');\n case 'integer':\n case 'number':\n return param.enum?.map((value) => `${value}`).join(' | ') ?? 'number';\n case 'boolean':\n return 'boolean';\n case 'null':\n return 'null';\n case 'array':\n return param.items\n ? `${formatFunctionType(param.items, indent)}[]`\n : 'any[]';\n case 'object': {\n const inner = formatObjectProperties(param, indent + 2, formatFunctionType);\n const closingIndent = ' '.repeat(indent);\n return `{\n${inner}\n${closingIndent}}`;\n }\n default:\n return 'any';\n }\n}\nexport function formatFunctionDefinitions(functions) {\n const lines = ['namespace functions {', ''];\n for (const fn of functions) {\n if (fn.description) {\n lines.push(`// ${fn.description}`);\n }\n const { parameters } = fn;\n const properties = parameters?.properties;\n if (!parameters || !properties || Object.keys(properties).length === 0) {\n lines.push(`type ${fn.name} = () => any;`);\n }\n else {\n lines.push(`type ${fn.name} = (_: {`);\n const formattedProperties = formatObjectProperties(parameters, 0, formatFunctionType);\n if (formattedProperties.length > 0) {\n lines.push(formattedProperties);\n }\n lines.push('}) => any;');\n }\n lines.push('');\n }\n lines.push('} // namespace functions');\n return lines.join('\\n');\n}\nexport function estimateTokensInFunctions(functions, countStringTokens) {\n const formatted = formatFunctionDefinitions(functions);\n let tokens = countStringTokens(formatted);\n tokens += FUNCTION_DEFINITION_TOKEN_OVERHEAD;\n return tokens;\n}\nexport function padSystemMessage(message, hasFunctions, isSystemPadded) {\n if (!hasFunctions || isSystemPadded || message.role !== 'system') {\n return message;\n }\n if (!message.content || message.content.endsWith(NEWLINE)) {\n return message;\n }\n return {\n ...message,\n content: `${message.content}${NEWLINE}`,\n };\n}\nexport function computeChatCompletionTokenCount(request, countStringTokens) {\n const { messages, functions, function_call: functionCall } = request;\n const hasFunctions = Boolean(functions && functions.length > 0);\n let paddedSystem = false;\n let total = 0;\n for (const message of messages) {\n const messageToCount = padSystemMessage(message, hasFunctions, paddedSystem);\n if (messageToCount !== message && message.role === 'system') {\n paddedSystem = true;\n }\n else if (message.role === 'system' && hasFunctions && !paddedSystem) {\n paddedSystem = true;\n }\n total += countMessageTokens(messageToCount, countStringTokens);\n }\n total += COMPLETION_REQUEST_TOKEN_OVERHEAD;\n if (hasFunctions && functions) {\n total += estimateTokensInFunctions(functions, countStringTokens);\n if (messages.some((message) => message.role === 'system')) {\n total -= SYSTEM_FUNCTION_TOKEN_DEDUCTION;\n }\n }\n if (functionCall && functionCall !== 'auto') {\n if (functionCall === 'none') {\n total += FUNCTION_CALL_NONE_TOKEN_OVERHEAD;\n }\n else if (typeof functionCall === 'object' && functionCall.name) {\n total +=\n countStringTokens(functionCall.name) + FUNCTION_CALL_NAME_TOKEN_OVERHEAD;\n }\n }\n return total;\n}\n//# sourceMappingURL=functionCalling.js.map","// This file was generated by src/codegen/generateChatEnabled.ts.\n// To regenerate, run: yarn codegen:chat-enabled.\n// Source data: src/models.ts.\nexport const chatEnabledModels = [\"chatgpt-4o-latest\", \"codex-mini-latest\", \"computer-use-preview\", \"computer-use-preview-2025-03-11\", \"gpt-3.5\", \"gpt-3.5-0301\", \"gpt-3.5-turbo\", \"gpt-3.5-turbo-0125\", \"gpt-3.5-turbo-0613\", \"gpt-3.5-turbo-1106\", \"gpt-3.5-turbo-16k-0613\", \"gpt-3.5-turbo-instruct\", \"gpt-4\", \"gpt-4-0125-preview\", \"gpt-4-0314\", \"gpt-4-0613\", \"gpt-4-1106-preview\", \"gpt-4-1106-vision-preview\", \"gpt-4-32k\", \"gpt-4-turbo\", \"gpt-4-turbo-2024-04-09\", \"gpt-4-turbo-preview\", \"gpt-4.1\", \"gpt-4.1-2025-04-14\", \"gpt-4.1-mini\", \"gpt-4.1-mini-2025-04-14\", \"gpt-4.1-nano\", \"gpt-4.1-nano-2025-04-14\", \"gpt-4.5-preview\", \"gpt-4.5-preview-2025-02-27\", \"gpt-4o\", \"gpt-4o-2024-05-13\", \"gpt-4o-2024-08-06\", \"gpt-4o-2024-11-20\", \"gpt-4o-audio-preview\", \"gpt-4o-audio-preview-2024-10-01\", \"gpt-4o-audio-preview-2024-12-17\", \"gpt-4o-audio-preview-2025-06-03\", \"gpt-4o-mini\", \"gpt-4o-mini-2024-07-18\", \"gpt-4o-mini-audio-preview\", \"gpt-4o-mini-audio-preview-2024-12-17\", \"gpt-4o-mini-search-preview\", \"gpt-4o-mini-search-preview-2025-03-11\", \"gpt-4o-search-preview\", \"gpt-4o-search-preview-2025-03-11\", \"gpt-5\", \"gpt-5-2025-08-07\", \"gpt-5-chat-latest\", \"gpt-5-codex\", \"gpt-5-mini\", \"gpt-5-mini-2025-08-07\", \"gpt-5-nano\", \"gpt-5-nano-2025-08-07\", \"gpt-5-pro\", \"gpt-5-pro-2025-10-06\", \"gpt-audio\", \"gpt-audio-2025-08-28\", \"gpt-audio-mini\", \"gpt-audio-mini-2025-10-06\", \"gpt-oss-120b\", \"gpt-oss-20b\", \"o1\", \"o1-2024-12-17\", \"o1-mini\", \"o1-mini-2024-09-12\", \"o1-preview\", \"o1-preview-2024-09-12\", \"o1-pro\", \"o1-pro-2025-03-19\", \"o3\", \"o3-2025-04-16\", \"o3-deep-research\", \"o3-deep-research-2025-06-26\", \"o3-mini\", \"o3-mini-2025-01-31\", \"o3-pro\", \"o3-pro-2025-06-10\", \"o4-mini\", \"o4-mini-2025-04-16\", \"o4-mini-deep-research\", \"o4-mini-deep-research-2025-06-26\"];\n//# sourceMappingURL=modelsChatEnabled.gen.js.map","/* eslint-disable camelcase */\n// reference: https://github.com/openai/tiktoken/blob/4560a8896f5fb1d35c6f8fd6eee0399f9a1a27ca/tiktoken/model.py\n// --- p50k_base models ---\nexport const p50k_base = [\n // legacy models\n 'text-davinci-002',\n 'text-davinci-003',\n 'code-davinci-001',\n 'code-davinci-002',\n 'davinci-codex',\n 'code-cushman-001',\n 'code-cushman-002',\n 'cushman-codex',\n];\n// --- r50k_base models ---\nexport const r50k_base = [\n // legacy models\n 'text-ada-001',\n 'text-babbage-001',\n 'text-curie-001',\n 'text-davinci-001',\n 'ada',\n 'babbage',\n 'curie',\n 'davinci',\n 'code-search-ada-code-001',\n 'code-search-ada-text-001',\n 'text-similarity-ada-001',\n 'text-search-ada-doc-001',\n 'text-search-ada-query-001',\n 'text-similarity-babbage-001',\n 'text-search-babbage-doc-001',\n 'text-search-babbage-query-001',\n 'code-search-babbage-code-001',\n 'code-search-babbage-text-001',\n 'text-similarity-curie-001',\n 'text-search-curie-doc-001',\n 'text-search-curie-query-001',\n 'text-similarity-davinci-001',\n 'text-search-davinci-doc-001',\n 'text-search-davinci-query-001',\n];\n// --- p50k_edit models ---\nexport const p50k_edit = [\n 'code-davinci-edit-001',\n 'text-davinci-edit-001',\n];\n// --- cl100k_base models ---\nexport const cl100k_base = [\n // all gpt-3.5 models:\n 'gpt-3.5',\n 'gpt-3.5-0301',\n 'gpt-3.5-turbo',\n 'gpt-3.5-turbo-0125',\n 'gpt-3.5-turbo-0613',\n 'gpt-3.5-turbo-1106',\n 'gpt-3.5-turbo-16k-0613',\n 'gpt-3.5-turbo-instruct',\n // all gpt-4.0 models:\n 'gpt-4',\n 'gpt-4-0125-preview',\n 'gpt-4-0314',\n 'gpt-4-0613',\n 'gpt-4-1106-preview',\n 'gpt-4-1106-vision-preview',\n 'gpt-4-32k',\n 'gpt-4-turbo',\n 'gpt-4-turbo-2024-04-09',\n 'gpt-4-turbo-preview',\n // embedding models:\n 'text-embedding-3-large',\n 'text-embedding-3-small',\n 'text-embedding-ada-002',\n // still supported models:\n 'babbage-002',\n 'davinci-002',\n];\n// all new proprietary models use o200k_base, hence we don't need to list them here\n// (e.g. chatgpt-4o-latest, gpt-5, o1, etc.)\n// --- o200k_base models ---\nexport const o200k_base = [];\n// --- o200k_harmony models ---\nexport const o200k_harmony = [\n 'gpt-oss-20b',\n 'gpt-oss-120b',\n];\n//# sourceMappingURL=modelsMap.js.map","export const EndOfText = '<|endoftext|>';\nexport const FimPrefix = '<|fim_prefix|>';\nexport const FimMiddle = '<|fim_middle|>';\nexport const FimSuffix = '<|fim_suffix|>';\nexport const ImStart = '<|im_start|>'; // 100264\nexport const ImEnd = '<|im_end|>'; // 100265\nexport const ImSep = '<|im_sep|>'; // 100266\nexport const EndOfPrompt = '<|endofprompt|>';\nexport const HarmonyStartOfText = '<|startoftext|>';\nexport const HarmonyStart = '<|start|>';\nexport const HarmonyEnd = '<|end|>';\nexport const HarmonyMessage = '<|message|>';\nexport const HarmonyChannel = '<|channel|>';\nexport const HarmonyReturn = '<|return|>';\nexport const HarmonyConstrain = '<|constrain|>';\nexport const HarmonyCall = '<|call|>';\n//# sourceMappingURL=specialTokens.js.map","/* eslint-disable camelcase */\nimport { chatEnabledModels } from './modelsChatEnabled.gen.js';\nimport * as encodingsMap from './modelsMap.js';\nimport { ImSep } from './specialTokens.js';\nexport const cl100k_base = 'cl100k_base';\nexport const p50k_base = 'p50k_base';\nexport const p50k_edit = 'p50k_edit';\nexport const r50k_base = 'r50k_base';\nexport const o200k_base = 'o200k_base';\nexport const o200k_harmony = 'o200k_harmony';\nexport const DEFAULT_ENCODING = o200k_base;\nexport const encodingNames = [\n p50k_base,\n r50k_base,\n p50k_edit,\n cl100k_base,\n o200k_base,\n o200k_harmony,\n];\n/**\n * maps model names to encoding names\n * if a model is not listed, it uses the default encoding for new models\n * which is `o200k_base`\n */\nexport const modelToEncodingMap = Object.fromEntries(Object.entries(encodingsMap).flatMap(([encodingName, models]) => models.map((modelName) => [modelName, encodingName])));\nconst gpt3params = {\n messageSeparator: '\\n',\n roleSeparator: '\\n',\n};\nconst gpt4params = {\n messageSeparator: '',\n roleSeparator: ImSep,\n};\nexport const chatModelParams = Object.fromEntries(chatEnabledModels.flatMap((modelName) => modelName.startsWith('gpt-3.5')\n ? [[modelName, gpt3params]]\n : [[modelName, gpt4params]]));\n//# sourceMappingURL=mapping.js.map","export const R50K_TOKEN_SPLIT_REGEX = /'s|'t|'re|'ve|'m|'ll|'d| ?\\p{L}+| ?\\p{N}+| ?[^\\s\\p{L}\\p{N}]+|\\s+(?!\\S)|\\s+/gu;\nconst CONTRACTION_SUFFIX_PATTERN = String.raw `'(?:[sS]|[dD]|[mM]|[tT]|[lL][lL]|[vV][eE]|[rR][eE])`;\nconst OPTIONAL_CONTRACTION_SUFFIX = String.raw `(?:${CONTRACTION_SUFFIX_PATTERN})?`;\nconst CL100K_TOKEN_SPLIT_PATTERN = String.raw `${CONTRACTION_SUFFIX_PATTERN}|[^\\r\\n\\p{L}\\p{N}]?\\p{L}+|\\p{N}{1,3}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n]*|\\s+$|\\s*[\\r\\n]|\\s+(?!\\S)|\\s`;\nexport const CL100K_TOKEN_SPLIT_REGEX = new RegExp(CL100K_TOKEN_SPLIT_PATTERN, 'gu');\nconst O200K_TOKEN_SPLIT_PATTERN = String.raw `[^\\r\\n\\p{L}\\p{N}]?[\\p{Lu}\\p{Lt}\\p{Lm}\\p{Lo}\\p{M}]*[\\p{Ll}\\p{Lm}\\p{Lo}\\p{M}]+${OPTIONAL_CONTRACTION_SUFFIX}|[^\\r\\n\\p{L}\\p{N}]?[\\p{Lu}\\p{Lt}\\p{Lm}\\p{Lo}\\p{M}]+[\\p{Ll}\\p{Lm}\\p{Lo}\\p{M}]*${OPTIONAL_CONTRACTION_SUFFIX}|\\p{N}{1,3}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n/]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+`;\nexport const O200K_TOKEN_SPLIT_REGEX = new RegExp(O200K_TOKEN_SPLIT_PATTERN, 'gu');\n//# sourceMappingURL=constants.js.map","import { EndOfPrompt, EndOfText, FimMiddle, FimPrefix, FimSuffix, ImEnd, ImSep, ImStart, } from '../specialTokens.js';\nimport { CL100K_TOKEN_SPLIT_REGEX } from './constants.js';\nexport function Cl100KBase(bytePairRankDecoder) {\n const specialTokenMapping = new Map([\n [EndOfText, 100_257],\n [FimPrefix, 100_258],\n [FimMiddle, 100_259],\n [FimSuffix, 100_260],\n [ImStart, 100_264],\n [ImEnd, 100_265],\n [ImSep, 100_266],\n [EndOfPrompt, 100_276],\n ]);\n return {\n tokenSplitRegex: CL100K_TOKEN_SPLIT_REGEX,\n bytePairRankDecoder,\n specialTokensEncoder: specialTokenMapping,\n };\n}\n//# sourceMappingURL=cl100k_base.js.map","import { EndOfPrompt, EndOfText, FimMiddle, FimPrefix, FimSuffix, ImEnd, ImSep, ImStart, } from '../specialTokens.js';\nimport { O200K_TOKEN_SPLIT_REGEX } from './constants.js';\nconst O200K_BASE_SPECIAL_TOKEN_ENTRIES = [\n [EndOfText, 199_999],\n [FimPrefix, 200_000],\n [FimMiddle, 200_001],\n [FimSuffix, 200_002],\n [ImStart, 200_003],\n [ImEnd, 200_004],\n [ImSep, 200_005],\n [EndOfPrompt, 200_006],\n];\nexport const createO200KSpecialTokenMap = () => new Map(O200K_BASE_SPECIAL_TOKEN_ENTRIES);\nexport function O200KBase(bytePairRankDecoder) {\n return {\n tokenSplitRegex: O200K_TOKEN_SPLIT_REGEX,\n bytePairRankDecoder,\n specialTokensEncoder: createO200KSpecialTokenMap(),\n };\n}\n//# sourceMappingURL=o200k_base.js.map","import { EndOfPrompt, EndOfText, HarmonyCall, HarmonyChannel, HarmonyConstrain, HarmonyEnd, HarmonyMessage, HarmonyReturn, HarmonyStart, HarmonyStartOfText, } from '../specialTokens.js';\nimport { O200K_TOKEN_SPLIT_REGEX } from './constants.js';\nconst RESERVED_TOKEN_RANGE_START = 200_013;\nconst RESERVED_TOKEN_RANGE_END = 201_088; // exclusive upper bound per tiktoken\nconst STATIC_SPECIAL_TOKEN_ENTRIES = [\n [HarmonyStartOfText, 199_998],\n [EndOfText, 199_999],\n ['<|reserved_200000|>', 200_000],\n ['<|reserved_200001|>', 200_001],\n [HarmonyReturn, 200_002],\n [HarmonyConstrain, 200_003],\n ['<|reserved_200004|>', 200_004],\n [HarmonyChannel, 200_005],\n [HarmonyStart, 200_006],\n [HarmonyEnd, 200_007],\n [HarmonyMessage, 200_008],\n ['<|reserved_200009|>', 200_009],\n ['<|reserved_200010|>', 200_010],\n ['<|reserved_200011|>', 200_011],\n [HarmonyCall, 200_012],\n];\nexport function O200KHarmony(bytePairRankDecoder) {\n const specialTokensEncoder = new Map(STATIC_SPECIAL_TOKEN_ENTRIES);\n for (let tokenId = RESERVED_TOKEN_RANGE_START; tokenId < RESERVED_TOKEN_RANGE_END; tokenId += 1) {\n specialTokensEncoder.set(`<|reserved_${tokenId}|>`, tokenId);\n }\n specialTokensEncoder.set(EndOfPrompt, 200_018);\n return {\n tokenSplitRegex: O200K_TOKEN_SPLIT_REGEX,\n bytePairRankDecoder,\n specialTokensEncoder,\n chatFormatter: 'harmony',\n };\n}\n//# sourceMappingURL=o200k_harmony.js.map","import {} from '../modelParams.js';\nimport { EndOfText } from '../specialTokens.js';\nimport { R50K_TOKEN_SPLIT_REGEX } from './constants.js';\nexport function P50KBase(bytePairRankDecoder) {\n return {\n expectedVocabularySize: 50_281,\n tokenSplitRegex: R50K_TOKEN_SPLIT_REGEX,\n bytePairRankDecoder,\n specialTokensEncoder: new Map([[EndOfText, 50_256]]),\n };\n}\n//# sourceMappingURL=p50k_base.js.map","import {} from '../modelParams.js';\nimport { EndOfText, FimMiddle, FimPrefix, FimSuffix } from '../specialTokens.js';\nimport { R50K_TOKEN_SPLIT_REGEX } from './constants.js';\nexport function P50KEdit(bytePairRankDecoder) {\n const specialTokenMapping = new Map([\n [EndOfText, 50_256],\n [FimPrefix, 50_281],\n [FimMiddle, 50_282],\n [FimSuffix, 50_283],\n ]);\n return {\n tokenSplitRegex: R50K_TOKEN_SPLIT_REGEX,\n bytePairRankDecoder,\n specialTokensEncoder: specialTokenMapping,\n };\n}\n//# sourceMappingURL=p50k_edit.js.map","import {} from '../modelParams.js';\nimport { EndOfText } from '../specialTokens.js';\nimport { R50K_TOKEN_SPLIT_REGEX } from './constants.js';\nexport function R50KBase(bytePairRankDecoder) {\n return {\n expectedVocabularySize: 50_257,\n tokenSplitRegex: R50K_TOKEN_SPLIT_REGEX,\n bytePairRankDecoder,\n specialTokensEncoder: new Map([[EndOfText, 50_256]]),\n };\n}\n//# sourceMappingURL=r50k_base.js.map","import { Cl100KBase } from './encodingParams/cl100k_base.js';\nimport { O200KBase } from './encodingParams/o200k_base.js';\nimport { O200KHarmony } from './encodingParams/o200k_harmony.js';\nimport { P50KBase } from './encodingParams/p50k_base.js';\nimport { P50KEdit } from './encodingParams/p50k_edit.js';\nimport { R50KBase } from './encodingParams/r50k_base.js';\nexport function getEncodingParams(encodingName, getMergeableRanks) {\n const mergeableBytePairRanks = getMergeableRanks(encodingName);\n switch (encodingName.toLowerCase()) {\n case 'r50k_base':\n return R50KBase(mergeableBytePairRanks);\n case 'p50k_base':\n return P50KBase(mergeableBytePairRanks);\n case 'p50k_edit':\n return P50KEdit(mergeableBytePairRanks);\n case 'cl100k_base':\n return Cl100KBase(mergeableBytePairRanks);\n case 'o200k_base':\n return O200KBase(mergeableBytePairRanks);\n case 'o200k_harmony':\n return O200KHarmony(mergeableBytePairRanks);\n default:\n throw new Error(`Unknown encoding name: ${encodingName}`);\n }\n}\n//# sourceMappingURL=modelParams.js.map","/* eslint-disable @typescript-eslint/member-ordering */\n/* eslint-disable no-param-reassign */\nimport { BytePairEncodingCore, decoder } from './BytePairEncodingCore.js';\nimport { ALL_SPECIAL_TOKENS } from './constants.js';\nimport { computeChatCompletionTokenCount, } from './functionCalling.js';\nimport { chatModelParams, DEFAULT_ENCODING, modelToEncodingMap, } from './mapping.js';\nimport { getEncodingParams, } from './modelParams.js';\nimport { EndOfPrompt, EndOfText, FimMiddle, FimPrefix, FimSuffix, HarmonyCall, HarmonyChannel, HarmonyConstrain, HarmonyEnd, HarmonyMessage, HarmonyReturn, HarmonyStart, ImEnd, ImSep, ImStart, } from './specialTokens.js';\nimport { endsWithIncompleteUtfPairSurrogate } from './utfUtil.js';\nimport { getMaxValueFromMap, getSpecialTokenRegex } from './util.js';\nexport class GptEncoding {\n static EndOfPrompt = EndOfPrompt;\n static EndOfText = EndOfText;\n static FimMiddle = FimMiddle;\n static FimPrefix = FimPrefix;\n static FimSuffix = FimSuffix;\n modelName;\n modelSpec;\n bytePairEncodingCoreProcessor;\n specialTokensEncoder;\n specialTokensSet;\n allSpecialTokenRegex;\n defaultSpecialTokenConfig;\n chatFormatter;\n countChatCompletionTokens;\n vocabularySize;\n constructor({ bytePairRankDecoder: mergeableBytePairRanks, specialTokensEncoder, expectedVocabularySize, modelName, modelSpec, chatFormatter, ...rest }) {\n this.specialTokensEncoder = specialTokensEncoder;\n this.specialTokensSet = new Set(this.specialTokensEncoder.keys());\n this.allSpecialTokenRegex = getSpecialTokenRegex(this.specialTokensSet);\n this.bytePairEncodingCoreProcessor = new BytePairEncodingCore({\n bytePairRankDecoder: mergeableBytePairRanks,\n specialTokensEncoder,\n ...rest,\n });\n this.defaultSpecialTokenConfig = this.processSpecialTokens();\n const maxTokenValue = Math.max(mergeableBytePairRanks.length - 1, getMaxValueFromMap(specialTokensEncoder));\n this.vocabularySize =\n this.bytePairEncodingCoreProcessor.mergeableBytePairRankCount +\n specialTokensEncoder.size;\n if (expectedVocabularySize !== undefined) {\n if (this.vocabularySize !== expectedVocabularySize) {\n throw new Error('The number of mergeable tokens and special tokens must be equal to expectedVocabularySize.');\n }\n if (maxTokenValue !== expectedVocabularySize - 1) {\n throw new Error(`The model encodings are invalid. The maximum token value must be equal to expectedVocabularySize - 1. Currently ${maxTokenValue}, expected ${expectedVocabularySize - 1}`);\n }\n }\n this.encode = this.encode.bind(this);\n this.decode = this.decode.bind(this);\n this.encodeGenerator = this.encodeGenerator.bind(this);\n this.decodeGenerator = this.decodeGenerator.bind(this);\n this.decodeAsyncGenerator = this.decodeAsyncGenerator.bind(this);\n this.decodeAsync = this.decodeAsync.bind(this);\n this.isWithinTokenLimit = this.isWithinTokenLimit.bind(this);\n this.encodeChat = this.encodeChat.bind(this);\n this.encodeChatGenerator = this.encodeChatGenerator.bind(this);\n this.countTokens = this.countTokens.bind(this);\n this.setMergeCacheSize = this.setMergeCacheSize.bind(this);\n this.clearMergeCache = this.clearMergeCache.bind(this);\n this.estimateCost = this.estimateCost.bind(this);\n if (modelSpec?.supported_features?.includes('function_calling')) {\n this.countChatCompletionTokens =\n this.countChatCompletionTokensInternal.bind(this);\n }\n this.modelName = modelName;\n this.modelSpec = modelSpec;\n this.chatFormatter = chatFormatter ?? 'chatml';\n }\n *encodeHarmonyChatGenerator(chat, encodeOptions) {\n const harmonyStart = this.specialTokensEncoder.get(HarmonyStart);\n const harmonyMessage = this.specialTokensEncoder.get(HarmonyMessage);\n const harmonyEnd = this.specialTokensEncoder.get(HarmonyEnd);\n const harmonyReturn = this.specialTokensEncoder.get(HarmonyReturn);\n const harmonyCall = this.specialTokensEncoder.get(HarmonyCall);\n const harmonyChannel = this.specialTokensEncoder.get(HarmonyChannel);\n const harmonyConstrain = this.specialTokensEncoder.get(HarmonyConstrain);\n if (harmonyStart === undefined ||\n harmonyMessage === undefined ||\n harmonyEnd === undefined ||\n harmonyReturn === undefined ||\n harmonyCall === undefined ||\n harmonyChannel === undefined ||\n harmonyConstrain === undefined) {\n throw new Error('Harmony chat format requires dedicated special tokens.');\n }\n const encodeHeaderText = (text) => text.length > 0 ? this.encode(text) : [];\n const resolveTerminatorToken = (terminator) => {\n switch (terminator) {\n case '<|return|>':\n return harmonyReturn;\n case '<|call|>':\n return harmonyCall;\n // eslint-disable-next-line unicorn/no-useless-switch-case\n case '<|end|>':\n default:\n return harmonyEnd;\n }\n };\n for (const message of chat) {\n if (message.content === undefined) {\n throw new Error('Content must be defined for all messages.');\n }\n const roleOrName = message.name ?? message.role ?? 'user';\n yield [harmonyStart];\n yield encodeHeaderText(roleOrName);\n const recipientInRole = message.recipient &&\n (message.recipientPlacement === 'role' || !message.channel);\n const recipientInChannel = message.recipient && !recipientInRole;\n if (recipientInRole) {\n yield encodeHeaderText(` to=${message.recipient}`);\n }\n if (message.channel) {\n yield [harmonyChannel];\n yield encodeHeaderText(message.channel);\n if (recipientInChannel) {\n yield encodeHeaderText(` to=${message.recipient}`);\n }\n }\n if (message.constraint) {\n yield [harmonyConstrain];\n yield encodeHeaderText(message.constraint);\n }\n yield [harmonyMessage];\n yield* this.encodeGenerator(message.content, encodeOptions);\n yield [resolveTerminatorToken(message.terminator)];\n }\n const assistantPrime = encodeOptions?.primeWithAssistantResponse ?? 'assistant';\n if (assistantPrime.length > 0) {\n yield [harmonyStart];\n yield encodeHeaderText(assistantPrime);\n }\n }\n static getEncodingApi(encodingName, getMergeableRanks) {\n const modelParams = getEncodingParams(encodingName, getMergeableRanks);\n return new GptEncoding(modelParams);\n }\n static getEncodingApiForModel(modelName, getMergeableRanks, modelSpec) {\n const encodingName = modelToEncodingMap[modelName] ?? DEFAULT_ENCODING;\n const modelParams = getEncodingParams(encodingName, getMergeableRanks);\n return new GptEncoding({ ...modelParams, modelName, modelSpec });\n }\n processSpecialTokens({ allowedSpecial, disallowedSpecial, } = {}) {\n let regexPattern;\n if (allowedSpecial === ALL_SPECIAL_TOKENS ||\n allowedSpecial?.has(ALL_SPECIAL_TOKENS)) {\n allowedSpecial = new Set(this.specialTokensSet);\n const allowedSpecialSet = allowedSpecial;\n if (disallowedSpecial === ALL_SPECIAL_TOKENS) {\n throw new Error('allowedSpecial and disallowedSpecial cannot both be set to \"all\".');\n }\n if (typeof disallowedSpecial === 'object') {\n // remove any special tokens that are disallowed\n disallowedSpecial.forEach((val) => allowedSpecialSet.delete(val));\n }\n else {\n // all special tokens are allowed, and no 'disallowedSpecial' is provided\n disallowedSpecial = new Set();\n }\n }\n if (!disallowedSpecial ||\n disallowedSpecial === ALL_SPECIAL_TOKENS ||\n disallowedSpecial.has(ALL_SPECIAL_TOKENS)) {\n // by default, all special tokens are disallowed\n disallowedSpecial = new Set(this.specialTokensSet);\n const disallowedSpecialSet = disallowedSpecial;\n if (allowedSpecial?.size) {\n allowedSpecial.forEach((val) => disallowedSpecialSet.delete(val));\n // disallowed takes precedence over allowed\n disallowedSpecial.forEach((val) => allowedSpecial.delete(val));\n if (disallowedSpecial.size > 0) {\n regexPattern = getSpecialTokenRegex(disallowedSpecial);\n }\n }\n else {\n regexPattern = this.allSpecialTokenRegex;\n }\n }\n return { allowedSpecial, regexPattern };\n }\n encodeGenerator(lineToEncode, encodeOptions) {\n const specialTokenConfig = encodeOptions\n ? this.processSpecialTokens(encodeOptions)\n : this.defaultSpecialTokenConfig;\n if (specialTokenConfig.regexPattern) {\n const match = lineToEncode.match(specialTokenConfig.regexPattern);\n if (match !== null) {\n throw new Error(`Disallowed special token found: ${match[0]}`);\n }\n }\n return this.bytePairEncodingCoreProcessor.encodeNativeGenerator(lineToEncode, specialTokenConfig.allowedSpecial);\n }\n encode(lineToEncode, encodeOptions) {\n const specialTokenConfig = encodeOptions\n ? this.processSpecialTokens(encodeOptions)\n : this.defaultSpecialTokenConfig;\n if (specialTokenConfig.regexPattern) {\n const match = lineToEncode.match(specialTokenConfig.regexPattern);\n if (match !== null) {\n throw new Error(`Disallowed special token found: ${match[0]}`);\n }\n }\n return this.bytePairEncodingCoreProcessor.encodeNative(lineToEncode, specialTokenConfig.allowedSpecial);\n }\n /**\n * Progressively tokenizes an OpenAI chat.\n * Warning: gpt-3.5-turbo and gpt-4 chat format may change over time.\n * Returns tokens assuming the 'gpt-3.5-turbo-0301' / 'gpt-4-0314' format.\n * Based on OpenAI's guidelines: https://github.com/openai/openai-python/blob/main/chatml.md\n * Also mentioned in section 6 of this document: https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb\n * @param encodeOptions Options controlling how special tokens are handled.\n */\n *encodeChatGenerator(chat, model = this.modelName, encodeOptions) {\n if (!model) {\n throw new Error('Model name must be provided either during initialization or passed in to the method.');\n }\n const params = chatModelParams[model];\n if (!params) {\n throw new Error(`Model '${model}' does not support chat.`);\n }\n if (this.chatFormatter === 'harmony') {\n yield* this.encodeHarmonyChatGenerator(chat, encodeOptions);\n return;\n }\n const chatStartToken = this.specialTokensEncoder.get(ImStart);\n const chatEndToken = this.specialTokensEncoder.get(ImEnd);\n if (chatStartToken === undefined || chatEndToken === undefined) {\n throw new Error(`Model '${model}' does not support chat.`);\n }\n const allowedSpecial = new Set([ImSep]);\n const { messageSeparator, roleSeparator } = params;\n const encodedMessageSeparator = messageSeparator.length > 0 ? this.encode(messageSeparator) : [];\n const encodedRoleSeparator = roleSeparator.length > 0\n ? this.encode(roleSeparator, { allowedSpecial })\n : [];\n const nameCache = new Map();\n for (const { role = 'system', name = role, content } of chat) {\n if (content === undefined) {\n throw new Error('Content must be defined for all messages.');\n }\n yield [chatStartToken];\n const encodedName = nameCache.get(name) ?? this.encode(name);\n nameCache.set(name, encodedName);\n yield encodedName;\n if (encodedRoleSeparator.length > 0) {\n yield encodedRoleSeparator;\n }\n yield* this.encodeGenerator(content, encodeOptions);\n yield [chatEndToken];\n yield encodedMessageSeparator;\n }\n // every reply is primed with <|start|>assistant<|message|>\n const assistantPrime = encodeOptions?.primeWithAssistantResponse ?? 'assistant';\n if (assistantPrime.length > 0) {\n yield [chatStartToken];\n yield* this.encodeGenerator(assistantPrime, encodeOptions);\n }\n if (encodedRoleSeparator.length > 0) {\n yield encodedRoleSeparator;\n }\n }\n /**\n * Encodes a chat into a single array of tokens.\n * Warning: gpt-3.5-turbo and gpt-4 chat format may change over time.\n * Returns tokens assuming the 'gpt-3.5-turbo-0301' / 'gpt-4-0314' format.\n * Based on OpenAI's guidelines: https://github.com/openai/openai-python/blob/main/chatml.md\n * Also mentioned in section 6 of this document: https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb\n * @param encodeOptions Options controlling how special tokens are handled.\n */\n encodeChat(chat, model = this.modelName, encodeOptions) {\n return [...this.encodeChatGenerator(chat, model, encodeOptions)].flat();\n }\n /**\n * Checks whether the provided input stays within the provided token limit.\n * @param input The string or chat messages to evaluate.\n * @param tokenLimit The maximum allowed number of tokens.\n * @param encodeOptions Options controlling how special tokens are handled.\n * @returns {false | number} false if token limit is exceeded, otherwise the number of tokens\n */\n isWithinTokenLimit(input, tokenLimit, encodeOptions) {\n const tokenGenerator = typeof input === 'string'\n ? this.encodeGenerator(input, encodeOptions)\n : this.encodeChatGenerator(input, undefined, encodeOptions);\n let count = 0;\n for (const tokens of tokenGenerator) {\n count += tokens.length;\n if (count > tokenLimit) {\n return false;\n }\n }\n return count;\n }\n /**\n * Counts the number of tokens in the input.\n * @param input The string or chat messages to evaluate.\n * @param encodeOptions Options controlling how special tokens are handled.\n * @returns {number} The number of tokens.\n */\n countTokens(input, encodeOptions) {\n if (typeof input === 'string') {\n const specialTokenConfig = encodeOptions\n ? this.processSpecialTokens(encodeOptions)\n : this.defaultSpecialTokenConfig;\n if (specialTokenConfig.regexPattern) {\n const match = input.match(specialTokenConfig.regexPattern);\n if (match !== null) {\n throw new Error(`Disallowed special token found: ${match[0]}`);\n }\n }\n return this.bytePairEncodingCoreProcessor.countNative(input, specialTokenConfig.allowedSpecial);\n }\n const tokenGenerator = this.encodeChatGenerator(input, undefined, encodeOptions);\n let count = 0;\n for (const tokens of tokenGenerator) {\n count += tokens.length;\n }\n return count;\n }\n countStringTokens(text) {\n if (!text) {\n return 0;\n }\n return this.bytePairEncodingCoreProcessor.countNative(text);\n }\n countChatCompletionTokensInternal(request) {\n return computeChatCompletionTokenCount(request, (text) => this.countStringTokens(text));\n }\n setMergeCacheSize(size) {\n this.bytePairEncodingCoreProcessor.setMergeCacheSize(size);\n }\n clearMergeCache() {\n this.bytePairEncodingCoreProcessor.clearMergeCache();\n }\n decode(inputTokensToDecode) {\n return this.bytePairEncodingCoreProcessor.decodeNative(inputTokensToDecode);\n }\n *decodeGenerator(inputTokensToDecode) {\n const decodedByteGenerator = this.bytePairEncodingCoreProcessor.decodeNativeGenerator(inputTokensToDecode);\n let buffer = '';\n for (const decodedPart of decodedByteGenerator) {\n buffer +=\n typeof decodedPart === 'string'\n ? decodedPart\n : decoder.decode(decodedPart, { stream: true });\n if (buffer.length === 0 || endsWithIncompleteUtfPairSurrogate(buffer)) {\n // Keep the high surrogate in the buffer and continue with the next token\n // eslint-disable-next-line no-continue\n continue;\n }\n else {\n yield buffer;\n // reset buffer\n buffer = '';\n }\n }\n // Yield any remaining characters in the buffer\n if (buffer.length > 0) {\n yield buffer;\n }\n }\n async *decodeAsyncGenerator(inputTokensToDecode) {\n const decodedByteGenerator = this.bytePairEncodingCoreProcessor.decodeNativeAsyncIterable(inputTokensToDecode);\n let buffer = '';\n for await (const decodedPart of decodedByteGenerator) {\n buffer +=\n typeof decodedPart === 'string'\n ? decodedPart\n : decoder.decode(decodedPart, { stream: true });\n if (buffer.length === 0 || endsWithIncompleteUtfPairSurrogate(buffer)) {\n // Keep the high surrogate in the buffer and continue with the next token\n // eslint-disable-next-line no-continue\n continue;\n }\n else {\n yield buffer;\n // reset buffer\n buffer = '';\n }\n }\n // Yield any remaining characters in the buffer\n if (buffer.length > 0) {\n yield buffer;\n }\n }\n async decodeAsync(inputTokensToDecode) {\n const decodedByteGenerator = this.bytePairEncodingCoreProcessor.decodeNativeAsyncIterable(inputTokensToDecode);\n let buffer = '';\n for await (const decodedPart of decodedByteGenerator) {\n buffer +=\n typeof decodedPart === 'string'\n ? decodedPart\n : decoder.decode(decodedPart, { stream: true });\n }\n return buffer;\n }\n /**\n * Estimates the cost of processing a given token count using the model's pricing.\n *\n * @param tokenCount - The number of tokens to estimate cost for\n * @returns Cost estimate object with applicable price components (input, output, batchInput, batchOutput)\n */\n estimateCost(tokenCount, modelSpec = this.modelSpec) {\n if (!modelSpec) {\n throw new Error('Model spec must be provided either during initialization or passed in to the method.');\n }\n if (!modelSpec.price_data) {\n throw new Error(`No cost information available for model: ${modelSpec.name}`);\n }\n const priceDataPerMillion = modelSpec.price_data;\n const result = {};\n // Calculate cost per token and multiply by token count\n // eslint-disable-next-line no-magic-numbers\n const millionTokens = tokenCount / 1_000_000;\n if (priceDataPerMillion.main) {\n result.main = {\n input: priceDataPerMillion.main.input &&\n priceDataPerMillion.main.input * millionTokens,\n output: priceDataPerMillion.main.output &&\n priceDataPerMillion.main.output * millionTokens,\n cached_input: priceDataPerMillion.main.cached_input &&\n priceDataPerMillion.main.cached_input * millionTokens,\n cached_output: priceDataPerMillion.main.cached_output &&\n priceDataPerMillion.main.cached_output * millionTokens,\n };\n }\n if (priceDataPerMillion.batch) {\n result.batch = {\n input: priceDataPerMillion.batch.input &&\n priceDataPerMillion.batch.input * millionTokens,\n output: priceDataPerMillion.batch.output &&\n priceDataPerMillion.batch.output * millionTokens,\n cached_input: priceDataPerMillion.batch.cached_input &&\n priceDataPerMillion.batch.cached_input * millionTokens,\n cached_output: priceDataPerMillion.batch.cached_output &&\n priceDataPerMillion.batch.cached_output * millionTokens,\n };\n }\n return result;\n }\n}\n//# sourceMappingURL=GptEncoding.js.map"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],"mappings":";;AAAA,MAAa,qBAAqB;AAClC,MAAa,2BAA2B;;;ACCxC,MAAa,WAAW,cAAc,aAAa;AACnD,MAAM,uBAAuB;AAC7B,MAAM,qBAAq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