@gtrabanco/pi-nan-provider 1.5.5 → 1.5.7
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/AGENTS.md +57 -28
- package/README.es.md +38 -23
- package/README.md +37 -22
- package/package.json +1 -1
- package/scripts/generate-models.ts +27 -37
- package/scripts/manual-overrides.ts +168 -121
- package/scripts/models.generated.ts +217 -68
- package/src/openai-compat-sanitizer.ts +10 -9
- package/src/provider-factory.ts +6 -4
|
@@ -201,12 +201,12 @@ export interface SanitizerOptions {
|
|
|
201
201
|
/**
|
|
202
202
|
* Keep `max_completion_tokens` in the payload instead of renaming it to
|
|
203
203
|
* `max_tokens`. Set only when the model's effective `compat.maxTokensField`
|
|
204
|
-
* is `"max_completion_tokens"`
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
* documented rename runs — NaN's
|
|
208
|
-
* `max_tokens`, so hand-built
|
|
209
|
-
* the strict shape.
|
|
204
|
+
* is `"max_completion_tokens"` — the per-model mechanism introduced for
|
|
205
|
+
* issue #34. `qwen3.8-flash` used it until the gateway fix landed (#36);
|
|
206
|
+
* `qwen3.8-max` still declares it because its `max_tokens` bounds only the
|
|
207
|
+
* visible answer. When false/absent the documented rename runs — NaN's
|
|
208
|
+
* published OpenAPI schema only documents `max_tokens`, so hand-built
|
|
209
|
+
* payloads and non-overridden models stay on the strict shape.
|
|
210
210
|
*/
|
|
211
211
|
preserveMaxCompletionTokens?: boolean;
|
|
212
212
|
}
|
|
@@ -255,9 +255,10 @@ export function sanitizeOpenAICompatPayload(payload: unknown, options: Sanitizer
|
|
|
255
255
|
// must stay schema-strict.
|
|
256
256
|
if (options.preserveStreamOptions !== true) delete out.stream_options;
|
|
257
257
|
// NaN documents `max_tokens`, not `max_completion_tokens` — unless the
|
|
258
|
-
// model's compat declares `max_completion_tokens` (
|
|
259
|
-
//
|
|
260
|
-
// the catalog's maxTokensField override
|
|
258
|
+
// model's compat declares `max_completion_tokens` (the #34 mechanism,
|
|
259
|
+
// still used by `qwen3.8-max`): the gateway honors it there to bound the
|
|
260
|
+
// total, so the rename would undo the catalog's maxTokensField override
|
|
261
|
+
// before the payload leaves pi.
|
|
261
262
|
if (
|
|
262
263
|
"max_completion_tokens" in out &&
|
|
263
264
|
!("max_tokens" in out) &&
|
package/src/provider-factory.ts
CHANGED
|
@@ -121,10 +121,12 @@ function modelSupportsUsageInStreaming(model: unknown): boolean {
|
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* Whether the model's effective compat sends the `max_completion_tokens`
|
|
124
|
-
* request field instead of the classic `max_tokens` (
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
124
|
+
* request field instead of the classic `max_tokens` (the per-model mechanism
|
|
125
|
+
* from issue #34; `qwen3.8-max` is the catalog model that still uses it).
|
|
126
|
+
* The model object here is pi-ai's post-registry view — baseline catalog,
|
|
127
|
+
* live-merge refresh, `models.json` override and the #19 stale-store overlay
|
|
128
|
+
* all flow through `compat`, so this reads the value the user actually runs
|
|
129
|
+
* with.
|
|
128
130
|
*/
|
|
129
131
|
function modelSendsMaxCompletionTokens(model: unknown): boolean {
|
|
130
132
|
if (!isObject(model)) return false;
|