@jambonz/llm 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +23 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +23 -6
- package/dist/test-kit/index.cjs.map +1 -1
- package/dist/test-kit/index.d.cts +1 -1
- package/dist/test-kit/index.d.ts +1 -1
- package/dist/test-kit/index.js +23 -6
- package/dist/test-kit/index.js.map +1 -1
- package/dist/{types-DxknK0Rc.d.cts → types-DbqWrdT6.d.cts} +1 -1
- package/dist/{types-DxknK0Rc.d.ts → types-DbqWrdT6.d.ts} +1 -1
- package/package.json +1 -1
package/dist/test-kit/index.cjs
CHANGED
|
@@ -113,7 +113,10 @@ async function* streamFromOpenAI(client, req, options) {
|
|
|
113
113
|
}
|
|
114
114
|
if (req.temperature !== void 0) body.temperature = req.temperature;
|
|
115
115
|
const effectiveMaxTokens = req.maxTokens ?? options.defaultMaxTokens;
|
|
116
|
-
if (effectiveMaxTokens !== void 0)
|
|
116
|
+
if (effectiveMaxTokens !== void 0) {
|
|
117
|
+
const param = options.tokensParam ?? (needsMaxCompletionTokens(req.model) ? "max_completion_tokens" : "max_tokens");
|
|
118
|
+
body[param] = effectiveMaxTokens;
|
|
119
|
+
}
|
|
117
120
|
let stream;
|
|
118
121
|
try {
|
|
119
122
|
stream = await client.chat.completions.create(body, { signal: req.signal });
|
|
@@ -296,6 +299,9 @@ function capabilitiesFor(modelId, knownModels) {
|
|
|
296
299
|
if (known) return known.capabilities;
|
|
297
300
|
return defaultCapabilitiesForUnknown(modelId);
|
|
298
301
|
}
|
|
302
|
+
function needsMaxCompletionTokens(modelId) {
|
|
303
|
+
return /^(o\d|gpt-5)/i.test(modelId);
|
|
304
|
+
}
|
|
299
305
|
function defaultCapabilitiesForUnknown(modelId) {
|
|
300
306
|
const isReasoning = /^o[13]([-/]|$)/i.test(modelId);
|
|
301
307
|
if (isReasoning) {
|
|
@@ -1673,7 +1679,12 @@ var VertexOpenAIAdapter = class {
|
|
|
1673
1679
|
stream(req) {
|
|
1674
1680
|
return streamFromOpenAI(this.ensureClient(), req, {
|
|
1675
1681
|
knownModels: vertexOpenAIManifest.knownModels,
|
|
1676
|
-
defaultMaxTokens: 4096
|
|
1682
|
+
defaultMaxTokens: 4096,
|
|
1683
|
+
// Pin legacy `max_tokens`: Vertex's OpenAI-compat partner-model
|
|
1684
|
+
// endpoint predates `max_completion_tokens` and may not recognize it.
|
|
1685
|
+
// The model-id heuristic wouldn't catch a partner model named in the
|
|
1686
|
+
// OpenAI style (unlikely today, but defensive).
|
|
1687
|
+
tokensParam: "max_tokens"
|
|
1677
1688
|
});
|
|
1678
1689
|
}
|
|
1679
1690
|
appendAssistantToolCall(history, toolCalls) {
|
|
@@ -2367,8 +2378,8 @@ var azureOpenAIManifest = {
|
|
|
2367
2378
|
label: "API Version",
|
|
2368
2379
|
type: "text",
|
|
2369
2380
|
required: true,
|
|
2370
|
-
default: "
|
|
2371
|
-
help: "Data-plane api-version, e.g.
|
|
2381
|
+
default: "2025-03-01-preview",
|
|
2382
|
+
help: "Data-plane api-version, e.g. 2025-03-01-preview. Microsoft rolls these frequently; newer gpt-5 / o-series deployments require an api-version that supports the Responses API (2025-03-01-preview or later). See Azure OpenAI API reference docs for the current recommended version."
|
|
2372
2383
|
}
|
|
2373
2384
|
]
|
|
2374
2385
|
}
|
|
@@ -2415,7 +2426,8 @@ var AzureOpenAIAdapter = class {
|
|
|
2415
2426
|
}
|
|
2416
2427
|
stream(req) {
|
|
2417
2428
|
return streamFromOpenAI(this.ensureClient(), req, {
|
|
2418
|
-
knownModels: azureOpenAIManifest.knownModels
|
|
2429
|
+
knownModels: azureOpenAIManifest.knownModels,
|
|
2430
|
+
tokensParam: "max_completion_tokens"
|
|
2419
2431
|
});
|
|
2420
2432
|
}
|
|
2421
2433
|
appendAssistantToolCall(history, toolCalls) {
|
|
@@ -2434,7 +2446,12 @@ var AzureOpenAIAdapter = class {
|
|
|
2434
2446
|
// still requires it as a parameter.
|
|
2435
2447
|
model: "probe",
|
|
2436
2448
|
messages: [{ role: "user", content: "ping" }],
|
|
2437
|
-
max_tokens:
|
|
2449
|
+
// Use `max_completion_tokens` (not legacy `max_tokens`): gpt-5 family
|
|
2450
|
+
// and o-series reasoning models return 400 on the legacy parameter.
|
|
2451
|
+
// The newer name is a superset — also accepted by gpt-4o, gpt-4-turbo,
|
|
2452
|
+
// and gpt-3.5-turbo deployments — so it's the safe choice for a probe
|
|
2453
|
+
// that has to work regardless of the underlying deployment model.
|
|
2454
|
+
max_completion_tokens: 1,
|
|
2438
2455
|
stream: false
|
|
2439
2456
|
});
|
|
2440
2457
|
}
|