@ai-sdk/openai 4.0.0-canary.49 → 4.0.0-canary.50
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.ts +4 -0
- package/dist/index.js +46 -13
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +45 -12
- package/dist/internal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/responses/openai-responses-language-model-options.ts +17 -0
- package/src/responses/openai-responses-language-model.ts +1 -0
- package/src/responses/openai-responses-prepare-tools.ts +26 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1067,6 +1067,10 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
|
|
|
1067
1067
|
type: "compaction";
|
|
1068
1068
|
compactThreshold: number;
|
|
1069
1069
|
}[] | null | undefined;
|
|
1070
|
+
allowedTools?: {
|
|
1071
|
+
toolNames: string[];
|
|
1072
|
+
mode?: "auto" | "required" | undefined;
|
|
1073
|
+
} | undefined;
|
|
1070
1074
|
}>;
|
|
1071
1075
|
type OpenAILanguageModelResponsesOptions = InferSchema<typeof openaiLanguageModelResponsesOptionsSchema>;
|
|
1072
1076
|
|
package/dist/index.js
CHANGED
|
@@ -4746,7 +4746,21 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema23(
|
|
|
4746
4746
|
type: z25.literal("compaction"),
|
|
4747
4747
|
compactThreshold: z25.number()
|
|
4748
4748
|
})
|
|
4749
|
-
).nullish()
|
|
4749
|
+
).nullish(),
|
|
4750
|
+
/**
|
|
4751
|
+
* Restrict the callable tools to a subset while keeping the full tools
|
|
4752
|
+
* list intact, so prompt caching is preserved across requests with
|
|
4753
|
+
* different allowlists.
|
|
4754
|
+
*
|
|
4755
|
+
* When set, this overrides the request-level `toolChoice` and emits
|
|
4756
|
+
* `tool_choice: { type: "allowed_tools", mode, tools }` on the wire.
|
|
4757
|
+
*
|
|
4758
|
+
* @see https://developers.openai.com/api/reference/resources/responses/methods/create#(resource)%20responses%20%3E%20(model)%20tool_choice_allowed%20%3E%20(schema)
|
|
4759
|
+
*/
|
|
4760
|
+
allowedTools: z25.object({
|
|
4761
|
+
toolNames: z25.array(z25.string()).min(1),
|
|
4762
|
+
mode: z25.enum(["auto", "required"]).optional()
|
|
4763
|
+
}).optional()
|
|
4750
4764
|
})
|
|
4751
4765
|
)
|
|
4752
4766
|
);
|
|
@@ -4762,10 +4776,11 @@ import {
|
|
|
4762
4776
|
async function prepareResponsesTools({
|
|
4763
4777
|
tools,
|
|
4764
4778
|
toolChoice,
|
|
4779
|
+
allowedTools,
|
|
4765
4780
|
toolNameMapping,
|
|
4766
4781
|
customProviderToolNames
|
|
4767
4782
|
}) {
|
|
4768
|
-
var _a, _b;
|
|
4783
|
+
var _a, _b, _c;
|
|
4769
4784
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
4770
4785
|
const toolWarnings = [];
|
|
4771
4786
|
if (tools == null) {
|
|
@@ -4956,6 +4971,23 @@ async function prepareResponsesTools({
|
|
|
4956
4971
|
break;
|
|
4957
4972
|
}
|
|
4958
4973
|
}
|
|
4974
|
+
if (allowedTools != null) {
|
|
4975
|
+
return {
|
|
4976
|
+
tools: openaiTools2,
|
|
4977
|
+
toolChoice: {
|
|
4978
|
+
type: "allowed_tools",
|
|
4979
|
+
mode: (_b = allowedTools.mode) != null ? _b : "auto",
|
|
4980
|
+
tools: allowedTools.toolNames.map((name) => {
|
|
4981
|
+
var _a2;
|
|
4982
|
+
return {
|
|
4983
|
+
type: "function",
|
|
4984
|
+
name: (_a2 = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(name)) != null ? _a2 : name
|
|
4985
|
+
};
|
|
4986
|
+
})
|
|
4987
|
+
},
|
|
4988
|
+
toolWarnings
|
|
4989
|
+
};
|
|
4990
|
+
}
|
|
4959
4991
|
if (toolChoice == null) {
|
|
4960
4992
|
return { tools: openaiTools2, toolChoice: void 0, toolWarnings };
|
|
4961
4993
|
}
|
|
@@ -4966,7 +4998,7 @@ async function prepareResponsesTools({
|
|
|
4966
4998
|
case "required":
|
|
4967
4999
|
return { tools: openaiTools2, toolChoice: type, toolWarnings };
|
|
4968
5000
|
case "tool": {
|
|
4969
|
-
const resolvedToolName = (
|
|
5001
|
+
const resolvedToolName = (_c = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _c : toolChoice.toolName;
|
|
4970
5002
|
return {
|
|
4971
5003
|
tools: openaiTools2,
|
|
4972
5004
|
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 },
|
|
@@ -5088,7 +5120,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5088
5120
|
toolChoice,
|
|
5089
5121
|
responseFormat
|
|
5090
5122
|
}) {
|
|
5091
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
5123
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5092
5124
|
const warnings = [];
|
|
5093
5125
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
5094
5126
|
if (topK != null) {
|
|
@@ -5151,16 +5183,17 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5151
5183
|
} = await prepareResponsesTools({
|
|
5152
5184
|
tools,
|
|
5153
5185
|
toolChoice,
|
|
5186
|
+
allowedTools: (_c = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _c : void 0,
|
|
5154
5187
|
toolNameMapping,
|
|
5155
5188
|
customProviderToolNames
|
|
5156
5189
|
});
|
|
5157
5190
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
5158
5191
|
prompt,
|
|
5159
5192
|
toolNameMapping,
|
|
5160
|
-
systemMessageMode: (
|
|
5193
|
+
systemMessageMode: (_d = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
5161
5194
|
providerOptionsName,
|
|
5162
5195
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
5163
|
-
store: (
|
|
5196
|
+
store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
|
|
5164
5197
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
5165
5198
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
5166
5199
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
@@ -5168,7 +5201,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5168
5201
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
5169
5202
|
});
|
|
5170
5203
|
warnings.push(...inputWarnings);
|
|
5171
|
-
const strictJsonSchema = (
|
|
5204
|
+
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
5172
5205
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
5173
5206
|
function addInclude(key) {
|
|
5174
5207
|
if (include == null) {
|
|
@@ -5184,9 +5217,9 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5184
5217
|
if (topLogprobs) {
|
|
5185
5218
|
addInclude("message.output_text.logprobs");
|
|
5186
5219
|
}
|
|
5187
|
-
const webSearchToolName = (
|
|
5220
|
+
const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
|
|
5188
5221
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
5189
|
-
)) == null ? void 0 :
|
|
5222
|
+
)) == null ? void 0 : _g.name;
|
|
5190
5223
|
if (webSearchToolName) {
|
|
5191
5224
|
addInclude("web_search_call.action.sources");
|
|
5192
5225
|
}
|
|
@@ -5209,7 +5242,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5209
5242
|
format: responseFormat.schema != null ? {
|
|
5210
5243
|
type: "json_schema",
|
|
5211
5244
|
strict: strictJsonSchema,
|
|
5212
|
-
name: (
|
|
5245
|
+
name: (_h = responseFormat.name) != null ? _h : "response",
|
|
5213
5246
|
description: responseFormat.description,
|
|
5214
5247
|
schema: responseFormat.schema
|
|
5215
5248
|
} : { type: "json_object" }
|
|
@@ -5305,9 +5338,9 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
5305
5338
|
});
|
|
5306
5339
|
delete baseArgs.service_tier;
|
|
5307
5340
|
}
|
|
5308
|
-
const shellToolEnvType = (
|
|
5341
|
+
const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
|
|
5309
5342
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
5310
|
-
)) == null ? void 0 :
|
|
5343
|
+
)) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
|
|
5311
5344
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
5312
5345
|
return {
|
|
5313
5346
|
webSearchToolName,
|
|
@@ -7259,7 +7292,7 @@ var OpenAISkills = class {
|
|
|
7259
7292
|
};
|
|
7260
7293
|
|
|
7261
7294
|
// src/version.ts
|
|
7262
|
-
var VERSION = true ? "4.0.0-canary.
|
|
7295
|
+
var VERSION = true ? "4.0.0-canary.50" : "0.0.0-test";
|
|
7263
7296
|
|
|
7264
7297
|
// src/openai-provider.ts
|
|
7265
7298
|
function createOpenAI(options = {}) {
|