@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.mjs
CHANGED
|
@@ -45,14 +45,18 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
45
45
|
const gptVersion = getGptVersion(modelId);
|
|
46
46
|
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);
|
|
47
47
|
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
48
|
+
const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
|
|
48
49
|
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
49
50
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
50
51
|
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
51
|
-
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
52
|
+
const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
52
53
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
53
54
|
return {
|
|
54
55
|
supportsFlexProcessing,
|
|
55
56
|
supportsPriorityProcessing,
|
|
57
|
+
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
58
|
+
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
59
|
+
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
56
60
|
isReasoningModel,
|
|
57
61
|
systemMessageMode,
|
|
58
62
|
supportsNonReasoningParameters
|
|
@@ -734,6 +738,7 @@ var openaiLanguageModelChatOptions = lazySchema2(
|
|
|
734
738
|
user: z3.string().optional(),
|
|
735
739
|
/**
|
|
736
740
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
741
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
737
742
|
*/
|
|
738
743
|
reasoningEffort: z3.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
739
744
|
/**
|
|
@@ -932,6 +937,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
932
937
|
})) != null ? _a2 : {};
|
|
933
938
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
934
939
|
const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
|
|
940
|
+
let resolvedReasoningEffort = openaiOptions.reasoningEffort;
|
|
941
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
942
|
+
resolvedReasoningEffort
|
|
943
|
+
)) {
|
|
944
|
+
warnings.push({
|
|
945
|
+
type: "unsupported",
|
|
946
|
+
feature: "reasoningEffort",
|
|
947
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
948
|
+
});
|
|
949
|
+
resolvedReasoningEffort = void 0;
|
|
950
|
+
}
|
|
935
951
|
if (topK != null) {
|
|
936
952
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
937
953
|
}
|
|
@@ -976,7 +992,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
976
992
|
store: openaiOptions.store,
|
|
977
993
|
metadata: openaiOptions.metadata,
|
|
978
994
|
prediction: openaiOptions.prediction,
|
|
979
|
-
reasoning_effort:
|
|
995
|
+
reasoning_effort: resolvedReasoningEffort,
|
|
980
996
|
service_tier: openaiOptions.serviceTier,
|
|
981
997
|
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
982
998
|
prompt_cache_options: openaiOptions.promptCacheOptions,
|
|
@@ -985,6 +1001,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
985
1001
|
// messages:
|
|
986
1002
|
messages
|
|
987
1003
|
};
|
|
1004
|
+
if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
|
|
1005
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
1006
|
+
warnings.push({
|
|
1007
|
+
type: "unsupported",
|
|
1008
|
+
feature: "promptCacheRetention",
|
|
1009
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
988
1012
|
if (isReasoningModel) {
|
|
989
1013
|
if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
|
|
990
1014
|
if (baseArgs.temperature != null) {
|
|
@@ -2083,9 +2107,10 @@ var baseImageModelOptionsObject = z9.object({
|
|
|
2083
2107
|
/**
|
|
2084
2108
|
* Quality of the generated image(s).
|
|
2085
2109
|
*
|
|
2086
|
-
* Valid values: `standard`, `hd`, `low`, `medium`, `high`, `auto`.
|
|
2110
|
+
* Valid values: `standard`, `hd`, `low`, `medium`, `high`, `xhigh`, `max`, `auto`.
|
|
2111
|
+
* `xhigh` and `max` are supported by GPT Image 2.5 models.
|
|
2087
2112
|
*/
|
|
2088
|
-
quality: z9.enum(["standard", "hd", "low", "medium", "high", "auto"]).optional(),
|
|
2113
|
+
quality: z9.enum(["standard", "hd", "low", "medium", "high", "xhigh", "max", "auto"]).optional(),
|
|
2089
2114
|
/**
|
|
2090
2115
|
* Background behavior for the generated image(s).
|
|
2091
2116
|
*
|
|
@@ -2458,6 +2483,7 @@ var customArgsSchema = lazySchema11(
|
|
|
2458
2483
|
z12.object({
|
|
2459
2484
|
name: z12.string(),
|
|
2460
2485
|
description: z12.string().optional(),
|
|
2486
|
+
async: z12.boolean().optional(),
|
|
2461
2487
|
format: z12.union([
|
|
2462
2488
|
z12.object({
|
|
2463
2489
|
type: z12.literal("grammar"),
|
|
@@ -2552,7 +2578,7 @@ var imageGenerationArgsSchema = lazySchema13(
|
|
|
2552
2578
|
outputCompression: z14.number().int().min(0).max(100).optional(),
|
|
2553
2579
|
outputFormat: z14.enum(["png", "jpeg", "webp"]).optional(),
|
|
2554
2580
|
partialImages: z14.number().int().min(0).max(3).optional(),
|
|
2555
|
-
quality: z14.enum(["auto", "low", "medium", "high"]).optional(),
|
|
2581
|
+
quality: z14.enum(["auto", "low", "medium", "high", "xhigh", "max"]).optional(),
|
|
2556
2582
|
size: z14.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
2557
2583
|
}).strict()
|
|
2558
2584
|
)
|
|
@@ -2936,6 +2962,7 @@ var openaiTools = {
|
|
|
2936
2962
|
*
|
|
2937
2963
|
* @param name - The name of the custom tool.
|
|
2938
2964
|
* @param description - An optional description of the tool.
|
|
2965
|
+
* @param async - Whether the model can continue without waiting for the tool result.
|
|
2939
2966
|
* @param format - The output format constraint (grammar type, syntax, and definition).
|
|
2940
2967
|
*/
|
|
2941
2968
|
customTool,
|
|
@@ -2971,7 +2998,7 @@ var openaiTools = {
|
|
|
2971
2998
|
* @param outputCompression - Compression level for the output image (0-100).
|
|
2972
2999
|
* @param outputFormat - The output format of the generated image. One of 'png', 'jpeg', or 'webp'.
|
|
2973
3000
|
* @param partialImages - Number of partial images to generate in streaming mode (0-3).
|
|
2974
|
-
* @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', or '
|
|
3001
|
+
* @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.
|
|
2975
3002
|
* @param size - The size of the generated image. One of 'auto', '1024x1024', '1024x1536', or '1536x1024'.
|
|
2976
3003
|
*/
|
|
2977
3004
|
imageGeneration,
|
|
@@ -3371,7 +3398,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3371
3398
|
toolSearchToolName,
|
|
3372
3399
|
customProviderToolNames
|
|
3373
3400
|
}) {
|
|
3374
|
-
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;
|
|
3401
|
+
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;
|
|
3375
3402
|
let input = [];
|
|
3376
3403
|
const warnings = [];
|
|
3377
3404
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -3556,6 +3583,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3556
3583
|
}
|
|
3557
3584
|
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;
|
|
3558
3585
|
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;
|
|
3586
|
+
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;
|
|
3559
3587
|
if (hasConversation && id != null) {
|
|
3560
3588
|
break;
|
|
3561
3589
|
}
|
|
@@ -3579,7 +3607,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3579
3607
|
type: "tool_search_call",
|
|
3580
3608
|
id: id != null ? id : part.toolCallId,
|
|
3581
3609
|
execution,
|
|
3582
|
-
call_id: (
|
|
3610
|
+
call_id: (_q = parsedInput.call_id) != null ? _q : null,
|
|
3583
3611
|
status: "completed",
|
|
3584
3612
|
arguments: parsedInput.arguments
|
|
3585
3613
|
});
|
|
@@ -3593,7 +3621,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3593
3621
|
break;
|
|
3594
3622
|
}
|
|
3595
3623
|
}
|
|
3596
|
-
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((
|
|
3624
|
+
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_r = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _r : false);
|
|
3597
3625
|
if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
|
|
3598
3626
|
break;
|
|
3599
3627
|
}
|
|
@@ -3659,6 +3687,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3659
3687
|
call_id: part.toolCallId,
|
|
3660
3688
|
name: resolvedToolName,
|
|
3661
3689
|
input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
|
|
3690
|
+
...isAsync != null && { async: isAsync },
|
|
3662
3691
|
id
|
|
3663
3692
|
});
|
|
3664
3693
|
break;
|
|
@@ -3668,6 +3697,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3668
3697
|
call_id: part.toolCallId,
|
|
3669
3698
|
name: resolvedToolName,
|
|
3670
3699
|
arguments: serializeToolCallArguments2(part.input),
|
|
3700
|
+
...isAsync != null && { async: isAsync },
|
|
3671
3701
|
...namespace != null && { namespace }
|
|
3672
3702
|
});
|
|
3673
3703
|
break;
|
|
@@ -3684,7 +3714,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3684
3714
|
part.toolName
|
|
3685
3715
|
);
|
|
3686
3716
|
if (part.toolName === toolSearchToolName) {
|
|
3687
|
-
const itemId = (
|
|
3717
|
+
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;
|
|
3688
3718
|
if (store) {
|
|
3689
3719
|
input.push({ type: "item_reference", id: itemId });
|
|
3690
3720
|
} else if (part.output.type === "json") {
|
|
@@ -3725,7 +3755,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3725
3755
|
break;
|
|
3726
3756
|
}
|
|
3727
3757
|
if (store) {
|
|
3728
|
-
const itemId = (
|
|
3758
|
+
const itemId = (_A = (_z = (_y = part.providerOptions) == null ? void 0 : _y[providerOptionsName]) == null ? void 0 : _z.itemId) != null ? _A : part.toolCallId;
|
|
3729
3759
|
input.push({ type: "item_reference", id: itemId });
|
|
3730
3760
|
} else {
|
|
3731
3761
|
warnings.push({
|
|
@@ -3892,7 +3922,7 @@ ${text}`,
|
|
|
3892
3922
|
}
|
|
3893
3923
|
const output = part.output;
|
|
3894
3924
|
if (output.type === "execution-denied") {
|
|
3895
|
-
const approvalId = (
|
|
3925
|
+
const approvalId = (_C = (_B = output.providerOptions) == null ? void 0 : _B.openai) == null ? void 0 : _C.approvalId;
|
|
3896
3926
|
if (approvalId) {
|
|
3897
3927
|
continue;
|
|
3898
3928
|
}
|
|
@@ -3979,7 +4009,7 @@ ${text}`,
|
|
|
3979
4009
|
break;
|
|
3980
4010
|
case "execution-denied":
|
|
3981
4011
|
outputValue = convertScalarOutput(
|
|
3982
|
-
(
|
|
4012
|
+
(_D = output.reason) != null ? _D : "Tool call execution denied."
|
|
3983
4013
|
);
|
|
3984
4014
|
break;
|
|
3985
4015
|
case "json":
|
|
@@ -4320,6 +4350,7 @@ var openaiResponsesChunkSchema = lazySchema20(
|
|
|
4320
4350
|
call_id: z22.string(),
|
|
4321
4351
|
name: z22.string(),
|
|
4322
4352
|
arguments: z22.string(),
|
|
4353
|
+
async: z22.boolean().nullish(),
|
|
4323
4354
|
namespace: z22.string().nullish()
|
|
4324
4355
|
}),
|
|
4325
4356
|
z22.object({
|
|
@@ -4395,7 +4426,8 @@ var openaiResponsesChunkSchema = lazySchema20(
|
|
|
4395
4426
|
id: z22.string(),
|
|
4396
4427
|
call_id: z22.string(),
|
|
4397
4428
|
name: z22.string(),
|
|
4398
|
-
input: z22.string()
|
|
4429
|
+
input: z22.string(),
|
|
4430
|
+
async: z22.boolean().nullish()
|
|
4399
4431
|
}),
|
|
4400
4432
|
z22.object({
|
|
4401
4433
|
type: z22.literal("shell_call"),
|
|
@@ -4463,6 +4495,7 @@ var openaiResponsesChunkSchema = lazySchema20(
|
|
|
4463
4495
|
call_id: z22.string(),
|
|
4464
4496
|
name: z22.string(),
|
|
4465
4497
|
arguments: z22.string(),
|
|
4498
|
+
async: z22.boolean().nullish(),
|
|
4466
4499
|
status: z22.literal("completed"),
|
|
4467
4500
|
namespace: z22.string().nullish()
|
|
4468
4501
|
}),
|
|
@@ -4472,6 +4505,7 @@ var openaiResponsesChunkSchema = lazySchema20(
|
|
|
4472
4505
|
call_id: z22.string(),
|
|
4473
4506
|
name: z22.string(),
|
|
4474
4507
|
input: z22.string(),
|
|
4508
|
+
async: z22.boolean().nullish(),
|
|
4475
4509
|
status: z22.literal("completed")
|
|
4476
4510
|
}),
|
|
4477
4511
|
z22.object({
|
|
@@ -4905,6 +4939,7 @@ var openaiResponsesResponseSchema = lazySchema20(
|
|
|
4905
4939
|
name: z22.string(),
|
|
4906
4940
|
arguments: z22.string(),
|
|
4907
4941
|
id: z22.string(),
|
|
4942
|
+
async: z22.boolean().nullish(),
|
|
4908
4943
|
namespace: z22.string().nullish()
|
|
4909
4944
|
}),
|
|
4910
4945
|
z22.object({
|
|
@@ -4912,7 +4947,8 @@ var openaiResponsesResponseSchema = lazySchema20(
|
|
|
4912
4947
|
call_id: z22.string(),
|
|
4913
4948
|
name: z22.string(),
|
|
4914
4949
|
input: z22.string(),
|
|
4915
|
-
id: z22.string()
|
|
4950
|
+
id: z22.string(),
|
|
4951
|
+
async: z22.boolean().nullish()
|
|
4916
4952
|
}),
|
|
4917
4953
|
z22.object({
|
|
4918
4954
|
type: z22.literal("computer_call"),
|
|
@@ -5224,9 +5260,19 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema21(
|
|
|
5224
5260
|
* Reasoning effort for reasoning models. Defaults to `medium`. If you use
|
|
5225
5261
|
* `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
5226
5262
|
* GPT-5.6 supports 'none' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5263
|
+
* GPT-6 and later models support 'low' | 'medium' | 'high' | 'xhigh' | 'max'.
|
|
5227
5264
|
* Supported values vary by model.
|
|
5228
5265
|
*/
|
|
5229
5266
|
reasoningEffort: z23.string().nullish(),
|
|
5267
|
+
/**
|
|
5268
|
+
* Updates the reasoning effort for GPT-6 and later models starting with this response
|
|
5269
|
+
* without changing the request-level reasoning effort. This preserves the
|
|
5270
|
+
* request prefix for prompt caching.
|
|
5271
|
+
*
|
|
5272
|
+
* Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
|
|
5273
|
+
* combined with automatic truncation.
|
|
5274
|
+
*/
|
|
5275
|
+
reasoningEffortUpdate: z23.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
5230
5276
|
/**
|
|
5231
5277
|
* Controls how much model work GPT-5.6 performs before returning a final answer.
|
|
5232
5278
|
* `standard` is the default. `pro` increases quality, latency, and token usage.
|
|
@@ -5339,7 +5385,8 @@ async function prepareResponsesTools({
|
|
|
5339
5385
|
toolChoice,
|
|
5340
5386
|
allowedTools,
|
|
5341
5387
|
toolNameMapping,
|
|
5342
|
-
customProviderToolNames
|
|
5388
|
+
customProviderToolNames,
|
|
5389
|
+
supportsAsyncToolCalling = true
|
|
5343
5390
|
}) {
|
|
5344
5391
|
var _a2, _b, _c, _d;
|
|
5345
5392
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -5370,7 +5417,13 @@ async function prepareResponsesTools({
|
|
|
5370
5417
|
const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
|
|
5371
5418
|
const openaiFunctionTool = prepareFunctionTool({
|
|
5372
5419
|
tool,
|
|
5373
|
-
options: openaiOptions
|
|
5420
|
+
options: openaiOptions,
|
|
5421
|
+
async: resolveAsyncToolOption({
|
|
5422
|
+
value: openaiOptions == null ? void 0 : openaiOptions.async,
|
|
5423
|
+
supportsAsyncToolCalling,
|
|
5424
|
+
toolName: tool.name,
|
|
5425
|
+
toolWarnings
|
|
5426
|
+
})
|
|
5374
5427
|
});
|
|
5375
5428
|
const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
|
|
5376
5429
|
if (namespace == null) {
|
|
@@ -5552,6 +5605,12 @@ async function prepareResponsesTools({
|
|
|
5552
5605
|
type: "custom",
|
|
5553
5606
|
name: args.name,
|
|
5554
5607
|
description: args.description,
|
|
5608
|
+
...resolveAsyncToolOption({
|
|
5609
|
+
value: args.async,
|
|
5610
|
+
supportsAsyncToolCalling,
|
|
5611
|
+
toolName: args.name,
|
|
5612
|
+
toolWarnings
|
|
5613
|
+
}) != null ? { async: args.async } : {},
|
|
5555
5614
|
format: args.format
|
|
5556
5615
|
});
|
|
5557
5616
|
resolvedCustomProviderToolNames.add(args.name);
|
|
@@ -5723,7 +5782,8 @@ function toAllowedToolResolution(tool) {
|
|
|
5723
5782
|
}
|
|
5724
5783
|
function prepareFunctionTool({
|
|
5725
5784
|
tool,
|
|
5726
|
-
options
|
|
5785
|
+
options,
|
|
5786
|
+
async
|
|
5727
5787
|
}) {
|
|
5728
5788
|
const deferLoading = options == null ? void 0 : options.deferLoading;
|
|
5729
5789
|
return {
|
|
@@ -5731,10 +5791,27 @@ function prepareFunctionTool({
|
|
|
5731
5791
|
name: tool.name,
|
|
5732
5792
|
description: tool.description,
|
|
5733
5793
|
parameters: tool.inputSchema,
|
|
5794
|
+
...async != null ? { async } : {},
|
|
5734
5795
|
...tool.strict != null ? { strict: tool.strict } : {},
|
|
5735
5796
|
...deferLoading != null ? { defer_loading: deferLoading } : {}
|
|
5736
5797
|
};
|
|
5737
5798
|
}
|
|
5799
|
+
function resolveAsyncToolOption({
|
|
5800
|
+
value,
|
|
5801
|
+
supportsAsyncToolCalling,
|
|
5802
|
+
toolName,
|
|
5803
|
+
toolWarnings
|
|
5804
|
+
}) {
|
|
5805
|
+
if (value !== true || supportsAsyncToolCalling) {
|
|
5806
|
+
return value;
|
|
5807
|
+
}
|
|
5808
|
+
toolWarnings.push({
|
|
5809
|
+
type: "unsupported",
|
|
5810
|
+
feature: `async tool calling for "${toolName}"`,
|
|
5811
|
+
details: "Async tool calling is only supported by GPT-6 and later models."
|
|
5812
|
+
});
|
|
5813
|
+
return void 0;
|
|
5814
|
+
}
|
|
5738
5815
|
function mapShellEnvironment(environment) {
|
|
5739
5816
|
if (environment.type === "containerReference") {
|
|
5740
5817
|
const env2 = environment;
|
|
@@ -5826,7 +5903,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5826
5903
|
toolChoice,
|
|
5827
5904
|
responseFormat
|
|
5828
5905
|
}) {
|
|
5829
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5906
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
5830
5907
|
const warnings = [];
|
|
5831
5908
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
5832
5909
|
if (topK != null) {
|
|
@@ -5858,6 +5935,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5858
5935
|
});
|
|
5859
5936
|
}
|
|
5860
5937
|
const isReasoningModel = (_a2 = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a2 : modelCapabilities.isReasoningModel;
|
|
5938
|
+
let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
|
|
5939
|
+
if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
|
|
5940
|
+
resolvedReasoningEffort
|
|
5941
|
+
)) {
|
|
5942
|
+
warnings.push({
|
|
5943
|
+
type: "unsupported",
|
|
5944
|
+
feature: "reasoningEffort",
|
|
5945
|
+
details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
5946
|
+
});
|
|
5947
|
+
resolvedReasoningEffort = void 0;
|
|
5948
|
+
}
|
|
5861
5949
|
if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
|
|
5862
5950
|
warnings.push({
|
|
5863
5951
|
type: "unsupported",
|
|
@@ -5891,7 +5979,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5891
5979
|
toolChoice,
|
|
5892
5980
|
allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
|
|
5893
5981
|
toolNameMapping,
|
|
5894
|
-
customProviderToolNames
|
|
5982
|
+
customProviderToolNames,
|
|
5983
|
+
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
|
|
5895
5984
|
});
|
|
5896
5985
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
5897
5986
|
prompt,
|
|
@@ -5910,6 +5999,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5910
5999
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
5911
6000
|
});
|
|
5912
6001
|
warnings.push(...inputWarnings);
|
|
6002
|
+
const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
|
|
6003
|
+
const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
|
|
6004
|
+
if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
|
|
6005
|
+
warnings.push({
|
|
6006
|
+
type: "unsupported",
|
|
6007
|
+
feature: "reasoningEffortUpdate",
|
|
6008
|
+
details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic truncation"
|
|
6009
|
+
});
|
|
6010
|
+
} else if (reasoningEffortUpdate != null) {
|
|
6011
|
+
input.unshift({
|
|
6012
|
+
type: "configuration_update",
|
|
6013
|
+
reasoning: { effort: reasoningEffortUpdate }
|
|
6014
|
+
});
|
|
6015
|
+
}
|
|
5913
6016
|
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
5914
6017
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
5915
6018
|
function addInclude(key) {
|
|
@@ -5983,10 +6086,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5983
6086
|
top_logprobs: topLogprobs,
|
|
5984
6087
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
5985
6088
|
// model-specific settings:
|
|
5986
|
-
...isReasoningModel && (
|
|
6089
|
+
...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningContext) != null) && {
|
|
5987
6090
|
reasoning: {
|
|
5988
|
-
...
|
|
5989
|
-
effort:
|
|
6091
|
+
...resolvedReasoningEffort != null && {
|
|
6092
|
+
effort: resolvedReasoningEffort
|
|
5990
6093
|
},
|
|
5991
6094
|
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
5992
6095
|
summary: openaiOptions.reasoningSummary
|
|
@@ -6000,6 +6103,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6000
6103
|
}
|
|
6001
6104
|
}
|
|
6002
6105
|
};
|
|
6106
|
+
if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
|
|
6107
|
+
baseArgs.prompt_cache_retention = void 0;
|
|
6108
|
+
warnings.push({
|
|
6109
|
+
type: "unsupported",
|
|
6110
|
+
feature: "promptCacheRetention",
|
|
6111
|
+
details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
|
|
6112
|
+
});
|
|
6113
|
+
}
|
|
6003
6114
|
if (isReasoningModel) {
|
|
6004
6115
|
if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
|
|
6005
6116
|
if (baseArgs.temperature != null) {
|
|
@@ -6019,6 +6130,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6019
6130
|
});
|
|
6020
6131
|
}
|
|
6021
6132
|
}
|
|
6133
|
+
if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_i = baseArgs.include) == null ? void 0 : _i.includes("message.output_text.logprobs")))) {
|
|
6134
|
+
baseArgs.top_logprobs = void 0;
|
|
6135
|
+
const filteredInclude = (_j = baseArgs.include) == null ? void 0 : _j.filter(
|
|
6136
|
+
(value) => value !== "message.output_text.logprobs"
|
|
6137
|
+
);
|
|
6138
|
+
baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
|
|
6139
|
+
warnings.push({
|
|
6140
|
+
type: "unsupported",
|
|
6141
|
+
feature: "logprobs",
|
|
6142
|
+
details: "logprobs is not supported for reasoning models"
|
|
6143
|
+
});
|
|
6144
|
+
}
|
|
6022
6145
|
} else {
|
|
6023
6146
|
if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
|
|
6024
6147
|
warnings.push({
|
|
@@ -6065,9 +6188,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6065
6188
|
});
|
|
6066
6189
|
delete baseArgs.service_tier;
|
|
6067
6190
|
}
|
|
6068
|
-
const shellToolEnvType = (
|
|
6191
|
+
const shellToolEnvType = (_m = (_l = (_k = tools == null ? void 0 : tools.find(
|
|
6069
6192
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
6070
|
-
)) == null ? void 0 :
|
|
6193
|
+
)) == null ? void 0 : _k.args) == null ? void 0 : _l.environment) == null ? void 0 : _m.type;
|
|
6071
6194
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
6072
6195
|
return {
|
|
6073
6196
|
webSearchToolName,
|
|
@@ -6367,6 +6490,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6367
6490
|
providerMetadata: {
|
|
6368
6491
|
[providerOptionsName]: {
|
|
6369
6492
|
itemId: part.id,
|
|
6493
|
+
...part.async != null && { async: part.async },
|
|
6370
6494
|
...part.namespace != null && { namespace: part.namespace }
|
|
6371
6495
|
}
|
|
6372
6496
|
}
|
|
@@ -6383,7 +6507,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6383
6507
|
input: JSON.stringify(part.input),
|
|
6384
6508
|
providerMetadata: {
|
|
6385
6509
|
[providerOptionsName]: {
|
|
6386
|
-
itemId: part.id
|
|
6510
|
+
itemId: part.id,
|
|
6511
|
+
...part.async != null && { async: part.async }
|
|
6387
6512
|
}
|
|
6388
6513
|
}
|
|
6389
6514
|
});
|
|
@@ -6671,7 +6796,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6671
6796
|
toolName: value.item.name,
|
|
6672
6797
|
toolCallId: value.item.call_id,
|
|
6673
6798
|
suppressInputStreaming,
|
|
6674
|
-
bufferedInputDeltas: suppressInputStreaming ? [] : void 0
|
|
6799
|
+
bufferedInputDeltas: suppressInputStreaming ? [] : void 0,
|
|
6800
|
+
async: value.item.async
|
|
6675
6801
|
};
|
|
6676
6802
|
if (!suppressInputStreaming) {
|
|
6677
6803
|
controller.enqueue({
|
|
@@ -6686,7 +6812,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6686
6812
|
);
|
|
6687
6813
|
ongoingToolCalls[value.output_index] = {
|
|
6688
6814
|
toolName,
|
|
6689
|
-
toolCallId: value.item.call_id
|
|
6815
|
+
toolCallId: value.item.call_id,
|
|
6816
|
+
async: value.item.async
|
|
6690
6817
|
};
|
|
6691
6818
|
controller.enqueue({
|
|
6692
6819
|
type: "tool-input-start",
|
|
@@ -6930,6 +7057,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6930
7057
|
providerMetadata: {
|
|
6931
7058
|
[providerOptionsName]: {
|
|
6932
7059
|
itemId: item.id,
|
|
7060
|
+
...item.async != null ? { async: item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {},
|
|
6933
7061
|
...item.namespace != null && {
|
|
6934
7062
|
namespace: item.namespace
|
|
6935
7063
|
}
|
|
@@ -6974,6 +7102,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6974
7102
|
}
|
|
6975
7103
|
});
|
|
6976
7104
|
} else if (value.item.type === "custom_tool_call") {
|
|
7105
|
+
const ongoingToolCall = ongoingToolCalls[value.output_index];
|
|
6977
7106
|
ongoingToolCalls[value.output_index] = void 0;
|
|
6978
7107
|
hasFunctionCall = true;
|
|
6979
7108
|
const toolName = toolNameMapping.toCustomToolName(
|
|
@@ -6990,7 +7119,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6990
7119
|
input: JSON.stringify(value.item.input),
|
|
6991
7120
|
providerMetadata: {
|
|
6992
7121
|
[providerOptionsName]: {
|
|
6993
|
-
itemId: value.item.id
|
|
7122
|
+
itemId: value.item.id,
|
|
7123
|
+
...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
|
|
6994
7124
|
}
|
|
6995
7125
|
}
|
|
6996
7126
|
});
|
|
@@ -8086,7 +8216,7 @@ var OpenAITranscriptionModel = class {
|
|
|
8086
8216
|
};
|
|
8087
8217
|
|
|
8088
8218
|
// src/version.ts
|
|
8089
|
-
var VERSION = true ? "3.0.
|
|
8219
|
+
var VERSION = true ? "3.0.110" : "0.0.0-test";
|
|
8090
8220
|
|
|
8091
8221
|
// src/openai-provider.ts
|
|
8092
8222
|
function createOpenAI(options = {}) {
|