@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.mjs
CHANGED
|
@@ -37,14 +37,18 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
37
37
|
const gptVersion = getGptVersion(modelId);
|
|
38
38
|
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);
|
|
39
39
|
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
40
|
+
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
40
41
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
41
42
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
42
43
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
43
|
-
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
44
|
+
const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
44
45
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
45
46
|
return {
|
|
46
47
|
supportsFlexProcessing,
|
|
47
48
|
supportsPriorityProcessing,
|
|
49
|
+
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
50
|
+
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
51
|
+
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
48
52
|
isReasoningModel,
|
|
49
53
|
systemMessageMode,
|
|
50
54
|
supportsNonReasoningParameters
|
|
@@ -726,6 +730,7 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
726
730
|
user: z3.string().optional(),
|
|
727
731
|
/**
|
|
728
732
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
733
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
729
734
|
*/
|
|
730
735
|
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
731
736
|
/**
|
|
@@ -924,6 +929,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
924
929
|
})) != null ? _a2 : {};
|
|
925
930
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
926
931
|
const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
|
|
932
|
+
let resolvedReasoningEffort = openaiOptions.reasoningEffort;
|
|
933
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
934
|
+
resolvedReasoningEffort
|
|
935
|
+
)) {
|
|
936
|
+
warnings.push({
|
|
937
|
+
type: "unsupported",
|
|
938
|
+
feature: "reasoningEffort",
|
|
939
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
940
|
+
});
|
|
941
|
+
resolvedReasoningEffort = void 0;
|
|
942
|
+
}
|
|
927
943
|
if (topK != null) {
|
|
928
944
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
929
945
|
}
|
|
@@ -968,7 +984,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
968
984
|
store: openaiOptions.store,
|
|
969
985
|
metadata: openaiOptions.metadata,
|
|
970
986
|
prediction: openaiOptions.prediction,
|
|
971
|
-
reasoning_effort:
|
|
987
|
+
reasoning_effort: resolvedReasoningEffort,
|
|
972
988
|
service_tier: openaiOptions.serviceTier,
|
|
973
989
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
974
990
|
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
@@ -977,6 +993,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
977
993
|
// messages:
|
|
978
994
|
messages
|
|
979
995
|
};
|
|
996
|
+
if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
|
|
997
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
998
|
+
warnings.push({
|
|
999
|
+
type: "unsupported",
|
|
1000
|
+
feature: "promptCacheRetention",
|
|
1001
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
980
1004
|
if (isReasoningModel) {
|
|
981
1005
|
if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
|
|
982
1006
|
if (baseArgs.temperature != null) {
|
|
@@ -2075,9 +2099,10 @@ var baseImageModelOptionsObject = z9.object({
|
|
|
2075
2099
|
/**
|
|
2076
2100
|
* Quality of the generated image(s).
|
|
2077
2101
|
*
|
|
2078
|
-
* Valid values: `standard`, `hd`, `low`, `medium`, `high`, `auto`.
|
|
2102
|
+
* Valid values: `standard`, `hd`, `low`, `medium`, `high`, `xhigh`, `max`, `auto`.
|
|
2103
|
+
* `xhigh` and `max` are supported by GPT Image 2.5 models.
|
|
2079
2104
|
*/
|
|
2080
|
-
quality: z9.enum(["standard", "hd", "low", "medium", "high", "auto"]).optional(),
|
|
2105
|
+
quality: z9.enum(["standard", "hd", "low", "medium", "high", "xhigh", "max", "auto"]).optional(),
|
|
2081
2106
|
/**
|
|
2082
2107
|
* Background behavior for the generated image(s).
|
|
2083
2108
|
*
|
|
@@ -3262,7 +3287,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3262
3287
|
toolSearchToolName,
|
|
3263
3288
|
customProviderToolNames
|
|
3264
3289
|
}) {
|
|
3265
|
-
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;
|
|
3290
|
+
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;
|
|
3266
3291
|
let input = [];
|
|
3267
3292
|
const warnings = [];
|
|
3268
3293
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -3447,6 +3472,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3447
3472
|
}
|
|
3448
3473
|
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;
|
|
3449
3474
|
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;
|
|
3475
|
+
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;
|
|
3450
3476
|
if (hasConversation && id != null) {
|
|
3451
3477
|
break;
|
|
3452
3478
|
}
|
|
@@ -3470,7 +3496,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3470
3496
|
type: "tool_search_call",
|
|
3471
3497
|
id: id != null ? id : part.toolCallId,
|
|
3472
3498
|
execution,
|
|
3473
|
-
call_id: (
|
|
3499
|
+
call_id: (_q = parsedInput.call_id) != null ? _q : null,
|
|
3474
3500
|
status: "completed",
|
|
3475
3501
|
arguments: parsedInput.arguments
|
|
3476
3502
|
});
|
|
@@ -3484,7 +3510,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3484
3510
|
break;
|
|
3485
3511
|
}
|
|
3486
3512
|
}
|
|
3487
|
-
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((
|
|
3513
|
+
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_r = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _r : false);
|
|
3488
3514
|
if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
|
|
3489
3515
|
break;
|
|
3490
3516
|
}
|
|
@@ -3550,6 +3576,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3550
3576
|
call_id: part.toolCallId,
|
|
3551
3577
|
name: resolvedToolName,
|
|
3552
3578
|
input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
|
|
3579
|
+
...isAsync != null && { async: isAsync },
|
|
3553
3580
|
id
|
|
3554
3581
|
});
|
|
3555
3582
|
break;
|
|
@@ -3559,6 +3586,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3559
3586
|
call_id: part.toolCallId,
|
|
3560
3587
|
name: resolvedToolName,
|
|
3561
3588
|
arguments: serializeToolCallArguments2(part.input),
|
|
3589
|
+
...isAsync != null && { async: isAsync },
|
|
3562
3590
|
...namespace != null && { namespace }
|
|
3563
3591
|
});
|
|
3564
3592
|
break;
|
|
@@ -3575,7 +3603,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3575
3603
|
part.toolName
|
|
3576
3604
|
);
|
|
3577
3605
|
if (part.toolName === toolSearchToolName) {
|
|
3578
|
-
const itemId = (
|
|
3606
|
+
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;
|
|
3579
3607
|
if (store) {
|
|
3580
3608
|
input.push({ type: "item_reference", id: itemId });
|
|
3581
3609
|
} else if (part.output.type === "json") {
|
|
@@ -3616,7 +3644,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3616
3644
|
break;
|
|
3617
3645
|
}
|
|
3618
3646
|
if (store) {
|
|
3619
|
-
const itemId = (
|
|
3647
|
+
const itemId = (_A = (_z = (_y = part.providerOptions) == null ? void 0 : _y[providerOptionsName]) == null ? void 0 : _z.itemId) != null ? _A : part.toolCallId;
|
|
3620
3648
|
input.push({ type: "item_reference", id: itemId });
|
|
3621
3649
|
} else {
|
|
3622
3650
|
warnings.push({
|
|
@@ -3783,7 +3811,7 @@ ${text}`,
|
|
|
3783
3811
|
}
|
|
3784
3812
|
const output = part.output;
|
|
3785
3813
|
if (output.type === "execution-denied") {
|
|
3786
|
-
const approvalId = (
|
|
3814
|
+
const approvalId = (_C = (_B = output.providerOptions) == null ? void 0 : _B.openai) == null ? void 0 : _C.approvalId;
|
|
3787
3815
|
if (approvalId) {
|
|
3788
3816
|
continue;
|
|
3789
3817
|
}
|
|
@@ -3870,7 +3898,7 @@ ${text}`,
|
|
|
3870
3898
|
break;
|
|
3871
3899
|
case "execution-denied":
|
|
3872
3900
|
outputValue = convertScalarOutput(
|
|
3873
|
-
(
|
|
3901
|
+
(_D = output.reason) != null ? _D : "Tool call execution denied."
|
|
3874
3902
|
);
|
|
3875
3903
|
break;
|
|
3876
3904
|
case "json":
|
|
@@ -4211,6 +4239,7 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
4211
4239
|
call_id: z18.string(),
|
|
4212
4240
|
name: z18.string(),
|
|
4213
4241
|
arguments: z18.string(),
|
|
4242
|
+
async: z18.boolean().nullish(),
|
|
4214
4243
|
namespace: z18.string().nullish()
|
|
4215
4244
|
}),
|
|
4216
4245
|
z18.object({
|
|
@@ -4286,7 +4315,8 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
4286
4315
|
id: z18.string(),
|
|
4287
4316
|
call_id: z18.string(),
|
|
4288
4317
|
name: z18.string(),
|
|
4289
|
-
input: z18.string()
|
|
4318
|
+
input: z18.string(),
|
|
4319
|
+
async: z18.boolean().nullish()
|
|
4290
4320
|
}),
|
|
4291
4321
|
z18.object({
|
|
4292
4322
|
type: z18.literal("shell_call"),
|
|
@@ -4354,6 +4384,7 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
4354
4384
|
call_id: z18.string(),
|
|
4355
4385
|
name: z18.string(),
|
|
4356
4386
|
arguments: z18.string(),
|
|
4387
|
+
async: z18.boolean().nullish(),
|
|
4357
4388
|
status: z18.literal("completed"),
|
|
4358
4389
|
namespace: z18.string().nullish()
|
|
4359
4390
|
}),
|
|
@@ -4363,6 +4394,7 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
4363
4394
|
call_id: z18.string(),
|
|
4364
4395
|
name: z18.string(),
|
|
4365
4396
|
input: z18.string(),
|
|
4397
|
+
async: z18.boolean().nullish(),
|
|
4366
4398
|
status: z18.literal("completed")
|
|
4367
4399
|
}),
|
|
4368
4400
|
z18.object({
|
|
@@ -4796,6 +4828,7 @@ var openaiResponsesResponseSchema = lazySchema16(
|
|
|
4796
4828
|
name: z18.string(),
|
|
4797
4829
|
arguments: z18.string(),
|
|
4798
4830
|
id: z18.string(),
|
|
4831
|
+
async: z18.boolean().nullish(),
|
|
4799
4832
|
namespace: z18.string().nullish()
|
|
4800
4833
|
}),
|
|
4801
4834
|
z18.object({
|
|
@@ -4803,7 +4836,8 @@ var openaiResponsesResponseSchema = lazySchema16(
|
|
|
4803
4836
|
call_id: z18.string(),
|
|
4804
4837
|
name: z18.string(),
|
|
4805
4838
|
input: z18.string(),
|
|
4806
|
-
id: z18.string()
|
|
4839
|
+
id: z18.string(),
|
|
4840
|
+
async: z18.boolean().nullish()
|
|
4807
4841
|
}),
|
|
4808
4842
|
z18.object({
|
|
4809
4843
|
type: z18.literal("computer_call"),
|
|
@@ -5115,9 +5149,19 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
|
|
|
5115
5149
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
5116
5150
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
5117
5151
|
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5152
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5118
5153
|
* Supported values vary by model.
|
|
5119
5154
|
*/
|
|
5120
5155
|
reasoningEffort: z19.string().nullish(),
|
|
5156
|
+
/**
|
|
5157
|
+
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
5158
|
+
* without changing the request-level reasoning effort. This preserves the
|
|
5159
|
+
* request prefix for prompt caching.
|
|
5160
|
+
*
|
|
5161
|
+
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
5162
|
+
* combined with automatic truncation.
|
|
5163
|
+
*/
|
|
5164
|
+
reasoningEffortUpdate: z19.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
5121
5165
|
/**
|
|
5122
5166
|
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
5123
5167
|
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
@@ -5348,7 +5392,7 @@ var imageGenerationArgsSchema = lazySchema20(
|
|
|
5348
5392
|
outputCompression: z22.number().int().min(0).max(100).optional(),
|
|
5349
5393
|
outputFormat: z22.enum(["png", "jpeg", "webp"]).optional(),
|
|
5350
5394
|
partialImages: z22.number().int().min(0).max(3).optional(),
|
|
5351
|
-
quality: z22.enum(["auto", "low", "medium", "high"]).optional(),
|
|
5395
|
+
quality: z22.enum(["auto", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
5352
5396
|
size: z22.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
5353
5397
|
}).strict()
|
|
5354
5398
|
)
|
|
@@ -5378,6 +5422,7 @@ var customArgsSchema = lazySchema21(
|
|
|
5378
5422
|
z23.object({
|
|
5379
5423
|
name: z23.string(),
|
|
5380
5424
|
description: z23.string().optional(),
|
|
5425
|
+
async: z23.boolean().optional(),
|
|
5381
5426
|
format: z23.union([
|
|
5382
5427
|
z23.object({
|
|
5383
5428
|
type: z23.literal("grammar"),
|
|
@@ -5582,7 +5627,8 @@ async function prepareResponsesTools({
|
|
|
5582
5627
|
toolChoice,
|
|
5583
5628
|
allowedTools,
|
|
5584
5629
|
toolNameMapping,
|
|
5585
|
-
customProviderToolNames
|
|
5630
|
+
customProviderToolNames,
|
|
5631
|
+
supportsAsyncToolCalling = true
|
|
5586
5632
|
}) {
|
|
5587
5633
|
var _a2, _b, _c, _d;
|
|
5588
5634
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -5613,7 +5659,13 @@ async function prepareResponsesTools({
|
|
|
5613
5659
|
const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
|
|
5614
5660
|
const openaiFunctionTool = prepareFunctionTool({
|
|
5615
5661
|
tool,
|
|
5616
|
-
options: openaiOptions
|
|
5662
|
+
options: openaiOptions,
|
|
5663
|
+
async: resolveAsyncToolOption({
|
|
5664
|
+
value: openaiOptions == null ? void 0 : openaiOptions.async,
|
|
5665
|
+
supportsAsyncToolCalling,
|
|
5666
|
+
toolName: tool.name,
|
|
5667
|
+
toolWarnings
|
|
5668
|
+
})
|
|
5617
5669
|
});
|
|
5618
5670
|
const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
|
|
5619
5671
|
if (namespace == null) {
|
|
@@ -5795,6 +5847,12 @@ async function prepareResponsesTools({
|
|
|
5795
5847
|
type: "custom",
|
|
5796
5848
|
name: args.name,
|
|
5797
5849
|
description: args.description,
|
|
5850
|
+
...resolveAsyncToolOption({
|
|
5851
|
+
value: args.async,
|
|
5852
|
+
supportsAsyncToolCalling,
|
|
5853
|
+
toolName: args.name,
|
|
5854
|
+
toolWarnings
|
|
5855
|
+
}) != null ? { async: args.async } : {},
|
|
5798
5856
|
format: args.format
|
|
5799
5857
|
});
|
|
5800
5858
|
resolvedCustomProviderToolNames.add(args.name);
|
|
@@ -5966,7 +6024,8 @@ function toAllowedToolResolution(tool) {
|
|
|
5966
6024
|
}
|
|
5967
6025
|
function prepareFunctionTool({
|
|
5968
6026
|
tool,
|
|
5969
|
-
options
|
|
6027
|
+
options,
|
|
6028
|
+
async
|
|
5970
6029
|
}) {
|
|
5971
6030
|
const deferLoading = options == null ? void 0 : options.deferLoading;
|
|
5972
6031
|
return {
|
|
@@ -5974,10 +6033,27 @@ function prepareFunctionTool({
|
|
|
5974
6033
|
name: tool.name,
|
|
5975
6034
|
description: tool.description,
|
|
5976
6035
|
parameters: tool.inputSchema,
|
|
6036
|
+
...async != null ? { async } : {},
|
|
5977
6037
|
...tool.strict != null ? { strict: tool.strict } : {},
|
|
5978
6038
|
...deferLoading != null ? { defer_loading: deferLoading } : {}
|
|
5979
6039
|
};
|
|
5980
6040
|
}
|
|
6041
|
+
function resolveAsyncToolOption({
|
|
6042
|
+
value,
|
|
6043
|
+
supportsAsyncToolCalling,
|
|
6044
|
+
toolName,
|
|
6045
|
+
toolWarnings
|
|
6046
|
+
}) {
|
|
6047
|
+
if (value !== true || supportsAsyncToolCalling) {
|
|
6048
|
+
return value;
|
|
6049
|
+
}
|
|
6050
|
+
toolWarnings.push({
|
|
6051
|
+
type: "unsupported",
|
|
6052
|
+
feature: `async tool calling for "${toolName}"`,
|
|
6053
|
+
details: "Async tool calling is only supported by GPT-6 and later models."
|
|
6054
|
+
});
|
|
6055
|
+
return void 0;
|
|
6056
|
+
}
|
|
5981
6057
|
function mapShellEnvironment(environment) {
|
|
5982
6058
|
if (environment.type === "containerReference") {
|
|
5983
6059
|
const env2 = environment;
|
|
@@ -6069,7 +6145,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6069
6145
|
toolChoice,
|
|
6070
6146
|
responseFormat
|
|
6071
6147
|
}) {
|
|
6072
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
6148
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
6073
6149
|
const warnings = [];
|
|
6074
6150
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
6075
6151
|
if (topK != null) {
|
|
@@ -6101,6 +6177,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6101
6177
|
});
|
|
6102
6178
|
}
|
|
6103
6179
|
const isReasoningModel = (_a2 = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a2 : modelCapabilities.isReasoningModel;
|
|
6180
|
+
let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
|
|
6181
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
6182
|
+
resolvedReasoningEffort
|
|
6183
|
+
)) {
|
|
6184
|
+
warnings.push({
|
|
6185
|
+
type: "unsupported",
|
|
6186
|
+
feature: "reasoningEffort",
|
|
6187
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
6188
|
+
});
|
|
6189
|
+
resolvedReasoningEffort = void 0;
|
|
6190
|
+
}
|
|
6104
6191
|
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
6105
6192
|
warnings.push({
|
|
6106
6193
|
type: "unsupported",
|
|
@@ -6134,7 +6221,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6134
6221
|
toolChoice,
|
|
6135
6222
|
allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
|
|
6136
6223
|
toolNameMapping,
|
|
6137
|
-
customProviderToolNames
|
|
6224
|
+
customProviderToolNames,
|
|
6225
|
+
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
|
|
6138
6226
|
});
|
|
6139
6227
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
6140
6228
|
prompt,
|
|
@@ -6153,6 +6241,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6153
6241
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
6154
6242
|
});
|
|
6155
6243
|
warnings.push(...inputWarnings);
|
|
6244
|
+
const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
|
|
6245
|
+
const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
|
|
6246
|
+
if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
|
|
6247
|
+
warnings.push({
|
|
6248
|
+
type: "unsupported",
|
|
6249
|
+
feature: "reasoningEffortUpdate",
|
|
6250
|
+
details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
|
|
6251
|
+
});
|
|
6252
|
+
} else if (reasoningEffortUpdate != null) {
|
|
6253
|
+
input.unshift({
|
|
6254
|
+
type: "configuration_update",
|
|
6255
|
+
reasoning: { effort: reasoningEffortUpdate }
|
|
6256
|
+
});
|
|
6257
|
+
}
|
|
6156
6258
|
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
6157
6259
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
6158
6260
|
function addInclude(key) {
|
|
@@ -6226,10 +6328,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6226
6328
|
top_logprobs: topLogprobs,
|
|
6227
6329
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
6228
6330
|
// model-specific settings:
|
|
6229
|
-
...isReasoningModel && (
|
|
6331
|
+
...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
|
|
6230
6332
|
reasoning: {
|
|
6231
|
-
...
|
|
6232
|
-
effort:
|
|
6333
|
+
...resolvedReasoningEffort != null && {
|
|
6334
|
+
effort: resolvedReasoningEffort
|
|
6233
6335
|
},
|
|
6234
6336
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
6235
6337
|
summary: openaiOptions.reasoningSummary
|
|
@@ -6243,6 +6345,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6243
6345
|
}
|
|
6244
6346
|
}
|
|
6245
6347
|
};
|
|
6348
|
+
if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
|
|
6349
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
6350
|
+
warnings.push({
|
|
6351
|
+
type: "unsupported",
|
|
6352
|
+
feature: "promptCacheRetention",
|
|
6353
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
6354
|
+
});
|
|
6355
|
+
}
|
|
6246
6356
|
if (isReasoningModel) {
|
|
6247
6357
|
if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
|
|
6248
6358
|
if (baseArgs.temperature != null) {
|
|
@@ -6262,6 +6372,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6262
6372
|
});
|
|
6263
6373
|
}
|
|
6264
6374
|
}
|
|
6375
|
+
if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_i = baseArgs.include) == null ? void 0 : _i.includes("message.output_text.logprobs")))) {
|
|
6376
|
+
baseArgs.top_logprobs = void 0;
|
|
6377
|
+
const filteredInclude = (_j = baseArgs.include) == null ? void 0 : _j.filter(
|
|
6378
|
+
(value) => value !== "message.output_text.logprobs"
|
|
6379
|
+
);
|
|
6380
|
+
baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
|
|
6381
|
+
warnings.push({
|
|
6382
|
+
type: "unsupported",
|
|
6383
|
+
feature: "logprobs",
|
|
6384
|
+
details: "logprobs is not supported for reasoning models"
|
|
6385
|
+
});
|
|
6386
|
+
}
|
|
6265
6387
|
} else {
|
|
6266
6388
|
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
|
|
6267
6389
|
warnings.push({
|
|
@@ -6308,9 +6430,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6308
6430
|
});
|
|
6309
6431
|
delete baseArgs.service_tier;
|
|
6310
6432
|
}
|
|
6311
|
-
const shellToolEnvType = (
|
|
6433
|
+
const shellToolEnvType = (_m = (_l = (_k = tools == null ? void 0 : tools.find(
|
|
6312
6434
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
6313
|
-
)) == null ? void 0 :
|
|
6435
|
+
)) == null ? void 0 : _k.args) == null ? void 0 : _l.environment) == null ? void 0 : _m.type;
|
|
6314
6436
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
6315
6437
|
return {
|
|
6316
6438
|
webSearchToolName,
|
|
@@ -6610,6 +6732,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6610
6732
|
providerMetadata: {
|
|
6611
6733
|
[providerOptionsName]: {
|
|
6612
6734
|
itemId: part.id,
|
|
6735
|
+
...part.async != null && { async: part.async },
|
|
6613
6736
|
...part.namespace != null && { namespace: part.namespace }
|
|
6614
6737
|
}
|
|
6615
6738
|
}
|
|
@@ -6626,7 +6749,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6626
6749
|
input: JSON.stringify(part.input),
|
|
6627
6750
|
providerMetadata: {
|
|
6628
6751
|
[providerOptionsName]: {
|
|
6629
|
-
itemId: part.id
|
|
6752
|
+
itemId: part.id,
|
|
6753
|
+
...part.async != null && { async: part.async }
|
|
6630
6754
|
}
|
|
6631
6755
|
}
|
|
6632
6756
|
});
|
|
@@ -6914,7 +7038,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6914
7038
|
toolName: value.item.name,
|
|
6915
7039
|
toolCallId: value.item.call_id,
|
|
6916
7040
|
suppressInputStreaming,
|
|
6917
|
-
bufferedInputDeltas: suppressInputStreaming ? [] : void 0
|
|
7041
|
+
bufferedInputDeltas: suppressInputStreaming ? [] : void 0,
|
|
7042
|
+
async: value.item.async
|
|
6918
7043
|
};
|
|
6919
7044
|
if (!suppressInputStreaming) {
|
|
6920
7045
|
controller.enqueue({
|
|
@@ -6929,7 +7054,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6929
7054
|
);
|
|
6930
7055
|
ongoingToolCalls[value.output_index] = {
|
|
6931
7056
|
toolName,
|
|
6932
|
-
toolCallId: value.item.call_id
|
|
7057
|
+
toolCallId: value.item.call_id,
|
|
7058
|
+
async: value.item.async
|
|
6933
7059
|
};
|
|
6934
7060
|
controller.enqueue({
|
|
6935
7061
|
type: "tool-input-start",
|
|
@@ -7173,6 +7299,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7173
7299
|
providerMetadata: {
|
|
7174
7300
|
[providerOptionsName]: {
|
|
7175
7301
|
itemId: item.id,
|
|
7302
|
+
...item.async != null ? { async: item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {},
|
|
7176
7303
|
...item.namespace != null && {
|
|
7177
7304
|
namespace: item.namespace
|
|
7178
7305
|
}
|
|
@@ -7217,6 +7344,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7217
7344
|
}
|
|
7218
7345
|
});
|
|
7219
7346
|
} else if (value.item.type === "custom_tool_call") {
|
|
7347
|
+
const ongoingToolCall = ongoingToolCalls[value.output_index];
|
|
7220
7348
|
ongoingToolCalls[value.output_index] = void 0;
|
|
7221
7349
|
hasFunctionCall = true;
|
|
7222
7350
|
const toolName = toolNameMapping.toCustomToolName(
|
|
@@ -7233,7 +7361,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7233
7361
|
input: JSON.stringify(value.item.input),
|
|
7234
7362
|
providerMetadata: {
|
|
7235
7363
|
[providerOptionsName]: {
|
|
7236
|
-
itemId: value.item.id
|
|
7364
|
+
itemId: value.item.id,
|
|
7365
|
+
...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
|
|
7237
7366
|
}
|
|
7238
7367
|
}
|
|
7239
7368
|
});
|