@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/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-
|
|
2
|
-
export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-
|
|
1
|
+
import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-DbqWrdT6.cjs';
|
|
2
|
+
export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-DbqWrdT6.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The loose "DB-shape" input accepted by `normalizeAuth`.
|
|
@@ -25,7 +25,7 @@ interface RawCredential {
|
|
|
25
25
|
endpoint?: string | null;
|
|
26
26
|
/** Azure OpenAI deployment name (the user-created deployment, not the model id). */
|
|
27
27
|
deployment?: string | null;
|
|
28
|
-
/** Azure OpenAI data-plane api-version, e.g. `
|
|
28
|
+
/** Azure OpenAI data-plane api-version, e.g. `2025-03-01-preview`. */
|
|
29
29
|
api_version?: string | null;
|
|
30
30
|
}
|
|
31
31
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-
|
|
2
|
-
export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-
|
|
1
|
+
import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-DbqWrdT6.js';
|
|
2
|
+
export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-DbqWrdT6.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The loose "DB-shape" input accepted by `normalizeAuth`.
|
|
@@ -25,7 +25,7 @@ interface RawCredential {
|
|
|
25
25
|
endpoint?: string | null;
|
|
26
26
|
/** Azure OpenAI deployment name (the user-created deployment, not the model id). */
|
|
27
27
|
deployment?: string | null;
|
|
28
|
-
/** Azure OpenAI data-plane api-version, e.g. `
|
|
28
|
+
/** Azure OpenAI data-plane api-version, e.g. `2025-03-01-preview`. */
|
|
29
29
|
api_version?: string | null;
|
|
30
30
|
}
|
|
31
31
|
/**
|
package/dist/index.js
CHANGED
|
@@ -81,7 +81,10 @@ async function* streamFromOpenAI(client, req, options) {
|
|
|
81
81
|
}
|
|
82
82
|
if (req.temperature !== void 0) body.temperature = req.temperature;
|
|
83
83
|
const effectiveMaxTokens = req.maxTokens ?? options.defaultMaxTokens;
|
|
84
|
-
if (effectiveMaxTokens !== void 0)
|
|
84
|
+
if (effectiveMaxTokens !== void 0) {
|
|
85
|
+
const param = options.tokensParam ?? (needsMaxCompletionTokens(req.model) ? "max_completion_tokens" : "max_tokens");
|
|
86
|
+
body[param] = effectiveMaxTokens;
|
|
87
|
+
}
|
|
85
88
|
let stream;
|
|
86
89
|
try {
|
|
87
90
|
stream = await client.chat.completions.create(body, { signal: req.signal });
|
|
@@ -264,6 +267,9 @@ function capabilitiesFor(modelId, knownModels) {
|
|
|
264
267
|
if (known) return known.capabilities;
|
|
265
268
|
return defaultCapabilitiesForUnknown(modelId);
|
|
266
269
|
}
|
|
270
|
+
function needsMaxCompletionTokens(modelId) {
|
|
271
|
+
return /^(o\d|gpt-5)/i.test(modelId);
|
|
272
|
+
}
|
|
267
273
|
function defaultCapabilitiesForUnknown(modelId) {
|
|
268
274
|
const isReasoning = /^o[13]([-/]|$)/i.test(modelId);
|
|
269
275
|
if (isReasoning) {
|
|
@@ -1641,7 +1647,12 @@ var VertexOpenAIAdapter = class {
|
|
|
1641
1647
|
stream(req) {
|
|
1642
1648
|
return streamFromOpenAI(this.ensureClient(), req, {
|
|
1643
1649
|
knownModels: vertexOpenAIManifest.knownModels,
|
|
1644
|
-
defaultMaxTokens: 4096
|
|
1650
|
+
defaultMaxTokens: 4096,
|
|
1651
|
+
// Pin legacy `max_tokens`: Vertex's OpenAI-compat partner-model
|
|
1652
|
+
// endpoint predates `max_completion_tokens` and may not recognize it.
|
|
1653
|
+
// The model-id heuristic wouldn't catch a partner model named in the
|
|
1654
|
+
// OpenAI style (unlikely today, but defensive).
|
|
1655
|
+
tokensParam: "max_tokens"
|
|
1645
1656
|
});
|
|
1646
1657
|
}
|
|
1647
1658
|
appendAssistantToolCall(history, toolCalls) {
|
|
@@ -2341,8 +2352,8 @@ var azureOpenAIManifest = {
|
|
|
2341
2352
|
label: "API Version",
|
|
2342
2353
|
type: "text",
|
|
2343
2354
|
required: true,
|
|
2344
|
-
default: "
|
|
2345
|
-
help: "Data-plane api-version, e.g.
|
|
2355
|
+
default: "2025-03-01-preview",
|
|
2356
|
+
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."
|
|
2346
2357
|
}
|
|
2347
2358
|
]
|
|
2348
2359
|
}
|
|
@@ -2389,7 +2400,8 @@ var AzureOpenAIAdapter = class {
|
|
|
2389
2400
|
}
|
|
2390
2401
|
stream(req) {
|
|
2391
2402
|
return streamFromOpenAI(this.ensureClient(), req, {
|
|
2392
|
-
knownModels: azureOpenAIManifest.knownModels
|
|
2403
|
+
knownModels: azureOpenAIManifest.knownModels,
|
|
2404
|
+
tokensParam: "max_completion_tokens"
|
|
2393
2405
|
});
|
|
2394
2406
|
}
|
|
2395
2407
|
appendAssistantToolCall(history, toolCalls) {
|
|
@@ -2408,7 +2420,12 @@ var AzureOpenAIAdapter = class {
|
|
|
2408
2420
|
// still requires it as a parameter.
|
|
2409
2421
|
model: "probe",
|
|
2410
2422
|
messages: [{ role: "user", content: "ping" }],
|
|
2411
|
-
max_tokens:
|
|
2423
|
+
// Use `max_completion_tokens` (not legacy `max_tokens`): gpt-5 family
|
|
2424
|
+
// and o-series reasoning models return 400 on the legacy parameter.
|
|
2425
|
+
// The newer name is a superset — also accepted by gpt-4o, gpt-4-turbo,
|
|
2426
|
+
// and gpt-3.5-turbo deployments — so it's the safe choice for a probe
|
|
2427
|
+
// that has to work regardless of the underlying deployment model.
|
|
2428
|
+
max_completion_tokens: 1,
|
|
2412
2429
|
stream: false
|
|
2413
2430
|
});
|
|
2414
2431
|
}
|