@ai-sdk/openai 2.0.125 → 2.0.126
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 +7 -0
- package/dist/index.d.mts +280 -1
- package/dist/index.d.ts +280 -1
- package/dist/index.js +55 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -11
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +5 -0
- package/dist/internal/index.d.ts +5 -0
- package/dist/internal/index.js +54 -10
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +54 -10
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -69,6 +69,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
69
69
|
supportsFlexProcessing,
|
|
70
70
|
supportsPriorityProcessing,
|
|
71
71
|
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
72
|
+
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
72
73
|
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
73
74
|
isReasoningModel,
|
|
74
75
|
systemMessageMode,
|
|
@@ -2359,11 +2360,12 @@ function isFileId(data, prefixes) {
|
|
|
2359
2360
|
async function convertToOpenAIResponsesInput({
|
|
2360
2361
|
prompt,
|
|
2361
2362
|
systemMessageMode,
|
|
2363
|
+
explicitMessageItemType = false,
|
|
2362
2364
|
fileIdPrefixes,
|
|
2363
2365
|
store,
|
|
2364
2366
|
hasLocalShellTool = false
|
|
2365
2367
|
}) {
|
|
2366
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
2368
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
2367
2369
|
let input = [];
|
|
2368
2370
|
const warnings = [];
|
|
2369
2371
|
for (const { role, content, providerOptions } of prompt) {
|
|
@@ -2373,6 +2375,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2373
2375
|
case "system": {
|
|
2374
2376
|
const promptCacheBreakpoint = getPromptCacheBreakpoint2(providerOptions);
|
|
2375
2377
|
input.push({
|
|
2378
|
+
...explicitMessageItemType && { type: "message" },
|
|
2376
2379
|
role: "system",
|
|
2377
2380
|
content: promptCacheBreakpoint == null ? content : [
|
|
2378
2381
|
{
|
|
@@ -2387,6 +2390,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2387
2390
|
case "developer": {
|
|
2388
2391
|
const promptCacheBreakpoint = getPromptCacheBreakpoint2(providerOptions);
|
|
2389
2392
|
input.push({
|
|
2393
|
+
...explicitMessageItemType && { type: "message" },
|
|
2390
2394
|
role: "developer",
|
|
2391
2395
|
content: promptCacheBreakpoint == null ? content : [
|
|
2392
2396
|
{
|
|
@@ -2416,6 +2420,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2416
2420
|
}
|
|
2417
2421
|
case "user": {
|
|
2418
2422
|
input.push({
|
|
2423
|
+
...explicitMessageItemType && { type: "message" },
|
|
2419
2424
|
role: "user",
|
|
2420
2425
|
content: content.map((part, index) => {
|
|
2421
2426
|
var _a3, _b2, _c2;
|
|
@@ -2492,6 +2497,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2492
2497
|
break;
|
|
2493
2498
|
}
|
|
2494
2499
|
input.push({
|
|
2500
|
+
...explicitMessageItemType && { type: "message" },
|
|
2495
2501
|
role: "assistant",
|
|
2496
2502
|
content: [{ type: "output_text", text: part.text }],
|
|
2497
2503
|
id,
|
|
@@ -2505,6 +2511,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2505
2511
|
break;
|
|
2506
2512
|
}
|
|
2507
2513
|
const id = (_f = (_e = part.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.itemId;
|
|
2514
|
+
const isAsync = (_h = (_g = part.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.async;
|
|
2508
2515
|
if (store && id != null) {
|
|
2509
2516
|
input.push({ type: "item_reference", id });
|
|
2510
2517
|
break;
|
|
@@ -2534,6 +2541,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2534
2541
|
call_id: part.toolCallId,
|
|
2535
2542
|
name: part.toolName,
|
|
2536
2543
|
arguments: JSON.stringify(part.input),
|
|
2544
|
+
...isAsync != null && { async: isAsync },
|
|
2537
2545
|
id
|
|
2538
2546
|
});
|
|
2539
2547
|
break;
|
|
@@ -2806,7 +2814,8 @@ var openaiResponsesChunkSchema = (0, import_provider_utils22.lazyValidator)(
|
|
|
2806
2814
|
id: import_v417.z.string(),
|
|
2807
2815
|
call_id: import_v417.z.string(),
|
|
2808
2816
|
name: import_v417.z.string(),
|
|
2809
|
-
arguments: import_v417.z.string()
|
|
2817
|
+
arguments: import_v417.z.string(),
|
|
2818
|
+
async: import_v417.z.boolean().nullish()
|
|
2810
2819
|
}),
|
|
2811
2820
|
import_v417.z.object({
|
|
2812
2821
|
type: import_v417.z.literal("web_search_call"),
|
|
@@ -2861,6 +2870,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils22.lazyValidator)(
|
|
|
2861
2870
|
call_id: import_v417.z.string(),
|
|
2862
2871
|
name: import_v417.z.string(),
|
|
2863
2872
|
arguments: import_v417.z.string(),
|
|
2873
|
+
async: import_v417.z.boolean().nullish(),
|
|
2864
2874
|
status: import_v417.z.literal("completed")
|
|
2865
2875
|
}),
|
|
2866
2876
|
import_v417.z.object({
|
|
@@ -3172,7 +3182,8 @@ var openaiResponsesResponseSchema = (0, import_provider_utils22.lazyValidator)(
|
|
|
3172
3182
|
call_id: import_v417.z.string(),
|
|
3173
3183
|
name: import_v417.z.string(),
|
|
3174
3184
|
arguments: import_v417.z.string(),
|
|
3175
|
-
id: import_v417.z.string()
|
|
3185
|
+
id: import_v417.z.string(),
|
|
3186
|
+
async: import_v417.z.boolean().nullish()
|
|
3176
3187
|
}),
|
|
3177
3188
|
import_v417.z.object({
|
|
3178
3189
|
type: import_v417.z.literal("computer_call"),
|
|
@@ -3405,8 +3416,10 @@ var import_provider_utils24 = require("@ai-sdk/provider-utils");
|
|
|
3405
3416
|
async function prepareResponsesTools({
|
|
3406
3417
|
tools,
|
|
3407
3418
|
toolChoice,
|
|
3408
|
-
strictJsonSchema
|
|
3419
|
+
strictJsonSchema,
|
|
3420
|
+
supportsAsyncToolCalling = true
|
|
3409
3421
|
}) {
|
|
3422
|
+
var _a2;
|
|
3410
3423
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
3411
3424
|
const toolWarnings = [];
|
|
3412
3425
|
if (tools == null) {
|
|
@@ -3415,15 +3428,24 @@ async function prepareResponsesTools({
|
|
|
3415
3428
|
const openaiTools2 = [];
|
|
3416
3429
|
for (const tool of tools) {
|
|
3417
3430
|
switch (tool.type) {
|
|
3418
|
-
case "function":
|
|
3431
|
+
case "function": {
|
|
3432
|
+
const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
|
|
3433
|
+
const async = resolveAsyncToolOption({
|
|
3434
|
+
value: openaiOptions == null ? void 0 : openaiOptions.async,
|
|
3435
|
+
supportsAsyncToolCalling,
|
|
3436
|
+
tool,
|
|
3437
|
+
toolWarnings
|
|
3438
|
+
});
|
|
3419
3439
|
openaiTools2.push({
|
|
3420
3440
|
type: "function",
|
|
3421
3441
|
name: tool.name,
|
|
3422
3442
|
description: tool.description,
|
|
3423
3443
|
parameters: tool.inputSchema,
|
|
3424
|
-
strict: strictJsonSchema
|
|
3444
|
+
strict: strictJsonSchema,
|
|
3445
|
+
...async != null ? { async } : {}
|
|
3425
3446
|
});
|
|
3426
3447
|
break;
|
|
3448
|
+
}
|
|
3427
3449
|
case "provider-defined": {
|
|
3428
3450
|
switch (tool.id) {
|
|
3429
3451
|
case "openai.file_search": {
|
|
@@ -3542,6 +3564,22 @@ async function prepareResponsesTools({
|
|
|
3542
3564
|
}
|
|
3543
3565
|
}
|
|
3544
3566
|
}
|
|
3567
|
+
function resolveAsyncToolOption({
|
|
3568
|
+
value,
|
|
3569
|
+
supportsAsyncToolCalling,
|
|
3570
|
+
tool,
|
|
3571
|
+
toolWarnings
|
|
3572
|
+
}) {
|
|
3573
|
+
if (value !== true || supportsAsyncToolCalling) {
|
|
3574
|
+
return value;
|
|
3575
|
+
}
|
|
3576
|
+
toolWarnings.push({
|
|
3577
|
+
type: "unsupported-tool",
|
|
3578
|
+
tool,
|
|
3579
|
+
details: "Async tool calling is only supported by GPT-6 and later models."
|
|
3580
|
+
});
|
|
3581
|
+
return void 0;
|
|
3582
|
+
}
|
|
3545
3583
|
|
|
3546
3584
|
// src/responses/openai-responses-language-model.ts
|
|
3547
3585
|
var OpenAIResponsesLanguageModel = class {
|
|
@@ -3611,6 +3649,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3611
3649
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
3612
3650
|
prompt,
|
|
3613
3651
|
systemMessageMode: modelCapabilities.systemMessageMode,
|
|
3652
|
+
explicitMessageItemType: this.config.explicitMessageItemType,
|
|
3614
3653
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
3615
3654
|
store: (_a2 = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a2 : true,
|
|
3616
3655
|
hasLocalShellTool: hasOpenAITool("openai.local_shell")
|
|
@@ -3821,7 +3860,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3821
3860
|
} = await prepareResponsesTools({
|
|
3822
3861
|
tools,
|
|
3823
3862
|
toolChoice,
|
|
3824
|
-
strictJsonSchema
|
|
3863
|
+
strictJsonSchema,
|
|
3864
|
+
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
|
|
3825
3865
|
});
|
|
3826
3866
|
return {
|
|
3827
3867
|
webSearchToolName,
|
|
@@ -4015,7 +4055,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4015
4055
|
input: part.arguments,
|
|
4016
4056
|
providerMetadata: {
|
|
4017
4057
|
[providerKey]: {
|
|
4018
|
-
itemId: part.id
|
|
4058
|
+
itemId: part.id,
|
|
4059
|
+
...part.async != null && { async: part.async }
|
|
4019
4060
|
}
|
|
4020
4061
|
}
|
|
4021
4062
|
});
|
|
@@ -4215,7 +4256,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4215
4256
|
if (value.item.type === "function_call") {
|
|
4216
4257
|
ongoingToolCalls[value.output_index] = {
|
|
4217
4258
|
toolName: value.item.name,
|
|
4218
|
-
toolCallId: value.item.call_id
|
|
4259
|
+
toolCallId: value.item.call_id,
|
|
4260
|
+
async: value.item.async
|
|
4219
4261
|
};
|
|
4220
4262
|
controller.enqueue({
|
|
4221
4263
|
type: "tool-input-start",
|
|
@@ -4339,6 +4381,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4339
4381
|
}
|
|
4340
4382
|
});
|
|
4341
4383
|
} else if (value.item.type === "function_call") {
|
|
4384
|
+
const ongoingToolCall = ongoingToolCalls[value.output_index];
|
|
4342
4385
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4343
4386
|
hasFunctionCall = true;
|
|
4344
4387
|
controller.enqueue({
|
|
@@ -4352,7 +4395,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4352
4395
|
input: value.item.arguments,
|
|
4353
4396
|
providerMetadata: {
|
|
4354
4397
|
[providerKey]: {
|
|
4355
|
-
itemId: value.item.id
|
|
4398
|
+
itemId: value.item.id,
|
|
4399
|
+
...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
|
|
4356
4400
|
}
|
|
4357
4401
|
}
|
|
4358
4402
|
});
|
|
@@ -5087,7 +5131,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5087
5131
|
};
|
|
5088
5132
|
|
|
5089
5133
|
// src/version.ts
|
|
5090
|
-
var VERSION = true ? "2.0.
|
|
5134
|
+
var VERSION = true ? "2.0.126" : "0.0.0-test";
|
|
5091
5135
|
|
|
5092
5136
|
// src/openai-provider.ts
|
|
5093
5137
|
function createOpenAI(options = {}) {
|