@ai-sdk/openai 3.0.60 → 3.0.62
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 +12 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +58 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -21
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +57 -20
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +57 -20
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/responses/convert-to-openai-responses-input.ts +12 -0
- package/src/responses/openai-responses-language-model.ts +1 -0
- package/src/responses/openai-responses-options.ts +17 -0
- package/src/responses/openai-responses-prepare-tools.ts +26 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -3197,24 +3197,26 @@ async function convertToOpenAIResponsesInput({
|
|
|
3197
3197
|
break;
|
|
3198
3198
|
case "content":
|
|
3199
3199
|
outputValue = output.value.map((item) => {
|
|
3200
|
-
var _a2;
|
|
3200
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
3201
3201
|
switch (item.type) {
|
|
3202
3202
|
case "text":
|
|
3203
3203
|
return { type: "input_text", text: item.text };
|
|
3204
3204
|
case "image-data":
|
|
3205
3205
|
return {
|
|
3206
3206
|
type: "input_image",
|
|
3207
|
-
image_url: `data:${item.mediaType};base64,${item.data}
|
|
3207
|
+
image_url: `data:${item.mediaType};base64,${item.data}`,
|
|
3208
|
+
detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
3208
3209
|
};
|
|
3209
3210
|
case "image-url":
|
|
3210
3211
|
return {
|
|
3211
3212
|
type: "input_image",
|
|
3212
|
-
image_url: item.url
|
|
3213
|
+
image_url: item.url,
|
|
3214
|
+
detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
|
|
3213
3215
|
};
|
|
3214
3216
|
case "file-data":
|
|
3215
3217
|
return {
|
|
3216
3218
|
type: "input_file",
|
|
3217
|
-
filename: (
|
|
3219
|
+
filename: (_e2 = item.filename) != null ? _e2 : "data",
|
|
3218
3220
|
file_data: `data:${item.mediaType};base64,${item.data}`
|
|
3219
3221
|
};
|
|
3220
3222
|
case "file-url":
|
|
@@ -3256,7 +3258,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3256
3258
|
break;
|
|
3257
3259
|
case "content":
|
|
3258
3260
|
contentValue = output.value.map((item) => {
|
|
3259
|
-
var _a2;
|
|
3261
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
3260
3262
|
switch (item.type) {
|
|
3261
3263
|
case "text": {
|
|
3262
3264
|
return { type: "input_text", text: item.text };
|
|
@@ -3264,19 +3266,21 @@ async function convertToOpenAIResponsesInput({
|
|
|
3264
3266
|
case "image-data": {
|
|
3265
3267
|
return {
|
|
3266
3268
|
type: "input_image",
|
|
3267
|
-
image_url: `data:${item.mediaType};base64,${item.data}
|
|
3269
|
+
image_url: `data:${item.mediaType};base64,${item.data}`,
|
|
3270
|
+
detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
3268
3271
|
};
|
|
3269
3272
|
}
|
|
3270
3273
|
case "image-url": {
|
|
3271
3274
|
return {
|
|
3272
3275
|
type: "input_image",
|
|
3273
|
-
image_url: item.url
|
|
3276
|
+
image_url: item.url,
|
|
3277
|
+
detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
|
|
3274
3278
|
};
|
|
3275
3279
|
}
|
|
3276
3280
|
case "file-data": {
|
|
3277
3281
|
return {
|
|
3278
3282
|
type: "input_file",
|
|
3279
|
-
filename: (
|
|
3283
|
+
filename: (_e2 = item.filename) != null ? _e2 : "data",
|
|
3280
3284
|
file_data: `data:${item.mediaType};base64,${item.data}`
|
|
3281
3285
|
};
|
|
3282
3286
|
}
|
|
@@ -4420,7 +4424,21 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
|
|
|
4420
4424
|
* When enabled, the SDK applies reasoning-model parameter compatibility rules
|
|
4421
4425
|
* and defaults `systemMessageMode` to `developer` unless overridden.
|
|
4422
4426
|
*/
|
|
4423
|
-
forceReasoning: z19.boolean().optional()
|
|
4427
|
+
forceReasoning: z19.boolean().optional(),
|
|
4428
|
+
/**
|
|
4429
|
+
* Restrict the callable tools to a subset while keeping the full tools
|
|
4430
|
+
* list intact, so prompt caching is preserved across requests with
|
|
4431
|
+
* different allowlists.
|
|
4432
|
+
*
|
|
4433
|
+
* When set, this overrides the request-level `toolChoice` and emits
|
|
4434
|
+
* `tool_choice: { type: "allowed_tools", mode, tools }` on the wire.
|
|
4435
|
+
*
|
|
4436
|
+
* @see https://developers.openai.com/api/reference/resources/responses/methods/create#(resource)%20responses%20%3E%20(model)%20tool_choice_allowed%20%3E%20(schema)
|
|
4437
|
+
*/
|
|
4438
|
+
allowedTools: z19.object({
|
|
4439
|
+
toolNames: z19.array(z19.string()).min(1),
|
|
4440
|
+
mode: z19.enum(["auto", "required"]).optional()
|
|
4441
|
+
}).optional()
|
|
4424
4442
|
})
|
|
4425
4443
|
)
|
|
4426
4444
|
);
|
|
@@ -4780,10 +4798,11 @@ var webSearchPreview = createProviderToolFactoryWithOutputSchema10({
|
|
|
4780
4798
|
async function prepareResponsesTools({
|
|
4781
4799
|
tools,
|
|
4782
4800
|
toolChoice,
|
|
4801
|
+
allowedTools,
|
|
4783
4802
|
toolNameMapping,
|
|
4784
4803
|
customProviderToolNames
|
|
4785
4804
|
}) {
|
|
4786
|
-
var _a, _b;
|
|
4805
|
+
var _a, _b, _c;
|
|
4787
4806
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
4788
4807
|
const toolWarnings = [];
|
|
4789
4808
|
if (tools == null) {
|
|
@@ -4974,6 +4993,23 @@ async function prepareResponsesTools({
|
|
|
4974
4993
|
break;
|
|
4975
4994
|
}
|
|
4976
4995
|
}
|
|
4996
|
+
if (allowedTools != null) {
|
|
4997
|
+
return {
|
|
4998
|
+
tools: openaiTools,
|
|
4999
|
+
toolChoice: {
|
|
5000
|
+
type: "allowed_tools",
|
|
5001
|
+
mode: (_b = allowedTools.mode) != null ? _b : "auto",
|
|
5002
|
+
tools: allowedTools.toolNames.map((name) => {
|
|
5003
|
+
var _a2;
|
|
5004
|
+
return {
|
|
5005
|
+
type: "function",
|
|
5006
|
+
name: (_a2 = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(name)) != null ? _a2 : name
|
|
5007
|
+
};
|
|
5008
|
+
})
|
|
5009
|
+
},
|
|
5010
|
+
toolWarnings
|
|
5011
|
+
};
|
|
5012
|
+
}
|
|
4977
5013
|
if (toolChoice == null) {
|
|
4978
5014
|
return { tools: openaiTools, toolChoice: void 0, toolWarnings };
|
|
4979
5015
|
}
|
|
@@ -4984,7 +5020,7 @@ async function prepareResponsesTools({
|
|
|
4984
5020
|
case "required":
|
|
4985
5021
|
return { tools: openaiTools, toolChoice: type, toolWarnings };
|
|
4986
5022
|
case "tool": {
|
|
4987
|
-
const resolvedToolName = (
|
|
5023
|
+
const resolvedToolName = (_c = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _c : toolChoice.toolName;
|
|
4988
5024
|
return {
|
|
4989
5025
|
tools: openaiTools,
|
|
4990
5026
|
toolChoice: resolvedToolName === "code_interpreter" || resolvedToolName === "file_search" || resolvedToolName === "image_generation" || resolvedToolName === "web_search_preview" || resolvedToolName === "web_search" || resolvedToolName === "mcp" || resolvedToolName === "apply_patch" ? { type: resolvedToolName } : resolvedCustomProviderToolNames.has(resolvedToolName) ? { type: "custom", name: resolvedToolName } : { type: "function", name: resolvedToolName },
|
|
@@ -5090,7 +5126,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5090
5126
|
toolChoice,
|
|
5091
5127
|
responseFormat
|
|
5092
5128
|
}) {
|
|
5093
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
5129
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
5094
5130
|
const warnings = [];
|
|
5095
5131
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
5096
5132
|
if (topK != null) {
|
|
@@ -5153,16 +5189,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5153
5189
|
} = await prepareResponsesTools({
|
|
5154
5190
|
tools,
|
|
5155
5191
|
toolChoice,
|
|
5192
|
+
allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
|
|
5156
5193
|
toolNameMapping,
|
|
5157
5194
|
customProviderToolNames
|
|
5158
5195
|
});
|
|
5159
5196
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
5160
5197
|
prompt,
|
|
5161
5198
|
toolNameMapping,
|
|
5162
|
-
systemMessageMode: (
|
|
5199
|
+
systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
5163
5200
|
providerOptionsName,
|
|
5164
5201
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
5165
|
-
store: (
|
|
5202
|
+
store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
|
|
5166
5203
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
5167
5204
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
5168
5205
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
@@ -5170,7 +5207,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5170
5207
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
5171
5208
|
});
|
|
5172
5209
|
warnings.push(...inputWarnings);
|
|
5173
|
-
const strictJsonSchema = (
|
|
5210
|
+
const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
|
|
5174
5211
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
5175
5212
|
function addInclude(key) {
|
|
5176
5213
|
if (include == null) {
|
|
@@ -5186,9 +5223,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5186
5223
|
if (topLogprobs) {
|
|
5187
5224
|
addInclude("message.output_text.logprobs");
|
|
5188
5225
|
}
|
|
5189
|
-
const webSearchToolName = (
|
|
5226
|
+
const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
|
|
5190
5227
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
5191
|
-
)) == null ? void 0 :
|
|
5228
|
+
)) == null ? void 0 : _f.name;
|
|
5192
5229
|
if (webSearchToolName) {
|
|
5193
5230
|
addInclude("web_search_call.action.sources");
|
|
5194
5231
|
}
|
|
@@ -5211,7 +5248,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5211
5248
|
format: responseFormat.schema != null ? {
|
|
5212
5249
|
type: "json_schema",
|
|
5213
5250
|
strict: strictJsonSchema,
|
|
5214
|
-
name: (
|
|
5251
|
+
name: (_g = responseFormat.name) != null ? _g : "response",
|
|
5215
5252
|
description: responseFormat.description,
|
|
5216
5253
|
schema: responseFormat.schema
|
|
5217
5254
|
} : { type: "json_object" }
|
|
@@ -5300,9 +5337,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5300
5337
|
});
|
|
5301
5338
|
delete baseArgs.service_tier;
|
|
5302
5339
|
}
|
|
5303
|
-
const shellToolEnvType = (
|
|
5340
|
+
const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
|
|
5304
5341
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
5305
|
-
)) == null ? void 0 :
|
|
5342
|
+
)) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
|
|
5306
5343
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
5307
5344
|
return {
|
|
5308
5345
|
webSearchToolName,
|