@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/internal/index.js
CHANGED
|
@@ -94,14 +94,18 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
94
94
|
const gptVersion = getGptVersion(modelId);
|
|
95
95
|
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);
|
|
96
96
|
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
97
|
+
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
97
98
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
98
99
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
99
100
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
100
|
-
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
101
|
+
const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
101
102
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
102
103
|
return {
|
|
103
104
|
supportsFlexProcessing,
|
|
104
105
|
supportsPriorityProcessing,
|
|
106
|
+
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
107
|
+
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
108
|
+
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
105
109
|
isReasoningModel,
|
|
106
110
|
systemMessageMode,
|
|
107
111
|
supportsNonReasoningParameters
|
|
@@ -775,6 +779,7 @@ var openaiLanguageModelChatOptions = (0, import_provider_utils4.lazySchema)(
|
|
|
775
779
|
user: import_v43.z.string().optional(),
|
|
776
780
|
/**
|
|
777
781
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
782
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
778
783
|
*/
|
|
779
784
|
reasoningEffort: import_v43.z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
780
785
|
/**
|
|
@@ -971,6 +976,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
971
976
|
})) != null ? _a2 : {};
|
|
972
977
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
973
978
|
const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
|
|
979
|
+
let resolvedReasoningEffort = openaiOptions.reasoningEffort;
|
|
980
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
981
|
+
resolvedReasoningEffort
|
|
982
|
+
)) {
|
|
983
|
+
warnings.push({
|
|
984
|
+
type: "unsupported",
|
|
985
|
+
feature: "reasoningEffort",
|
|
986
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
987
|
+
});
|
|
988
|
+
resolvedReasoningEffort = void 0;
|
|
989
|
+
}
|
|
974
990
|
if (topK != null) {
|
|
975
991
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
976
992
|
}
|
|
@@ -1015,7 +1031,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
1015
1031
|
store: openaiOptions.store,
|
|
1016
1032
|
metadata: openaiOptions.metadata,
|
|
1017
1033
|
prediction: openaiOptions.prediction,
|
|
1018
|
-
reasoning_effort:
|
|
1034
|
+
reasoning_effort: resolvedReasoningEffort,
|
|
1019
1035
|
service_tier: openaiOptions.serviceTier,
|
|
1020
1036
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
1021
1037
|
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
@@ -1024,6 +1040,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
1024
1040
|
// messages:
|
|
1025
1041
|
messages
|
|
1026
1042
|
};
|
|
1043
|
+
if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
|
|
1044
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
1045
|
+
warnings.push({
|
|
1046
|
+
type: "unsupported",
|
|
1047
|
+
feature: "promptCacheRetention",
|
|
1048
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1027
1051
|
if (isReasoningModel) {
|
|
1028
1052
|
if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
|
|
1029
1053
|
if (baseArgs.temperature != null) {
|
|
@@ -2084,9 +2108,10 @@ var baseImageModelOptionsObject = import_v49.z.object({
|
|
|
2084
2108
|
/**
|
|
2085
2109
|
* Quality of the generated image(s).
|
|
2086
2110
|
*
|
|
2087
|
-
* Valid values: `standard`, `hd`, `low`, `medium`, `high`, `auto`.
|
|
2111
|
+
* Valid values: `standard`, `hd`, `low`, `medium`, `high`, `xhigh`, `max`, `auto`.
|
|
2112
|
+
* `xhigh` and `max` are supported by GPT Image 2.5 models.
|
|
2088
2113
|
*/
|
|
2089
|
-
quality: import_v49.z.enum(["standard", "hd", "low", "medium", "high", "auto"]).optional(),
|
|
2114
|
+
quality: import_v49.z.enum(["standard", "hd", "low", "medium", "high", "xhigh", "max", "auto"]).optional(),
|
|
2090
2115
|
/**
|
|
2091
2116
|
* Background behavior for the generated image(s).
|
|
2092
2117
|
*
|
|
@@ -3217,7 +3242,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3217
3242
|
toolSearchToolName,
|
|
3218
3243
|
customProviderToolNames
|
|
3219
3244
|
}) {
|
|
3220
|
-
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;
|
|
3245
|
+
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;
|
|
3221
3246
|
let input = [];
|
|
3222
3247
|
const warnings = [];
|
|
3223
3248
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -3402,6 +3427,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3402
3427
|
}
|
|
3403
3428
|
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;
|
|
3404
3429
|
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;
|
|
3430
|
+
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;
|
|
3405
3431
|
if (hasConversation && id != null) {
|
|
3406
3432
|
break;
|
|
3407
3433
|
}
|
|
@@ -3425,7 +3451,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3425
3451
|
type: "tool_search_call",
|
|
3426
3452
|
id: id != null ? id : part.toolCallId,
|
|
3427
3453
|
execution,
|
|
3428
|
-
call_id: (
|
|
3454
|
+
call_id: (_q = parsedInput.call_id) != null ? _q : null,
|
|
3429
3455
|
status: "completed",
|
|
3430
3456
|
arguments: parsedInput.arguments
|
|
3431
3457
|
});
|
|
@@ -3439,7 +3465,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3439
3465
|
break;
|
|
3440
3466
|
}
|
|
3441
3467
|
}
|
|
3442
|
-
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((
|
|
3468
|
+
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_r = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _r : false);
|
|
3443
3469
|
if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
|
|
3444
3470
|
break;
|
|
3445
3471
|
}
|
|
@@ -3505,6 +3531,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3505
3531
|
call_id: part.toolCallId,
|
|
3506
3532
|
name: resolvedToolName,
|
|
3507
3533
|
input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
|
|
3534
|
+
...isAsync != null && { async: isAsync },
|
|
3508
3535
|
id
|
|
3509
3536
|
});
|
|
3510
3537
|
break;
|
|
@@ -3514,6 +3541,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3514
3541
|
call_id: part.toolCallId,
|
|
3515
3542
|
name: resolvedToolName,
|
|
3516
3543
|
arguments: serializeToolCallArguments2(part.input),
|
|
3544
|
+
...isAsync != null && { async: isAsync },
|
|
3517
3545
|
...namespace != null && { namespace }
|
|
3518
3546
|
});
|
|
3519
3547
|
break;
|
|
@@ -3530,7 +3558,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3530
3558
|
part.toolName
|
|
3531
3559
|
);
|
|
3532
3560
|
if (part.toolName === toolSearchToolName) {
|
|
3533
|
-
const itemId = (
|
|
3561
|
+
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;
|
|
3534
3562
|
if (store) {
|
|
3535
3563
|
input.push({ type: "item_reference", id: itemId });
|
|
3536
3564
|
} else if (part.output.type === "json") {
|
|
@@ -3571,7 +3599,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3571
3599
|
break;
|
|
3572
3600
|
}
|
|
3573
3601
|
if (store) {
|
|
3574
|
-
const itemId = (
|
|
3602
|
+
const itemId = (_A = (_z = (_y = part.providerOptions) == null ? void 0 : _y[providerOptionsName]) == null ? void 0 : _z.itemId) != null ? _A : part.toolCallId;
|
|
3575
3603
|
input.push({ type: "item_reference", id: itemId });
|
|
3576
3604
|
} else {
|
|
3577
3605
|
warnings.push({
|
|
@@ -3738,7 +3766,7 @@ ${text}`,
|
|
|
3738
3766
|
}
|
|
3739
3767
|
const output = part.output;
|
|
3740
3768
|
if (output.type === "execution-denied") {
|
|
3741
|
-
const approvalId = (
|
|
3769
|
+
const approvalId = (_C = (_B = output.providerOptions) == null ? void 0 : _B.openai) == null ? void 0 : _C.approvalId;
|
|
3742
3770
|
if (approvalId) {
|
|
3743
3771
|
continue;
|
|
3744
3772
|
}
|
|
@@ -3825,7 +3853,7 @@ ${text}`,
|
|
|
3825
3853
|
break;
|
|
3826
3854
|
case "execution-denied":
|
|
3827
3855
|
outputValue = convertScalarOutput(
|
|
3828
|
-
(
|
|
3856
|
+
(_D = output.reason) != null ? _D : "Tool call execution denied."
|
|
3829
3857
|
);
|
|
3830
3858
|
break;
|
|
3831
3859
|
case "json":
|
|
@@ -4163,6 +4191,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils26.lazySchema)(
|
|
|
4163
4191
|
call_id: import_v418.z.string(),
|
|
4164
4192
|
name: import_v418.z.string(),
|
|
4165
4193
|
arguments: import_v418.z.string(),
|
|
4194
|
+
async: import_v418.z.boolean().nullish(),
|
|
4166
4195
|
namespace: import_v418.z.string().nullish()
|
|
4167
4196
|
}),
|
|
4168
4197
|
import_v418.z.object({
|
|
@@ -4238,7 +4267,8 @@ var openaiResponsesChunkSchema = (0, import_provider_utils26.lazySchema)(
|
|
|
4238
4267
|
id: import_v418.z.string(),
|
|
4239
4268
|
call_id: import_v418.z.string(),
|
|
4240
4269
|
name: import_v418.z.string(),
|
|
4241
|
-
input: import_v418.z.string()
|
|
4270
|
+
input: import_v418.z.string(),
|
|
4271
|
+
async: import_v418.z.boolean().nullish()
|
|
4242
4272
|
}),
|
|
4243
4273
|
import_v418.z.object({
|
|
4244
4274
|
type: import_v418.z.literal("shell_call"),
|
|
@@ -4306,6 +4336,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils26.lazySchema)(
|
|
|
4306
4336
|
call_id: import_v418.z.string(),
|
|
4307
4337
|
name: import_v418.z.string(),
|
|
4308
4338
|
arguments: import_v418.z.string(),
|
|
4339
|
+
async: import_v418.z.boolean().nullish(),
|
|
4309
4340
|
status: import_v418.z.literal("completed"),
|
|
4310
4341
|
namespace: import_v418.z.string().nullish()
|
|
4311
4342
|
}),
|
|
@@ -4315,6 +4346,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils26.lazySchema)(
|
|
|
4315
4346
|
call_id: import_v418.z.string(),
|
|
4316
4347
|
name: import_v418.z.string(),
|
|
4317
4348
|
input: import_v418.z.string(),
|
|
4349
|
+
async: import_v418.z.boolean().nullish(),
|
|
4318
4350
|
status: import_v418.z.literal("completed")
|
|
4319
4351
|
}),
|
|
4320
4352
|
import_v418.z.object({
|
|
@@ -4748,6 +4780,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils26.lazySchema)(
|
|
|
4748
4780
|
name: import_v418.z.string(),
|
|
4749
4781
|
arguments: import_v418.z.string(),
|
|
4750
4782
|
id: import_v418.z.string(),
|
|
4783
|
+
async: import_v418.z.boolean().nullish(),
|
|
4751
4784
|
namespace: import_v418.z.string().nullish()
|
|
4752
4785
|
}),
|
|
4753
4786
|
import_v418.z.object({
|
|
@@ -4755,7 +4788,8 @@ var openaiResponsesResponseSchema = (0, import_provider_utils26.lazySchema)(
|
|
|
4755
4788
|
call_id: import_v418.z.string(),
|
|
4756
4789
|
name: import_v418.z.string(),
|
|
4757
4790
|
input: import_v418.z.string(),
|
|
4758
|
-
id: import_v418.z.string()
|
|
4791
|
+
id: import_v418.z.string(),
|
|
4792
|
+
async: import_v418.z.boolean().nullish()
|
|
4759
4793
|
}),
|
|
4760
4794
|
import_v418.z.object({
|
|
4761
4795
|
type: import_v418.z.literal("computer_call"),
|
|
@@ -5064,9 +5098,19 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils27.lazy
|
|
|
5064
5098
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
5065
5099
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
5066
5100
|
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5101
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5067
5102
|
* Supported values vary by model.
|
|
5068
5103
|
*/
|
|
5069
5104
|
reasoningEffort: import_v419.z.string().nullish(),
|
|
5105
|
+
/**
|
|
5106
|
+
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
5107
|
+
* without changing the request-level reasoning effort. This preserves the
|
|
5108
|
+
* request prefix for prompt caching.
|
|
5109
|
+
*
|
|
5110
|
+
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
5111
|
+
* combined with automatic truncation.
|
|
5112
|
+
*/
|
|
5113
|
+
reasoningEffortUpdate: import_v419.z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
5070
5114
|
/**
|
|
5071
5115
|
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
5072
5116
|
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
@@ -5283,7 +5327,7 @@ var imageGenerationArgsSchema = (0, import_provider_utils30.lazySchema)(
|
|
|
5283
5327
|
outputCompression: import_v422.z.number().int().min(0).max(100).optional(),
|
|
5284
5328
|
outputFormat: import_v422.z.enum(["png", "jpeg", "webp"]).optional(),
|
|
5285
5329
|
partialImages: import_v422.z.number().int().min(0).max(3).optional(),
|
|
5286
|
-
quality: import_v422.z.enum(["auto", "low", "medium", "high"]).optional(),
|
|
5330
|
+
quality: import_v422.z.enum(["auto", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
5287
5331
|
size: import_v422.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
5288
5332
|
}).strict()
|
|
5289
5333
|
)
|
|
@@ -5309,6 +5353,7 @@ var customArgsSchema = (0, import_provider_utils31.lazySchema)(
|
|
|
5309
5353
|
import_v423.z.object({
|
|
5310
5354
|
name: import_v423.z.string(),
|
|
5311
5355
|
description: import_v423.z.string().optional(),
|
|
5356
|
+
async: import_v423.z.boolean().optional(),
|
|
5312
5357
|
format: import_v423.z.union([
|
|
5313
5358
|
import_v423.z.object({
|
|
5314
5359
|
type: import_v423.z.literal("grammar"),
|
|
@@ -5501,7 +5546,8 @@ async function prepareResponsesTools({
|
|
|
5501
5546
|
toolChoice,
|
|
5502
5547
|
allowedTools,
|
|
5503
5548
|
toolNameMapping,
|
|
5504
|
-
customProviderToolNames
|
|
5549
|
+
customProviderToolNames,
|
|
5550
|
+
supportsAsyncToolCalling = true
|
|
5505
5551
|
}) {
|
|
5506
5552
|
var _a2, _b, _c, _d;
|
|
5507
5553
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -5532,7 +5578,13 @@ async function prepareResponsesTools({
|
|
|
5532
5578
|
const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
|
|
5533
5579
|
const openaiFunctionTool = prepareFunctionTool({
|
|
5534
5580
|
tool,
|
|
5535
|
-
options: openaiOptions
|
|
5581
|
+
options: openaiOptions,
|
|
5582
|
+
async: resolveAsyncToolOption({
|
|
5583
|
+
value: openaiOptions == null ? void 0 : openaiOptions.async,
|
|
5584
|
+
supportsAsyncToolCalling,
|
|
5585
|
+
toolName: tool.name,
|
|
5586
|
+
toolWarnings
|
|
5587
|
+
})
|
|
5536
5588
|
});
|
|
5537
5589
|
const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
|
|
5538
5590
|
if (namespace == null) {
|
|
@@ -5714,6 +5766,12 @@ async function prepareResponsesTools({
|
|
|
5714
5766
|
type: "custom",
|
|
5715
5767
|
name: args.name,
|
|
5716
5768
|
description: args.description,
|
|
5769
|
+
...resolveAsyncToolOption({
|
|
5770
|
+
value: args.async,
|
|
5771
|
+
supportsAsyncToolCalling,
|
|
5772
|
+
toolName: args.name,
|
|
5773
|
+
toolWarnings
|
|
5774
|
+
}) != null ? { async: args.async } : {},
|
|
5717
5775
|
format: args.format
|
|
5718
5776
|
});
|
|
5719
5777
|
resolvedCustomProviderToolNames.add(args.name);
|
|
@@ -5885,7 +5943,8 @@ function toAllowedToolResolution(tool) {
|
|
|
5885
5943
|
}
|
|
5886
5944
|
function prepareFunctionTool({
|
|
5887
5945
|
tool,
|
|
5888
|
-
options
|
|
5946
|
+
options,
|
|
5947
|
+
async
|
|
5889
5948
|
}) {
|
|
5890
5949
|
const deferLoading = options == null ? void 0 : options.deferLoading;
|
|
5891
5950
|
return {
|
|
@@ -5893,10 +5952,27 @@ function prepareFunctionTool({
|
|
|
5893
5952
|
name: tool.name,
|
|
5894
5953
|
description: tool.description,
|
|
5895
5954
|
parameters: tool.inputSchema,
|
|
5955
|
+
...async != null ? { async } : {},
|
|
5896
5956
|
...tool.strict != null ? { strict: tool.strict } : {},
|
|
5897
5957
|
...deferLoading != null ? { defer_loading: deferLoading } : {}
|
|
5898
5958
|
};
|
|
5899
5959
|
}
|
|
5960
|
+
function resolveAsyncToolOption({
|
|
5961
|
+
value,
|
|
5962
|
+
supportsAsyncToolCalling,
|
|
5963
|
+
toolName,
|
|
5964
|
+
toolWarnings
|
|
5965
|
+
}) {
|
|
5966
|
+
if (value !== true || supportsAsyncToolCalling) {
|
|
5967
|
+
return value;
|
|
5968
|
+
}
|
|
5969
|
+
toolWarnings.push({
|
|
5970
|
+
type: "unsupported",
|
|
5971
|
+
feature: `async tool calling for "${toolName}"`,
|
|
5972
|
+
details: "Async tool calling is only supported by GPT-6 and later models."
|
|
5973
|
+
});
|
|
5974
|
+
return void 0;
|
|
5975
|
+
}
|
|
5900
5976
|
function mapShellEnvironment(environment) {
|
|
5901
5977
|
if (environment.type === "containerReference") {
|
|
5902
5978
|
const env2 = environment;
|
|
@@ -5988,7 +6064,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5988
6064
|
toolChoice,
|
|
5989
6065
|
responseFormat
|
|
5990
6066
|
}) {
|
|
5991
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
6067
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
5992
6068
|
const warnings = [];
|
|
5993
6069
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
5994
6070
|
if (topK != null) {
|
|
@@ -6020,6 +6096,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6020
6096
|
});
|
|
6021
6097
|
}
|
|
6022
6098
|
const isReasoningModel = (_a2 = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a2 : modelCapabilities.isReasoningModel;
|
|
6099
|
+
let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
|
|
6100
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
6101
|
+
resolvedReasoningEffort
|
|
6102
|
+
)) {
|
|
6103
|
+
warnings.push({
|
|
6104
|
+
type: "unsupported",
|
|
6105
|
+
feature: "reasoningEffort",
|
|
6106
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
6107
|
+
});
|
|
6108
|
+
resolvedReasoningEffort = void 0;
|
|
6109
|
+
}
|
|
6023
6110
|
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
6024
6111
|
warnings.push({
|
|
6025
6112
|
type: "unsupported",
|
|
@@ -6053,7 +6140,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6053
6140
|
toolChoice,
|
|
6054
6141
|
allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
|
|
6055
6142
|
toolNameMapping,
|
|
6056
|
-
customProviderToolNames
|
|
6143
|
+
customProviderToolNames,
|
|
6144
|
+
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
|
|
6057
6145
|
});
|
|
6058
6146
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
6059
6147
|
prompt,
|
|
@@ -6072,6 +6160,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6072
6160
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
6073
6161
|
});
|
|
6074
6162
|
warnings.push(...inputWarnings);
|
|
6163
|
+
const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
|
|
6164
|
+
const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
|
|
6165
|
+
if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
|
|
6166
|
+
warnings.push({
|
|
6167
|
+
type: "unsupported",
|
|
6168
|
+
feature: "reasoningEffortUpdate",
|
|
6169
|
+
details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
|
|
6170
|
+
});
|
|
6171
|
+
} else if (reasoningEffortUpdate != null) {
|
|
6172
|
+
input.unshift({
|
|
6173
|
+
type: "configuration_update",
|
|
6174
|
+
reasoning: { effort: reasoningEffortUpdate }
|
|
6175
|
+
});
|
|
6176
|
+
}
|
|
6075
6177
|
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
6076
6178
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
6077
6179
|
function addInclude(key) {
|
|
@@ -6145,10 +6247,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6145
6247
|
top_logprobs: topLogprobs,
|
|
6146
6248
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
6147
6249
|
// model-specific settings:
|
|
6148
|
-
...isReasoningModel && (
|
|
6250
|
+
...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
|
|
6149
6251
|
reasoning: {
|
|
6150
|
-
...
|
|
6151
|
-
effort:
|
|
6252
|
+
...resolvedReasoningEffort != null && {
|
|
6253
|
+
effort: resolvedReasoningEffort
|
|
6152
6254
|
},
|
|
6153
6255
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
6154
6256
|
summary: openaiOptions.reasoningSummary
|
|
@@ -6162,6 +6264,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6162
6264
|
}
|
|
6163
6265
|
}
|
|
6164
6266
|
};
|
|
6267
|
+
if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
|
|
6268
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
6269
|
+
warnings.push({
|
|
6270
|
+
type: "unsupported",
|
|
6271
|
+
feature: "promptCacheRetention",
|
|
6272
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
6273
|
+
});
|
|
6274
|
+
}
|
|
6165
6275
|
if (isReasoningModel) {
|
|
6166
6276
|
if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
|
|
6167
6277
|
if (baseArgs.temperature != null) {
|
|
@@ -6181,6 +6291,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6181
6291
|
});
|
|
6182
6292
|
}
|
|
6183
6293
|
}
|
|
6294
|
+
if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_i = baseArgs.include) == null ? void 0 : _i.includes("message.output_text.logprobs")))) {
|
|
6295
|
+
baseArgs.top_logprobs = void 0;
|
|
6296
|
+
const filteredInclude = (_j = baseArgs.include) == null ? void 0 : _j.filter(
|
|
6297
|
+
(value) => value !== "message.output_text.logprobs"
|
|
6298
|
+
);
|
|
6299
|
+
baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
|
|
6300
|
+
warnings.push({
|
|
6301
|
+
type: "unsupported",
|
|
6302
|
+
feature: "logprobs",
|
|
6303
|
+
details: "logprobs is not supported for reasoning models"
|
|
6304
|
+
});
|
|
6305
|
+
}
|
|
6184
6306
|
} else {
|
|
6185
6307
|
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
|
|
6186
6308
|
warnings.push({
|
|
@@ -6227,9 +6349,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6227
6349
|
});
|
|
6228
6350
|
delete baseArgs.service_tier;
|
|
6229
6351
|
}
|
|
6230
|
-
const shellToolEnvType = (
|
|
6352
|
+
const shellToolEnvType = (_m = (_l = (_k = tools == null ? void 0 : tools.find(
|
|
6231
6353
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
6232
|
-
)) == null ? void 0 :
|
|
6354
|
+
)) == null ? void 0 : _k.args) == null ? void 0 : _l.environment) == null ? void 0 : _m.type;
|
|
6233
6355
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
6234
6356
|
return {
|
|
6235
6357
|
webSearchToolName,
|
|
@@ -6529,6 +6651,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6529
6651
|
providerMetadata: {
|
|
6530
6652
|
[providerOptionsName]: {
|
|
6531
6653
|
itemId: part.id,
|
|
6654
|
+
...part.async != null && { async: part.async },
|
|
6532
6655
|
...part.namespace != null && { namespace: part.namespace }
|
|
6533
6656
|
}
|
|
6534
6657
|
}
|
|
@@ -6545,7 +6668,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6545
6668
|
input: JSON.stringify(part.input),
|
|
6546
6669
|
providerMetadata: {
|
|
6547
6670
|
[providerOptionsName]: {
|
|
6548
|
-
itemId: part.id
|
|
6671
|
+
itemId: part.id,
|
|
6672
|
+
...part.async != null && { async: part.async }
|
|
6549
6673
|
}
|
|
6550
6674
|
}
|
|
6551
6675
|
});
|
|
@@ -6833,7 +6957,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6833
6957
|
toolName: value.item.name,
|
|
6834
6958
|
toolCallId: value.item.call_id,
|
|
6835
6959
|
suppressInputStreaming,
|
|
6836
|
-
bufferedInputDeltas: suppressInputStreaming ? [] : void 0
|
|
6960
|
+
bufferedInputDeltas: suppressInputStreaming ? [] : void 0,
|
|
6961
|
+
async: value.item.async
|
|
6837
6962
|
};
|
|
6838
6963
|
if (!suppressInputStreaming) {
|
|
6839
6964
|
controller.enqueue({
|
|
@@ -6848,7 +6973,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6848
6973
|
);
|
|
6849
6974
|
ongoingToolCalls[value.output_index] = {
|
|
6850
6975
|
toolName,
|
|
6851
|
-
toolCallId: value.item.call_id
|
|
6976
|
+
toolCallId: value.item.call_id,
|
|
6977
|
+
async: value.item.async
|
|
6852
6978
|
};
|
|
6853
6979
|
controller.enqueue({
|
|
6854
6980
|
type: "tool-input-start",
|
|
@@ -7092,6 +7218,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7092
7218
|
providerMetadata: {
|
|
7093
7219
|
[providerOptionsName]: {
|
|
7094
7220
|
itemId: item.id,
|
|
7221
|
+
...item.async != null ? { async: item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {},
|
|
7095
7222
|
...item.namespace != null && {
|
|
7096
7223
|
namespace: item.namespace
|
|
7097
7224
|
}
|
|
@@ -7136,6 +7263,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7136
7263
|
}
|
|
7137
7264
|
});
|
|
7138
7265
|
} else if (value.item.type === "custom_tool_call") {
|
|
7266
|
+
const ongoingToolCall = ongoingToolCalls[value.output_index];
|
|
7139
7267
|
ongoingToolCalls[value.output_index] = void 0;
|
|
7140
7268
|
hasFunctionCall = true;
|
|
7141
7269
|
const toolName = toolNameMapping.toCustomToolName(
|
|
@@ -7152,7 +7280,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7152
7280
|
input: JSON.stringify(value.item.input),
|
|
7153
7281
|
providerMetadata: {
|
|
7154
7282
|
[providerOptionsName]: {
|
|
7155
|
-
itemId: value.item.id
|
|
7283
|
+
itemId: value.item.id,
|
|
7284
|
+
...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
|
|
7156
7285
|
}
|
|
7157
7286
|
}
|
|
7158
7287
|
});
|