@mupt-ai/dari-gateway 1.0.372 → 1.0.374
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/dist/ingress/codex_models.js +3 -13
- package/dist/ingress/muse_models.d.ts +3 -2
- package/dist/ingress/muse_models.js +12 -7
- package/dist/models/canonical.d.ts +10 -0
- package/dist/models/canonical.js +8 -0
- package/dist/models/canonical_models.json +80 -0
- package/dist/models/context_limits.d.ts +7 -2
- package/dist/models/context_limits.js +21 -0
- package/dist/models/provider_models.json +267 -89
- package/package.json +2 -2
- package/src/ingress/codex_models.ts +3 -15
- package/src/ingress/muse_models.ts +13 -8
- package/src/models/canonical.ts +18 -0
- package/src/models/canonical_models.json +80 -0
- package/src/models/context_limits.ts +31 -2
- package/src/models/provider_models.json +267 -89
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { CANONICAL_ROUTER_MODEL, explicitModelSlug } from "../protocol/input/router_model.js";
|
|
3
|
-
import {
|
|
3
|
+
import { listedContextWindow } from "../models/context_limits.js";
|
|
4
4
|
import { modelSupportsHostedWebSearch } from "../providers/model_capabilities.js";
|
|
5
|
-
const DEFAULT_CODEX_CONTEXT_WINDOW = 128_000;
|
|
6
|
-
function codexRouterContextWindow(router) {
|
|
7
|
-
const windows = router.enabled_models.map((model) => {
|
|
8
|
-
const configured = effectiveContextWindow(router.model_configs?.[model], router.allow_long_context === true);
|
|
9
|
-
return typeof configured === "number" && Number.isFinite(configured) && configured > 0
|
|
10
|
-
? Math.floor(configured)
|
|
11
|
-
: DEFAULT_CODEX_CONTEXT_WINDOW;
|
|
12
|
-
});
|
|
13
|
-
return windows.length > 0 ? Math.max(...windows) : DEFAULT_CODEX_CONTEXT_WINDOW;
|
|
14
|
-
}
|
|
15
5
|
function codexRouterSupportsHostedWebSearch(router) {
|
|
16
6
|
return router.enabled_models.some((model) => {
|
|
17
7
|
const config = router.model_configs?.[model];
|
|
@@ -118,7 +108,7 @@ function codexCatalogEntries(router, imageInputFor) {
|
|
|
118
108
|
displayName: "Dari Routing",
|
|
119
109
|
description: "Routes Codex HTTP Responses requests through the configured Dari model router.",
|
|
120
110
|
priority: 0,
|
|
121
|
-
contextWindow:
|
|
111
|
+
contextWindow: listedContextWindow(router, router.enabled_models),
|
|
122
112
|
hostedWebSearch: codexRouterSupportsHostedWebSearch(router),
|
|
123
113
|
imageInput: router.enabled_models.some(imageInputFor),
|
|
124
114
|
})]),
|
|
@@ -127,7 +117,7 @@ function codexCatalogEntries(router, imageInputFor) {
|
|
|
127
117
|
displayName: model,
|
|
128
118
|
description: `Serves ${model} directly, without routing.`,
|
|
129
119
|
priority: index + 1,
|
|
130
|
-
contextWindow:
|
|
120
|
+
contextWindow: listedContextWindow(router, [model]),
|
|
131
121
|
hostedWebSearch: codexRouterSupportsHostedWebSearch({ ...router, enabled_models: [model] }),
|
|
132
122
|
imageInput: imageInputFor(model),
|
|
133
123
|
...codexThinkingChoices(router, model),
|
|
@@ -3,7 +3,8 @@ import type { ResolvedRouter } from "../types.js";
|
|
|
3
3
|
* Muse Code fetches its model list from its base URL's origin
|
|
4
4
|
* (`/muse-code/models`) before its first request. A list of only the router's
|
|
5
5
|
* models lets Muse Code pick from them and start on the first; `dari/routing`
|
|
6
|
-
* leads it only on the Autorouting plan.
|
|
6
|
+
* leads it only on the Autorouting plan. Muse Code compacts against the
|
|
7
|
+
* context limit each entry states in its `muse-code` metadata.
|
|
7
8
|
*/
|
|
8
|
-
export declare function museCodeModelsResponse(router: Pick<ResolvedRouter, "enabled_models" | "autorouting_enabled" | "routing_listed">): Record<string, unknown>;
|
|
9
|
+
export declare function museCodeModelsResponse(router: Pick<ResolvedRouter, "enabled_models" | "model_configs" | "allow_long_context" | "autorouting_enabled" | "routing_listed">): Record<string, unknown>;
|
|
9
10
|
export declare function handleMuseCodeModels(request: Request, routerId: string): Promise<Response>;
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import { bearerToken } from "../http/auth.js";
|
|
2
2
|
import { errorResponse } from "../http/errors.js";
|
|
3
3
|
import { resolveRouter } from "../strategies/routing.js";
|
|
4
|
+
import { listedContextWindow } from "../models/context_limits.js";
|
|
4
5
|
/**
|
|
5
6
|
* Muse Code fetches its model list from its base URL's origin
|
|
6
7
|
* (`/muse-code/models`) before its first request. A list of only the router's
|
|
7
8
|
* models lets Muse Code pick from them and start on the first; `dari/routing`
|
|
8
|
-
* leads it only on the Autorouting plan.
|
|
9
|
+
* leads it only on the Autorouting plan. Muse Code compacts against the
|
|
10
|
+
* context limit each entry states in its `muse-code` metadata.
|
|
9
11
|
*/
|
|
10
12
|
export function museCodeModelsResponse(router) {
|
|
11
|
-
const
|
|
12
|
-
...(router.autorouting_enabled === false || router.routing_listed === false
|
|
13
|
-
|
|
13
|
+
const entries = [
|
|
14
|
+
...(router.autorouting_enabled === false || router.routing_listed === false
|
|
15
|
+
? []
|
|
16
|
+
: [{ id: "dari/routing", label: "Dari Routing", models: router.enabled_models }]),
|
|
17
|
+
...router.enabled_models.map((model) => ({ id: `dari/model/${model}`, label: model, models: [model] })),
|
|
14
18
|
];
|
|
15
19
|
return {
|
|
16
|
-
data:
|
|
17
|
-
id,
|
|
18
|
-
display_label:
|
|
20
|
+
data: entries.map((entry, index) => ({
|
|
21
|
+
id: entry.id,
|
|
22
|
+
display_label: entry.label,
|
|
19
23
|
is_default: index === 0,
|
|
24
|
+
metadata: { "muse-code": { limit: { context: listedContextWindow(router, entry.models) } } },
|
|
20
25
|
})),
|
|
21
26
|
};
|
|
22
27
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { ResolvedRouterModelConfig } from "../types.js";
|
|
1
2
|
export type CanonicalModel = {
|
|
2
3
|
id: string;
|
|
3
4
|
name: string;
|
|
4
5
|
maker: string;
|
|
5
6
|
thinking_levels: string[];
|
|
7
|
+
context_window: number | null;
|
|
8
|
+
standard_context_limit: number | null;
|
|
6
9
|
providers: string[];
|
|
7
10
|
};
|
|
8
11
|
/** The canonical models Dari serves, from the monorepo's router catalog. */
|
|
@@ -21,8 +24,15 @@ export type ProviderModel = {
|
|
|
21
24
|
native_model_id: string;
|
|
22
25
|
api: string;
|
|
23
26
|
base_url: string | null;
|
|
27
|
+
context_window: number | null;
|
|
28
|
+
standard_context_limit: number | null;
|
|
24
29
|
};
|
|
25
30
|
/** How `provider` serves a model whose id names another provider, if it does. */
|
|
26
31
|
export declare function providerModel(modelId: string, provider: string): ProviderModel | undefined;
|
|
27
32
|
/** The providers and gateways besides the one its id names that serve a model. */
|
|
28
33
|
export declare function otherModelProviders(modelId: string): string[];
|
|
34
|
+
/**
|
|
35
|
+
* A model's context limits as `provider` serves it, else as its default
|
|
36
|
+
* provider does; undefined for a model the catalog does not list.
|
|
37
|
+
*/
|
|
38
|
+
export declare function catalogContextLimits(modelId: string, provider: string | undefined): Pick<ResolvedRouterModelConfig, "context_window" | "standard_context_limit"> | undefined;
|
package/dist/models/canonical.js
CHANGED
|
@@ -23,3 +23,11 @@ export function providerModel(modelId, provider) {
|
|
|
23
23
|
export function otherModelProviders(modelId) {
|
|
24
24
|
return PROVIDER_MODELS.filter((row) => row.model_id === modelId).map((row) => row.provider);
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* A model's context limits as `provider` serves it, else as its default
|
|
28
|
+
* provider does; undefined for a model the catalog does not list.
|
|
29
|
+
*/
|
|
30
|
+
export function catalogContextLimits(modelId, provider) {
|
|
31
|
+
return (provider === undefined ? undefined : providerModel(modelId, provider))
|
|
32
|
+
?? CANONICAL_MODELS.find((model) => model.id === modelId);
|
|
33
|
+
}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
"xhigh",
|
|
11
11
|
"max"
|
|
12
12
|
],
|
|
13
|
+
"context_window": 1050000,
|
|
14
|
+
"standard_context_limit": 272000,
|
|
13
15
|
"providers": [
|
|
14
16
|
"openai"
|
|
15
17
|
]
|
|
@@ -25,6 +27,8 @@
|
|
|
25
27
|
"xhigh",
|
|
26
28
|
"max"
|
|
27
29
|
],
|
|
30
|
+
"context_window": 1050000,
|
|
31
|
+
"standard_context_limit": 272000,
|
|
28
32
|
"providers": [
|
|
29
33
|
"openai"
|
|
30
34
|
]
|
|
@@ -41,6 +45,8 @@
|
|
|
41
45
|
"xhigh",
|
|
42
46
|
"max"
|
|
43
47
|
],
|
|
48
|
+
"context_window": 1050000,
|
|
49
|
+
"standard_context_limit": 272000,
|
|
44
50
|
"providers": [
|
|
45
51
|
"openai"
|
|
46
52
|
]
|
|
@@ -56,6 +62,8 @@
|
|
|
56
62
|
"xhigh",
|
|
57
63
|
"max"
|
|
58
64
|
],
|
|
65
|
+
"context_window": 1050000,
|
|
66
|
+
"standard_context_limit": 272000,
|
|
59
67
|
"providers": [
|
|
60
68
|
"openai"
|
|
61
69
|
]
|
|
@@ -72,6 +80,8 @@
|
|
|
72
80
|
"xhigh",
|
|
73
81
|
"max"
|
|
74
82
|
],
|
|
83
|
+
"context_window": 1050000,
|
|
84
|
+
"standard_context_limit": 272000,
|
|
75
85
|
"providers": [
|
|
76
86
|
"openai"
|
|
77
87
|
]
|
|
@@ -88,6 +98,8 @@
|
|
|
88
98
|
"xhigh",
|
|
89
99
|
"max"
|
|
90
100
|
],
|
|
101
|
+
"context_window": 1050000,
|
|
102
|
+
"standard_context_limit": 272000,
|
|
91
103
|
"providers": [
|
|
92
104
|
"openai"
|
|
93
105
|
]
|
|
@@ -104,6 +116,8 @@
|
|
|
104
116
|
"xhigh",
|
|
105
117
|
"max"
|
|
106
118
|
],
|
|
119
|
+
"context_window": 1050000,
|
|
120
|
+
"standard_context_limit": 272000,
|
|
107
121
|
"providers": [
|
|
108
122
|
"openai"
|
|
109
123
|
]
|
|
@@ -120,6 +134,8 @@
|
|
|
120
134
|
"xhigh",
|
|
121
135
|
"max"
|
|
122
136
|
],
|
|
137
|
+
"context_window": 1050000,
|
|
138
|
+
"standard_context_limit": 272000,
|
|
123
139
|
"providers": [
|
|
124
140
|
"openai"
|
|
125
141
|
]
|
|
@@ -136,6 +152,8 @@
|
|
|
136
152
|
"xhigh",
|
|
137
153
|
"max"
|
|
138
154
|
],
|
|
155
|
+
"context_window": 1050000,
|
|
156
|
+
"standard_context_limit": 272000,
|
|
139
157
|
"providers": [
|
|
140
158
|
"openai"
|
|
141
159
|
]
|
|
@@ -152,6 +170,8 @@
|
|
|
152
170
|
"xhigh",
|
|
153
171
|
"max"
|
|
154
172
|
],
|
|
173
|
+
"context_window": 1050000,
|
|
174
|
+
"standard_context_limit": 272000,
|
|
155
175
|
"providers": [
|
|
156
176
|
"openai"
|
|
157
177
|
]
|
|
@@ -168,6 +188,8 @@
|
|
|
168
188
|
"xhigh",
|
|
169
189
|
"max"
|
|
170
190
|
],
|
|
191
|
+
"context_window": 1000000,
|
|
192
|
+
"standard_context_limit": null,
|
|
171
193
|
"providers": [
|
|
172
194
|
"anthropic"
|
|
173
195
|
]
|
|
@@ -184,6 +206,8 @@
|
|
|
184
206
|
"xhigh",
|
|
185
207
|
"max"
|
|
186
208
|
],
|
|
209
|
+
"context_window": 1000000,
|
|
210
|
+
"standard_context_limit": null,
|
|
187
211
|
"providers": [
|
|
188
212
|
"anthropic"
|
|
189
213
|
]
|
|
@@ -199,6 +223,8 @@
|
|
|
199
223
|
"xhigh",
|
|
200
224
|
"max"
|
|
201
225
|
],
|
|
226
|
+
"context_window": 1000000,
|
|
227
|
+
"standard_context_limit": null,
|
|
202
228
|
"providers": [
|
|
203
229
|
"anthropic"
|
|
204
230
|
]
|
|
@@ -215,6 +241,8 @@
|
|
|
215
241
|
"xhigh",
|
|
216
242
|
"max"
|
|
217
243
|
],
|
|
244
|
+
"context_window": 1000000,
|
|
245
|
+
"standard_context_limit": null,
|
|
218
246
|
"providers": [
|
|
219
247
|
"anthropic"
|
|
220
248
|
]
|
|
@@ -230,6 +258,8 @@
|
|
|
230
258
|
"xhigh",
|
|
231
259
|
"max"
|
|
232
260
|
],
|
|
261
|
+
"context_window": 1000000,
|
|
262
|
+
"standard_context_limit": null,
|
|
233
263
|
"providers": [
|
|
234
264
|
"anthropic"
|
|
235
265
|
]
|
|
@@ -245,6 +275,8 @@
|
|
|
245
275
|
"xhigh",
|
|
246
276
|
"max"
|
|
247
277
|
],
|
|
278
|
+
"context_window": 1000000,
|
|
279
|
+
"standard_context_limit": null,
|
|
248
280
|
"providers": [
|
|
249
281
|
"anthropic"
|
|
250
282
|
]
|
|
@@ -260,6 +292,8 @@
|
|
|
260
292
|
"xhigh",
|
|
261
293
|
"max"
|
|
262
294
|
],
|
|
295
|
+
"context_window": 1000000,
|
|
296
|
+
"standard_context_limit": null,
|
|
263
297
|
"providers": [
|
|
264
298
|
"anthropic"
|
|
265
299
|
]
|
|
@@ -275,6 +309,8 @@
|
|
|
275
309
|
"xhigh",
|
|
276
310
|
"max"
|
|
277
311
|
],
|
|
312
|
+
"context_window": 1000000,
|
|
313
|
+
"standard_context_limit": null,
|
|
278
314
|
"providers": [
|
|
279
315
|
"anthropic"
|
|
280
316
|
]
|
|
@@ -289,6 +325,8 @@
|
|
|
289
325
|
"medium",
|
|
290
326
|
"high"
|
|
291
327
|
],
|
|
328
|
+
"context_window": 200000,
|
|
329
|
+
"standard_context_limit": null,
|
|
292
330
|
"providers": [
|
|
293
331
|
"anthropic"
|
|
294
332
|
]
|
|
@@ -305,6 +343,8 @@
|
|
|
305
343
|
"xhigh",
|
|
306
344
|
"max"
|
|
307
345
|
],
|
|
346
|
+
"context_window": 1048576,
|
|
347
|
+
"standard_context_limit": null,
|
|
308
348
|
"providers": [
|
|
309
349
|
"meta"
|
|
310
350
|
]
|
|
@@ -321,6 +361,8 @@
|
|
|
321
361
|
"xhigh",
|
|
322
362
|
"max"
|
|
323
363
|
],
|
|
364
|
+
"context_window": 1048576,
|
|
365
|
+
"standard_context_limit": null,
|
|
324
366
|
"providers": [
|
|
325
367
|
"meta"
|
|
326
368
|
]
|
|
@@ -337,6 +379,8 @@
|
|
|
337
379
|
"xhigh",
|
|
338
380
|
"max"
|
|
339
381
|
],
|
|
382
|
+
"context_window": 1048576,
|
|
383
|
+
"standard_context_limit": null,
|
|
340
384
|
"providers": [
|
|
341
385
|
"meta"
|
|
342
386
|
]
|
|
@@ -351,6 +395,8 @@
|
|
|
351
395
|
"high",
|
|
352
396
|
"xhigh"
|
|
353
397
|
],
|
|
398
|
+
"context_window": 1048576,
|
|
399
|
+
"standard_context_limit": null,
|
|
354
400
|
"providers": [
|
|
355
401
|
"fireworks",
|
|
356
402
|
"openrouter",
|
|
@@ -368,6 +414,8 @@
|
|
|
368
414
|
"high",
|
|
369
415
|
"xhigh"
|
|
370
416
|
],
|
|
417
|
+
"context_window": 1048576,
|
|
418
|
+
"standard_context_limit": null,
|
|
371
419
|
"providers": [
|
|
372
420
|
"meta"
|
|
373
421
|
]
|
|
@@ -381,6 +429,8 @@
|
|
|
381
429
|
"high",
|
|
382
430
|
"max"
|
|
383
431
|
],
|
|
432
|
+
"context_window": 1048576,
|
|
433
|
+
"standard_context_limit": null,
|
|
384
434
|
"providers": [
|
|
385
435
|
"fireworks",
|
|
386
436
|
"opencode-go",
|
|
@@ -398,6 +448,8 @@
|
|
|
398
448
|
"high",
|
|
399
449
|
"max"
|
|
400
450
|
],
|
|
451
|
+
"context_window": 1048576,
|
|
452
|
+
"standard_context_limit": null,
|
|
401
453
|
"providers": [
|
|
402
454
|
"fireworks",
|
|
403
455
|
"opencode-go",
|
|
@@ -415,6 +467,8 @@
|
|
|
415
467
|
"high",
|
|
416
468
|
"max"
|
|
417
469
|
],
|
|
470
|
+
"context_window": 1048576,
|
|
471
|
+
"standard_context_limit": null,
|
|
418
472
|
"providers": [
|
|
419
473
|
"fireworks",
|
|
420
474
|
"opencode-go",
|
|
@@ -432,6 +486,8 @@
|
|
|
432
486
|
"high",
|
|
433
487
|
"max"
|
|
434
488
|
],
|
|
489
|
+
"context_window": 1048576,
|
|
490
|
+
"standard_context_limit": null,
|
|
435
491
|
"providers": [
|
|
436
492
|
"fireworks",
|
|
437
493
|
"opencode-go",
|
|
@@ -449,6 +505,8 @@
|
|
|
449
505
|
"high",
|
|
450
506
|
"max"
|
|
451
507
|
],
|
|
508
|
+
"context_window": 1048576,
|
|
509
|
+
"standard_context_limit": null,
|
|
452
510
|
"providers": [
|
|
453
511
|
"fireworks",
|
|
454
512
|
"openrouter",
|
|
@@ -464,6 +522,8 @@
|
|
|
464
522
|
"high",
|
|
465
523
|
"max"
|
|
466
524
|
],
|
|
525
|
+
"context_window": 1048575,
|
|
526
|
+
"standard_context_limit": null,
|
|
467
527
|
"providers": [
|
|
468
528
|
"fireworks",
|
|
469
529
|
"opencode-go",
|
|
@@ -480,6 +540,8 @@
|
|
|
480
540
|
"high",
|
|
481
541
|
"max"
|
|
482
542
|
],
|
|
543
|
+
"context_window": 1000000,
|
|
544
|
+
"standard_context_limit": null,
|
|
483
545
|
"providers": [
|
|
484
546
|
"fireworks",
|
|
485
547
|
"openrouter",
|
|
@@ -495,6 +557,8 @@
|
|
|
495
557
|
"high",
|
|
496
558
|
"max"
|
|
497
559
|
],
|
|
560
|
+
"context_window": 1048576,
|
|
561
|
+
"standard_context_limit": null,
|
|
498
562
|
"providers": [
|
|
499
563
|
"fireworks",
|
|
500
564
|
"opencode-go",
|
|
@@ -511,6 +575,8 @@
|
|
|
511
575
|
"high",
|
|
512
576
|
"max"
|
|
513
577
|
],
|
|
578
|
+
"context_window": 1048576,
|
|
579
|
+
"standard_context_limit": null,
|
|
514
580
|
"providers": [
|
|
515
581
|
"fireworks",
|
|
516
582
|
"vercel-token-pass",
|
|
@@ -528,6 +594,8 @@
|
|
|
528
594
|
"high",
|
|
529
595
|
"xhigh"
|
|
530
596
|
],
|
|
597
|
+
"context_window": 500000,
|
|
598
|
+
"standard_context_limit": 200000,
|
|
531
599
|
"providers": [
|
|
532
600
|
"xai"
|
|
533
601
|
]
|
|
@@ -542,6 +610,8 @@
|
|
|
542
610
|
"high",
|
|
543
611
|
"xhigh"
|
|
544
612
|
],
|
|
613
|
+
"context_window": 500000,
|
|
614
|
+
"standard_context_limit": 200000,
|
|
545
615
|
"providers": [
|
|
546
616
|
"xai"
|
|
547
617
|
]
|
|
@@ -555,6 +625,8 @@
|
|
|
555
625
|
"medium",
|
|
556
626
|
"high"
|
|
557
627
|
],
|
|
628
|
+
"context_window": 1048576,
|
|
629
|
+
"standard_context_limit": null,
|
|
558
630
|
"providers": [
|
|
559
631
|
"google"
|
|
560
632
|
]
|
|
@@ -568,6 +640,8 @@
|
|
|
568
640
|
"medium",
|
|
569
641
|
"high"
|
|
570
642
|
],
|
|
643
|
+
"context_window": 1048576,
|
|
644
|
+
"standard_context_limit": null,
|
|
571
645
|
"providers": [
|
|
572
646
|
"google"
|
|
573
647
|
]
|
|
@@ -582,6 +656,8 @@
|
|
|
582
656
|
"high",
|
|
583
657
|
"xhigh"
|
|
584
658
|
],
|
|
659
|
+
"context_window": 1048576,
|
|
660
|
+
"standard_context_limit": null,
|
|
585
661
|
"providers": [
|
|
586
662
|
"google"
|
|
587
663
|
]
|
|
@@ -596,6 +672,8 @@
|
|
|
596
672
|
"high",
|
|
597
673
|
"xhigh"
|
|
598
674
|
],
|
|
675
|
+
"context_window": 1048576,
|
|
676
|
+
"standard_context_limit": null,
|
|
599
677
|
"providers": [
|
|
600
678
|
"google"
|
|
601
679
|
]
|
|
@@ -609,6 +687,8 @@
|
|
|
609
687
|
"medium",
|
|
610
688
|
"high"
|
|
611
689
|
],
|
|
690
|
+
"context_window": 1048576,
|
|
691
|
+
"standard_context_limit": null,
|
|
612
692
|
"providers": [
|
|
613
693
|
"google"
|
|
614
694
|
]
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import type { ResolvedRouterModelConfig } from "../types.js";
|
|
2
|
-
|
|
1
|
+
import type { ResolvedRouter, ResolvedRouterModelConfig } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The context window a model list states for an entry that `models` serve:
|
|
4
|
+
* the largest prompt any of them takes. Coding agents compact against it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function listedContextWindow(router: Pick<ResolvedRouter, "model_configs" | "allow_long_context">, models: readonly string[]): number;
|
|
7
|
+
export declare function effectiveContextWindow(config: Pick<ResolvedRouterModelConfig, "context_window" | "standard_context_limit"> | undefined, allowLongContext?: boolean): number | null;
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
import { catalogContextLimits } from "./canonical.js";
|
|
2
|
+
const DEFAULT_LISTED_CONTEXT_WINDOW = 128_000;
|
|
3
|
+
/**
|
|
4
|
+
* The context window a model list states for an entry that `models` serve:
|
|
5
|
+
* the largest prompt any of them takes. Coding agents compact against it.
|
|
6
|
+
*/
|
|
7
|
+
export function listedContextWindow(router, models) {
|
|
8
|
+
const windows = models.map((model) => {
|
|
9
|
+
const config = router.model_configs?.[model];
|
|
10
|
+
// A self-hosted gateway's configs state no limits, and a model its own
|
|
11
|
+
// provider serves there has no config: the catalog's limits apply.
|
|
12
|
+
const limits = config?.context_window == null && config?.standard_context_limit == null
|
|
13
|
+
? catalogContextLimits(model, config?.provider)
|
|
14
|
+
: config;
|
|
15
|
+
const configured = effectiveContextWindow(limits, router.allow_long_context === true);
|
|
16
|
+
return typeof configured === "number" && Number.isFinite(configured) && configured > 0
|
|
17
|
+
? Math.floor(configured)
|
|
18
|
+
: DEFAULT_LISTED_CONTEXT_WINDOW;
|
|
19
|
+
});
|
|
20
|
+
return windows.length > 0 ? Math.max(...windows) : DEFAULT_LISTED_CONTEXT_WINDOW;
|
|
21
|
+
}
|
|
1
22
|
export function effectiveContextWindow(config, allowLongContext = false) {
|
|
2
23
|
const window = config?.context_window;
|
|
3
24
|
const limit = config?.standard_context_limit;
|