@ai-sdk/openai 3.0.61 → 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 +6 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +46 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -13
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +45 -12
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +45 -12
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- 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.js
CHANGED
|
@@ -4370,7 +4370,21 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils26.lazy
|
|
|
4370
4370
|
* When enabled, the SDK applies reasoning-model parameter compatibility rules
|
|
4371
4371
|
* and defaults `systemMessageMode` to `developer` unless overridden.
|
|
4372
4372
|
*/
|
|
4373
|
-
forceReasoning: import_v419.z.boolean().optional()
|
|
4373
|
+
forceReasoning: import_v419.z.boolean().optional(),
|
|
4374
|
+
/**
|
|
4375
|
+
* Restrict the callable tools to a subset while keeping the full tools
|
|
4376
|
+
* list intact, so prompt caching is preserved across requests with
|
|
4377
|
+
* different allowlists.
|
|
4378
|
+
*
|
|
4379
|
+
* When set, this overrides the request-level `toolChoice` and emits
|
|
4380
|
+
* `tool_choice: { type: "allowed_tools", mode, tools }` on the wire.
|
|
4381
|
+
*
|
|
4382
|
+
* @see https://developers.openai.com/api/reference/resources/responses/methods/create#(resource)%20responses%20%3E%20(model)%20tool_choice_allowed%20%3E%20(schema)
|
|
4383
|
+
*/
|
|
4384
|
+
allowedTools: import_v419.z.object({
|
|
4385
|
+
toolNames: import_v419.z.array(import_v419.z.string()).min(1),
|
|
4386
|
+
mode: import_v419.z.enum(["auto", "required"]).optional()
|
|
4387
|
+
}).optional()
|
|
4374
4388
|
})
|
|
4375
4389
|
)
|
|
4376
4390
|
);
|
|
@@ -4700,10 +4714,11 @@ var webSearchPreview = (0, import_provider_utils33.createProviderToolFactoryWith
|
|
|
4700
4714
|
async function prepareResponsesTools({
|
|
4701
4715
|
tools,
|
|
4702
4716
|
toolChoice,
|
|
4717
|
+
allowedTools,
|
|
4703
4718
|
toolNameMapping,
|
|
4704
4719
|
customProviderToolNames
|
|
4705
4720
|
}) {
|
|
4706
|
-
var _a, _b;
|
|
4721
|
+
var _a, _b, _c;
|
|
4707
4722
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
4708
4723
|
const toolWarnings = [];
|
|
4709
4724
|
if (tools == null) {
|
|
@@ -4894,6 +4909,23 @@ async function prepareResponsesTools({
|
|
|
4894
4909
|
break;
|
|
4895
4910
|
}
|
|
4896
4911
|
}
|
|
4912
|
+
if (allowedTools != null) {
|
|
4913
|
+
return {
|
|
4914
|
+
tools: openaiTools,
|
|
4915
|
+
toolChoice: {
|
|
4916
|
+
type: "allowed_tools",
|
|
4917
|
+
mode: (_b = allowedTools.mode) != null ? _b : "auto",
|
|
4918
|
+
tools: allowedTools.toolNames.map((name) => {
|
|
4919
|
+
var _a2;
|
|
4920
|
+
return {
|
|
4921
|
+
type: "function",
|
|
4922
|
+
name: (_a2 = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(name)) != null ? _a2 : name
|
|
4923
|
+
};
|
|
4924
|
+
})
|
|
4925
|
+
},
|
|
4926
|
+
toolWarnings
|
|
4927
|
+
};
|
|
4928
|
+
}
|
|
4897
4929
|
if (toolChoice == null) {
|
|
4898
4930
|
return { tools: openaiTools, toolChoice: void 0, toolWarnings };
|
|
4899
4931
|
}
|
|
@@ -4904,7 +4936,7 @@ async function prepareResponsesTools({
|
|
|
4904
4936
|
case "required":
|
|
4905
4937
|
return { tools: openaiTools, toolChoice: type, toolWarnings };
|
|
4906
4938
|
case "tool": {
|
|
4907
|
-
const resolvedToolName = (
|
|
4939
|
+
const resolvedToolName = (_c = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _c : toolChoice.toolName;
|
|
4908
4940
|
return {
|
|
4909
4941
|
tools: openaiTools,
|
|
4910
4942
|
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 },
|
|
@@ -5010,7 +5042,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5010
5042
|
toolChoice,
|
|
5011
5043
|
responseFormat
|
|
5012
5044
|
}) {
|
|
5013
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
5045
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
5014
5046
|
const warnings = [];
|
|
5015
5047
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
5016
5048
|
if (topK != null) {
|
|
@@ -5073,16 +5105,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5073
5105
|
} = await prepareResponsesTools({
|
|
5074
5106
|
tools,
|
|
5075
5107
|
toolChoice,
|
|
5108
|
+
allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
|
|
5076
5109
|
toolNameMapping,
|
|
5077
5110
|
customProviderToolNames
|
|
5078
5111
|
});
|
|
5079
5112
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
5080
5113
|
prompt,
|
|
5081
5114
|
toolNameMapping,
|
|
5082
|
-
systemMessageMode: (
|
|
5115
|
+
systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
5083
5116
|
providerOptionsName,
|
|
5084
5117
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
5085
|
-
store: (
|
|
5118
|
+
store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
|
|
5086
5119
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
5087
5120
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
5088
5121
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
@@ -5090,7 +5123,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5090
5123
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
5091
5124
|
});
|
|
5092
5125
|
warnings.push(...inputWarnings);
|
|
5093
|
-
const strictJsonSchema = (
|
|
5126
|
+
const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
|
|
5094
5127
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
5095
5128
|
function addInclude(key) {
|
|
5096
5129
|
if (include == null) {
|
|
@@ -5106,9 +5139,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5106
5139
|
if (topLogprobs) {
|
|
5107
5140
|
addInclude("message.output_text.logprobs");
|
|
5108
5141
|
}
|
|
5109
|
-
const webSearchToolName = (
|
|
5142
|
+
const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
|
|
5110
5143
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
5111
|
-
)) == null ? void 0 :
|
|
5144
|
+
)) == null ? void 0 : _f.name;
|
|
5112
5145
|
if (webSearchToolName) {
|
|
5113
5146
|
addInclude("web_search_call.action.sources");
|
|
5114
5147
|
}
|
|
@@ -5131,7 +5164,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5131
5164
|
format: responseFormat.schema != null ? {
|
|
5132
5165
|
type: "json_schema",
|
|
5133
5166
|
strict: strictJsonSchema,
|
|
5134
|
-
name: (
|
|
5167
|
+
name: (_g = responseFormat.name) != null ? _g : "response",
|
|
5135
5168
|
description: responseFormat.description,
|
|
5136
5169
|
schema: responseFormat.schema
|
|
5137
5170
|
} : { type: "json_object" }
|
|
@@ -5220,9 +5253,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5220
5253
|
});
|
|
5221
5254
|
delete baseArgs.service_tier;
|
|
5222
5255
|
}
|
|
5223
|
-
const shellToolEnvType = (
|
|
5256
|
+
const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
|
|
5224
5257
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
5225
|
-
)) == null ? void 0 :
|
|
5258
|
+
)) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
|
|
5226
5259
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
5227
5260
|
return {
|
|
5228
5261
|
webSearchToolName,
|