@ai-sdk/openai 3.0.108 → 3.0.110
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/CHANGELOG.md +13 -0
- package/dist/index.d.mts +41 -21
- package/dist/index.d.ts +41 -21
- package/dist/index.js +160 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +160 -30
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +22 -9
- package/dist/internal/index.d.ts +22 -9
- package/dist/internal/index.js +157 -28
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +157 -28
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +140 -2
- package/package.json +1 -1
- package/src/chat/openai-chat-language-model.ts +31 -1
- package/src/chat/openai-chat-options.ts +1 -0
- package/src/image/openai-image-model-options.ts +3 -2
- package/src/index.ts +2 -0
- package/src/openai-language-model-capabilities.ts +10 -0
- package/src/openai-tools.ts +2 -1
- package/src/responses/convert-to-openai-responses-input.ts +14 -0
- package/src/responses/openai-responses-api.ts +20 -2
- package/src/responses/openai-responses-language-model.ts +97 -7
- package/src/responses/openai-responses-options.ts +13 -0
- package/src/responses/openai-responses-prepare-tools.ts +48 -1
- package/src/responses/openai-responses-provider-metadata.ts +10 -0
- package/src/tool/custom.ts +7 -0
- package/src/tool/image-generation.ts +6 -3
package/dist/index.js
CHANGED
|
@@ -59,14 +59,18 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
59
59
|
const gptVersion = getGptVersion(modelId);
|
|
60
60
|
const isGptChatModel = (gptVersion == null ? void 0 : gptVersion.minor) == null && ((_b = (_a2 = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _a2.startsWith("chat")) != null ? _b : false);
|
|
61
61
|
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
62
|
+
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
62
63
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
63
64
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
64
65
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
65
|
-
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
66
|
+
const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
66
67
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
67
68
|
return {
|
|
68
69
|
supportsFlexProcessing,
|
|
69
70
|
supportsPriorityProcessing,
|
|
71
|
+
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
72
|
+
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
73
|
+
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
70
74
|
isReasoningModel,
|
|
71
75
|
systemMessageMode,
|
|
72
76
|
supportsNonReasoningParameters
|
|
@@ -740,6 +744,7 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
740
744
|
user: import_v43.z.string().optional(),
|
|
741
745
|
/**
|
|
742
746
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
747
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
743
748
|
*/
|
|
744
749
|
reasoningEffort: import_v43.z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
745
750
|
/**
|
|
@@ -936,6 +941,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
936
941
|
})) != null ? _a2 : {};
|
|
937
942
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
938
943
|
const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
|
|
944
|
+
let resolvedReasoningEffort = openaiOptions.reasoningEffort;
|
|
945
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
946
|
+
resolvedReasoningEffort
|
|
947
|
+
)) {
|
|
948
|
+
warnings.push({
|
|
949
|
+
type: "unsupported",
|
|
950
|
+
feature: "reasoningEffort",
|
|
951
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
952
|
+
});
|
|
953
|
+
resolvedReasoningEffort = void 0;
|
|
954
|
+
}
|
|
939
955
|
if (topK != null) {
|
|
940
956
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
941
957
|
}
|
|
@@ -980,7 +996,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
980
996
|
store: openaiOptions.store,
|
|
981
997
|
metadata: openaiOptions.metadata,
|
|
982
998
|
prediction: openaiOptions.prediction,
|
|
983
|
-
reasoning_effort:
|
|
999
|
+
reasoning_effort: resolvedReasoningEffort,
|
|
984
1000
|
service_tier: openaiOptions.serviceTier,
|
|
985
1001
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
986
1002
|
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
@@ -989,6 +1005,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
989
1005
|
// messages:
|
|
990
1006
|
messages
|
|
991
1007
|
};
|
|
1008
|
+
if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
|
|
1009
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
1010
|
+
warnings.push({
|
|
1011
|
+
type: "unsupported",
|
|
1012
|
+
feature: "promptCacheRetention",
|
|
1013
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
992
1016
|
if (isReasoningModel) {
|
|
993
1017
|
if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
|
|
994
1018
|
if (baseArgs.temperature != null) {
|
|
@@ -2049,9 +2073,10 @@ var baseImageModelOptionsObject = import_v49.z.object({
|
|
|
2049
2073
|
/**
|
|
2050
2074
|
* Quality of the generated image(s).
|
|
2051
2075
|
*
|
|
2052
|
-
* Valid values: `standard`, `hd`, `low`, `medium`, `high`, `auto`.
|
|
2076
|
+
* Valid values: `standard`, `hd`, `low`, `medium`, `high`, `xhigh`, `max`, `auto`.
|
|
2077
|
+
* `xhigh` and `max` are supported by GPT Image 2.5 models.
|
|
2053
2078
|
*/
|
|
2054
|
-
quality: import_v49.z.enum(["standard", "hd", "low", "medium", "high", "auto"]).optional(),
|
|
2079
|
+
quality: import_v49.z.enum(["standard", "hd", "low", "medium", "high", "xhigh", "max", "auto"]).optional(),
|
|
2055
2080
|
/**
|
|
2056
2081
|
* Background behavior for the generated image(s).
|
|
2057
2082
|
*
|
|
@@ -2412,6 +2437,7 @@ var customArgsSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
2412
2437
|
import_v412.z.object({
|
|
2413
2438
|
name: import_v412.z.string(),
|
|
2414
2439
|
description: import_v412.z.string().optional(),
|
|
2440
|
+
async: import_v412.z.boolean().optional(),
|
|
2415
2441
|
format: import_v412.z.union([
|
|
2416
2442
|
import_v412.z.object({
|
|
2417
2443
|
type: import_v412.z.literal("grammar"),
|
|
@@ -2498,7 +2524,7 @@ var imageGenerationArgsSchema = (0, import_provider_utils19.lazySchema)(
|
|
|
2498
2524
|
outputCompression: import_v414.z.number().int().min(0).max(100).optional(),
|
|
2499
2525
|
outputFormat: import_v414.z.enum(["png", "jpeg", "webp"]).optional(),
|
|
2500
2526
|
partialImages: import_v414.z.number().int().min(0).max(3).optional(),
|
|
2501
|
-
quality: import_v414.z.enum(["auto", "low", "medium", "high"]).optional(),
|
|
2527
|
+
quality: import_v414.z.enum(["auto", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
2502
2528
|
size: import_v414.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
2503
2529
|
}).strict()
|
|
2504
2530
|
)
|
|
@@ -2858,6 +2884,7 @@ var openaiTools = {
|
|
|
2858
2884
|
*
|
|
2859
2885
|
* @param name - The name of the custom tool.
|
|
2860
2886
|
* @param description - An optional description of the tool.
|
|
2887
|
+
* @param async - Whether the model can continue without waiting for the tool result.
|
|
2861
2888
|
* @param format - The output format constraint (grammar type, syntax, and definition).
|
|
2862
2889
|
*/
|
|
2863
2890
|
customTool,
|
|
@@ -2893,7 +2920,7 @@ var openaiTools = {
|
|
|
2893
2920
|
* @param outputCompression - Compression level for the output image (0-100).
|
|
2894
2921
|
* @param outputFormat - The output format of the generated image. One of 'png', 'jpeg', or 'webp'.
|
|
2895
2922
|
* @param partialImages - Number of partial images to generate in streaming mode (0-3).
|
|
2896
|
-
* @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', or '
|
|
2923
|
+
* @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', 'high', 'xhigh', or 'max'. 'xhigh' and 'max' require a GPT Image 2.5 model.
|
|
2897
2924
|
* @param size - The size of the generated image. One of 'auto', '1024x1024', '1024x1536', or '1536x1024'.
|
|
2898
2925
|
*/
|
|
2899
2926
|
imageGeneration,
|
|
@@ -3273,7 +3300,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3273
3300
|
toolSearchToolName,
|
|
3274
3301
|
customProviderToolNames
|
|
3275
3302
|
}) {
|
|
3276
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
3303
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
|
|
3277
3304
|
let input = [];
|
|
3278
3305
|
const warnings = [];
|
|
3279
3306
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -3458,6 +3485,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3458
3485
|
}
|
|
3459
3486
|
const id = (_f = (_c = (_b = part.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.itemId) != null ? _f : (_e = (_d = part.providerMetadata) == null ? void 0 : _d[providerOptionsName]) == null ? void 0 : _e.itemId;
|
|
3460
3487
|
const namespace = (_k = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.namespace) != null ? _k : (_j = (_i = part.providerMetadata) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.namespace;
|
|
3488
|
+
const isAsync = (_p = (_m = (_l = part.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.async) != null ? _p : (_o = (_n = part.providerMetadata) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.async;
|
|
3461
3489
|
if (hasConversation && id != null) {
|
|
3462
3490
|
break;
|
|
3463
3491
|
}
|
|
@@ -3481,7 +3509,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3481
3509
|
type: "tool_search_call",
|
|
3482
3510
|
id: id != null ? id : part.toolCallId,
|
|
3483
3511
|
execution,
|
|
3484
|
-
call_id: (
|
|
3512
|
+
call_id: (_q = parsedInput.call_id) != null ? _q : null,
|
|
3485
3513
|
status: "completed",
|
|
3486
3514
|
arguments: parsedInput.arguments
|
|
3487
3515
|
});
|
|
@@ -3495,7 +3523,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3495
3523
|
break;
|
|
3496
3524
|
}
|
|
3497
3525
|
}
|
|
3498
|
-
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((
|
|
3526
|
+
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_r = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _r : false);
|
|
3499
3527
|
if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
|
|
3500
3528
|
break;
|
|
3501
3529
|
}
|
|
@@ -3561,6 +3589,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3561
3589
|
call_id: part.toolCallId,
|
|
3562
3590
|
name: resolvedToolName,
|
|
3563
3591
|
input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
|
|
3592
|
+
...isAsync != null && { async: isAsync },
|
|
3564
3593
|
id
|
|
3565
3594
|
});
|
|
3566
3595
|
break;
|
|
@@ -3570,6 +3599,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3570
3599
|
call_id: part.toolCallId,
|
|
3571
3600
|
name: resolvedToolName,
|
|
3572
3601
|
arguments: serializeToolCallArguments2(part.input),
|
|
3602
|
+
...isAsync != null && { async: isAsync },
|
|
3573
3603
|
...namespace != null && { namespace }
|
|
3574
3604
|
});
|
|
3575
3605
|
break;
|
|
@@ -3586,7 +3616,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3586
3616
|
part.toolName
|
|
3587
3617
|
);
|
|
3588
3618
|
if (part.toolName === toolSearchToolName) {
|
|
3589
|
-
const itemId = (
|
|
3619
|
+
const itemId = (_x = (_w = (_t = (_s = part.providerOptions) == null ? void 0 : _s[providerOptionsName]) == null ? void 0 : _t.itemId) != null ? _w : (_v = (_u = part.providerMetadata) == null ? void 0 : _u[providerOptionsName]) == null ? void 0 : _v.itemId) != null ? _x : part.toolCallId;
|
|
3590
3620
|
if (store) {
|
|
3591
3621
|
input.push({ type: "item_reference", id: itemId });
|
|
3592
3622
|
} else if (part.output.type === "json") {
|
|
@@ -3627,7 +3657,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3627
3657
|
break;
|
|
3628
3658
|
}
|
|
3629
3659
|
if (store) {
|
|
3630
|
-
const itemId = (
|
|
3660
|
+
const itemId = (_A = (_z = (_y = part.providerOptions) == null ? void 0 : _y[providerOptionsName]) == null ? void 0 : _z.itemId) != null ? _A : part.toolCallId;
|
|
3631
3661
|
input.push({ type: "item_reference", id: itemId });
|
|
3632
3662
|
} else {
|
|
3633
3663
|
warnings.push({
|
|
@@ -3794,7 +3824,7 @@ ${text}`,
|
|
|
3794
3824
|
}
|
|
3795
3825
|
const output = part.output;
|
|
3796
3826
|
if (output.type === "execution-denied") {
|
|
3797
|
-
const approvalId = (
|
|
3827
|
+
const approvalId = (_C = (_B = output.providerOptions) == null ? void 0 : _B.openai) == null ? void 0 : _C.approvalId;
|
|
3798
3828
|
if (approvalId) {
|
|
3799
3829
|
continue;
|
|
3800
3830
|
}
|
|
@@ -3881,7 +3911,7 @@ ${text}`,
|
|
|
3881
3911
|
break;
|
|
3882
3912
|
case "execution-denied":
|
|
3883
3913
|
outputValue = convertScalarOutput(
|
|
3884
|
-
(
|
|
3914
|
+
(_D = output.reason) != null ? _D : "Tool call execution denied."
|
|
3885
3915
|
);
|
|
3886
3916
|
break;
|
|
3887
3917
|
case "json":
|
|
@@ -4219,6 +4249,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4219
4249
|
call_id: import_v422.z.string(),
|
|
4220
4250
|
name: import_v422.z.string(),
|
|
4221
4251
|
arguments: import_v422.z.string(),
|
|
4252
|
+
async: import_v422.z.boolean().nullish(),
|
|
4222
4253
|
namespace: import_v422.z.string().nullish()
|
|
4223
4254
|
}),
|
|
4224
4255
|
import_v422.z.object({
|
|
@@ -4294,7 +4325,8 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4294
4325
|
id: import_v422.z.string(),
|
|
4295
4326
|
call_id: import_v422.z.string(),
|
|
4296
4327
|
name: import_v422.z.string(),
|
|
4297
|
-
input: import_v422.z.string()
|
|
4328
|
+
input: import_v422.z.string(),
|
|
4329
|
+
async: import_v422.z.boolean().nullish()
|
|
4298
4330
|
}),
|
|
4299
4331
|
import_v422.z.object({
|
|
4300
4332
|
type: import_v422.z.literal("shell_call"),
|
|
@@ -4362,6 +4394,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4362
4394
|
call_id: import_v422.z.string(),
|
|
4363
4395
|
name: import_v422.z.string(),
|
|
4364
4396
|
arguments: import_v422.z.string(),
|
|
4397
|
+
async: import_v422.z.boolean().nullish(),
|
|
4365
4398
|
status: import_v422.z.literal("completed"),
|
|
4366
4399
|
namespace: import_v422.z.string().nullish()
|
|
4367
4400
|
}),
|
|
@@ -4371,6 +4404,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4371
4404
|
call_id: import_v422.z.string(),
|
|
4372
4405
|
name: import_v422.z.string(),
|
|
4373
4406
|
input: import_v422.z.string(),
|
|
4407
|
+
async: import_v422.z.boolean().nullish(),
|
|
4374
4408
|
status: import_v422.z.literal("completed")
|
|
4375
4409
|
}),
|
|
4376
4410
|
import_v422.z.object({
|
|
@@ -4804,6 +4838,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4804
4838
|
name: import_v422.z.string(),
|
|
4805
4839
|
arguments: import_v422.z.string(),
|
|
4806
4840
|
id: import_v422.z.string(),
|
|
4841
|
+
async: import_v422.z.boolean().nullish(),
|
|
4807
4842
|
namespace: import_v422.z.string().nullish()
|
|
4808
4843
|
}),
|
|
4809
4844
|
import_v422.z.object({
|
|
@@ -4811,7 +4846,8 @@ var openaiResponsesResponseSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4811
4846
|
call_id: import_v422.z.string(),
|
|
4812
4847
|
name: import_v422.z.string(),
|
|
4813
4848
|
input: import_v422.z.string(),
|
|
4814
|
-
id: import_v422.z.string()
|
|
4849
|
+
id: import_v422.z.string(),
|
|
4850
|
+
async: import_v422.z.boolean().nullish()
|
|
4815
4851
|
}),
|
|
4816
4852
|
import_v422.z.object({
|
|
4817
4853
|
type: import_v422.z.literal("computer_call"),
|
|
@@ -5120,9 +5156,19 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils29.lazy
|
|
|
5120
5156
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
5121
5157
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
5122
5158
|
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5159
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5123
5160
|
* Supported values vary by model.
|
|
5124
5161
|
*/
|
|
5125
5162
|
reasoningEffort: import_v423.z.string().nullish(),
|
|
5163
|
+
/**
|
|
5164
|
+
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
5165
|
+
* without changing the request-level reasoning effort. This preserves the
|
|
5166
|
+
* request prefix for prompt caching.
|
|
5167
|
+
*
|
|
5168
|
+
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
5169
|
+
* combined with automatic truncation.
|
|
5170
|
+
*/
|
|
5171
|
+
reasoningEffortUpdate: import_v423.z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
5126
5172
|
/**
|
|
5127
5173
|
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
5128
5174
|
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
@@ -5233,7 +5279,8 @@ async function prepareResponsesTools({
|
|
|
5233
5279
|
toolChoice,
|
|
5234
5280
|
allowedTools,
|
|
5235
5281
|
toolNameMapping,
|
|
5236
|
-
customProviderToolNames
|
|
5282
|
+
customProviderToolNames,
|
|
5283
|
+
supportsAsyncToolCalling = true
|
|
5237
5284
|
}) {
|
|
5238
5285
|
var _a2, _b, _c, _d;
|
|
5239
5286
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -5264,7 +5311,13 @@ async function prepareResponsesTools({
|
|
|
5264
5311
|
const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
|
|
5265
5312
|
const openaiFunctionTool = prepareFunctionTool({
|
|
5266
5313
|
tool,
|
|
5267
|
-
options: openaiOptions
|
|
5314
|
+
options: openaiOptions,
|
|
5315
|
+
async: resolveAsyncToolOption({
|
|
5316
|
+
value: openaiOptions == null ? void 0 : openaiOptions.async,
|
|
5317
|
+
supportsAsyncToolCalling,
|
|
5318
|
+
toolName: tool.name,
|
|
5319
|
+
toolWarnings
|
|
5320
|
+
})
|
|
5268
5321
|
});
|
|
5269
5322
|
const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
|
|
5270
5323
|
if (namespace == null) {
|
|
@@ -5446,6 +5499,12 @@ async function prepareResponsesTools({
|
|
|
5446
5499
|
type: "custom",
|
|
5447
5500
|
name: args.name,
|
|
5448
5501
|
description: args.description,
|
|
5502
|
+
...resolveAsyncToolOption({
|
|
5503
|
+
value: args.async,
|
|
5504
|
+
supportsAsyncToolCalling,
|
|
5505
|
+
toolName: args.name,
|
|
5506
|
+
toolWarnings
|
|
5507
|
+
}) != null ? { async: args.async } : {},
|
|
5449
5508
|
format: args.format
|
|
5450
5509
|
});
|
|
5451
5510
|
resolvedCustomProviderToolNames.add(args.name);
|
|
@@ -5617,7 +5676,8 @@ function toAllowedToolResolution(tool) {
|
|
|
5617
5676
|
}
|
|
5618
5677
|
function prepareFunctionTool({
|
|
5619
5678
|
tool,
|
|
5620
|
-
options
|
|
5679
|
+
options,
|
|
5680
|
+
async
|
|
5621
5681
|
}) {
|
|
5622
5682
|
const deferLoading = options == null ? void 0 : options.deferLoading;
|
|
5623
5683
|
return {
|
|
@@ -5625,10 +5685,27 @@ function prepareFunctionTool({
|
|
|
5625
5685
|
name: tool.name,
|
|
5626
5686
|
description: tool.description,
|
|
5627
5687
|
parameters: tool.inputSchema,
|
|
5688
|
+
...async != null ? { async } : {},
|
|
5628
5689
|
...tool.strict != null ? { strict: tool.strict } : {},
|
|
5629
5690
|
...deferLoading != null ? { defer_loading: deferLoading } : {}
|
|
5630
5691
|
};
|
|
5631
5692
|
}
|
|
5693
|
+
function resolveAsyncToolOption({
|
|
5694
|
+
value,
|
|
5695
|
+
supportsAsyncToolCalling,
|
|
5696
|
+
toolName,
|
|
5697
|
+
toolWarnings
|
|
5698
|
+
}) {
|
|
5699
|
+
if (value !== true || supportsAsyncToolCalling) {
|
|
5700
|
+
return value;
|
|
5701
|
+
}
|
|
5702
|
+
toolWarnings.push({
|
|
5703
|
+
type: "unsupported",
|
|
5704
|
+
feature: `async tool calling for "${toolName}"`,
|
|
5705
|
+
details: "Async tool calling is only supported by GPT-6 and later models."
|
|
5706
|
+
});
|
|
5707
|
+
return void 0;
|
|
5708
|
+
}
|
|
5632
5709
|
function mapShellEnvironment(environment) {
|
|
5633
5710
|
if (environment.type === "containerReference") {
|
|
5634
5711
|
const env2 = environment;
|
|
@@ -5720,7 +5797,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5720
5797
|
toolChoice,
|
|
5721
5798
|
responseFormat
|
|
5722
5799
|
}) {
|
|
5723
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5800
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
5724
5801
|
const warnings = [];
|
|
5725
5802
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
5726
5803
|
if (topK != null) {
|
|
@@ -5752,6 +5829,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5752
5829
|
});
|
|
5753
5830
|
}
|
|
5754
5831
|
const isReasoningModel = (_a2 = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a2 : modelCapabilities.isReasoningModel;
|
|
5832
|
+
let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
|
|
5833
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
5834
|
+
resolvedReasoningEffort
|
|
5835
|
+
)) {
|
|
5836
|
+
warnings.push({
|
|
5837
|
+
type: "unsupported",
|
|
5838
|
+
feature: "reasoningEffort",
|
|
5839
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
5840
|
+
});
|
|
5841
|
+
resolvedReasoningEffort = void 0;
|
|
5842
|
+
}
|
|
5755
5843
|
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
5756
5844
|
warnings.push({
|
|
5757
5845
|
type: "unsupported",
|
|
@@ -5785,7 +5873,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5785
5873
|
toolChoice,
|
|
5786
5874
|
allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
|
|
5787
5875
|
toolNameMapping,
|
|
5788
|
-
customProviderToolNames
|
|
5876
|
+
customProviderToolNames,
|
|
5877
|
+
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
|
|
5789
5878
|
});
|
|
5790
5879
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
5791
5880
|
prompt,
|
|
@@ -5804,6 +5893,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5804
5893
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
5805
5894
|
});
|
|
5806
5895
|
warnings.push(...inputWarnings);
|
|
5896
|
+
const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
|
|
5897
|
+
const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
|
|
5898
|
+
if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
|
|
5899
|
+
warnings.push({
|
|
5900
|
+
type: "unsupported",
|
|
5901
|
+
feature: "reasoningEffortUpdate",
|
|
5902
|
+
details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
|
|
5903
|
+
});
|
|
5904
|
+
} else if (reasoningEffortUpdate != null) {
|
|
5905
|
+
input.unshift({
|
|
5906
|
+
type: "configuration_update",
|
|
5907
|
+
reasoning: { effort: reasoningEffortUpdate }
|
|
5908
|
+
});
|
|
5909
|
+
}
|
|
5807
5910
|
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
5808
5911
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
5809
5912
|
function addInclude(key) {
|
|
@@ -5877,10 +5980,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5877
5980
|
top_logprobs: topLogprobs,
|
|
5878
5981
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
5879
5982
|
// model-specific settings:
|
|
5880
|
-
...isReasoningModel && (
|
|
5983
|
+
...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
|
|
5881
5984
|
reasoning: {
|
|
5882
|
-
...
|
|
5883
|
-
effort:
|
|
5985
|
+
...resolvedReasoningEffort != null && {
|
|
5986
|
+
effort: resolvedReasoningEffort
|
|
5884
5987
|
},
|
|
5885
5988
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
5886
5989
|
summary: openaiOptions.reasoningSummary
|
|
@@ -5894,6 +5997,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5894
5997
|
}
|
|
5895
5998
|
}
|
|
5896
5999
|
};
|
|
6000
|
+
if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
|
|
6001
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
6002
|
+
warnings.push({
|
|
6003
|
+
type: "unsupported",
|
|
6004
|
+
feature: "promptCacheRetention",
|
|
6005
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
6006
|
+
});
|
|
6007
|
+
}
|
|
5897
6008
|
if (isReasoningModel) {
|
|
5898
6009
|
if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
|
|
5899
6010
|
if (baseArgs.temperature != null) {
|
|
@@ -5913,6 +6024,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5913
6024
|
});
|
|
5914
6025
|
}
|
|
5915
6026
|
}
|
|
6027
|
+
if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_i = baseArgs.include) == null ? void 0 : _i.includes("message.output_text.logprobs")))) {
|
|
6028
|
+
baseArgs.top_logprobs = void 0;
|
|
6029
|
+
const filteredInclude = (_j = baseArgs.include) == null ? void 0 : _j.filter(
|
|
6030
|
+
(value) => value !== "message.output_text.logprobs"
|
|
6031
|
+
);
|
|
6032
|
+
baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
|
|
6033
|
+
warnings.push({
|
|
6034
|
+
type: "unsupported",
|
|
6035
|
+
feature: "logprobs",
|
|
6036
|
+
details: "logprobs is not supported for reasoning models"
|
|
6037
|
+
});
|
|
6038
|
+
}
|
|
5916
6039
|
} else {
|
|
5917
6040
|
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
|
|
5918
6041
|
warnings.push({
|
|
@@ -5959,9 +6082,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5959
6082
|
});
|
|
5960
6083
|
delete baseArgs.service_tier;
|
|
5961
6084
|
}
|
|
5962
|
-
const shellToolEnvType = (
|
|
6085
|
+
const shellToolEnvType = (_m = (_l = (_k = tools == null ? void 0 : tools.find(
|
|
5963
6086
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
5964
|
-
)) == null ? void 0 :
|
|
6087
|
+
)) == null ? void 0 : _k.args) == null ? void 0 : _l.environment) == null ? void 0 : _m.type;
|
|
5965
6088
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
5966
6089
|
return {
|
|
5967
6090
|
webSearchToolName,
|
|
@@ -6261,6 +6384,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6261
6384
|
providerMetadata: {
|
|
6262
6385
|
[providerOptionsName]: {
|
|
6263
6386
|
itemId: part.id,
|
|
6387
|
+
...part.async != null && { async: part.async },
|
|
6264
6388
|
...part.namespace != null && { namespace: part.namespace }
|
|
6265
6389
|
}
|
|
6266
6390
|
}
|
|
@@ -6277,7 +6401,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6277
6401
|
input: JSON.stringify(part.input),
|
|
6278
6402
|
providerMetadata: {
|
|
6279
6403
|
[providerOptionsName]: {
|
|
6280
|
-
itemId: part.id
|
|
6404
|
+
itemId: part.id,
|
|
6405
|
+
...part.async != null && { async: part.async }
|
|
6281
6406
|
}
|
|
6282
6407
|
}
|
|
6283
6408
|
});
|
|
@@ -6565,7 +6690,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6565
6690
|
toolName: value.item.name,
|
|
6566
6691
|
toolCallId: value.item.call_id,
|
|
6567
6692
|
suppressInputStreaming,
|
|
6568
|
-
bufferedInputDeltas: suppressInputStreaming ? [] : void 0
|
|
6693
|
+
bufferedInputDeltas: suppressInputStreaming ? [] : void 0,
|
|
6694
|
+
async: value.item.async
|
|
6569
6695
|
};
|
|
6570
6696
|
if (!suppressInputStreaming) {
|
|
6571
6697
|
controller.enqueue({
|
|
@@ -6580,7 +6706,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6580
6706
|
);
|
|
6581
6707
|
ongoingToolCalls[value.output_index] = {
|
|
6582
6708
|
toolName,
|
|
6583
|
-
toolCallId: value.item.call_id
|
|
6709
|
+
toolCallId: value.item.call_id,
|
|
6710
|
+
async: value.item.async
|
|
6584
6711
|
};
|
|
6585
6712
|
controller.enqueue({
|
|
6586
6713
|
type: "tool-input-start",
|
|
@@ -6824,6 +6951,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6824
6951
|
providerMetadata: {
|
|
6825
6952
|
[providerOptionsName]: {
|
|
6826
6953
|
itemId: item.id,
|
|
6954
|
+
...item.async != null ? { async: item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {},
|
|
6827
6955
|
...item.namespace != null && {
|
|
6828
6956
|
namespace: item.namespace
|
|
6829
6957
|
}
|
|
@@ -6868,6 +6996,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6868
6996
|
}
|
|
6869
6997
|
});
|
|
6870
6998
|
} else if (value.item.type === "custom_tool_call") {
|
|
6999
|
+
const ongoingToolCall = ongoingToolCalls[value.output_index];
|
|
6871
7000
|
ongoingToolCalls[value.output_index] = void 0;
|
|
6872
7001
|
hasFunctionCall = true;
|
|
6873
7002
|
const toolName = toolNameMapping.toCustomToolName(
|
|
@@ -6884,7 +7013,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6884
7013
|
input: JSON.stringify(value.item.input),
|
|
6885
7014
|
providerMetadata: {
|
|
6886
7015
|
[providerOptionsName]: {
|
|
6887
|
-
itemId: value.item.id
|
|
7016
|
+
itemId: value.item.id,
|
|
7017
|
+
...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
|
|
6888
7018
|
}
|
|
6889
7019
|
}
|
|
6890
7020
|
});
|
|
@@ -7962,7 +8092,7 @@ var OpenAITranscriptionModel = class {
|
|
|
7962
8092
|
};
|
|
7963
8093
|
|
|
7964
8094
|
// src/version.ts
|
|
7965
|
-
var VERSION = true ? "3.0.
|
|
8095
|
+
var VERSION = true ? "3.0.110" : "0.0.0-test";
|
|
7966
8096
|
|
|
7967
8097
|
// src/openai-provider.ts
|
|
7968
8098
|
function createOpenAI(options = {}) {
|