@ai-sdk/openai 2.0.16 → 2.0.17
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.js +56 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -45
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +56 -45
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +56 -45
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.js
CHANGED
|
@@ -444,7 +444,23 @@ var webSearchPreviewArgsSchema = import_v44.z.object({
|
|
|
444
444
|
var webSearchPreview = (0, import_provider_utils4.createProviderDefinedToolFactory)({
|
|
445
445
|
id: "openai.web_search_preview",
|
|
446
446
|
name: "web_search_preview",
|
|
447
|
-
inputSchema: import_v44.z.object({
|
|
447
|
+
inputSchema: import_v44.z.object({
|
|
448
|
+
action: import_v44.z.discriminatedUnion("type", [
|
|
449
|
+
import_v44.z.object({
|
|
450
|
+
type: import_v44.z.literal("search"),
|
|
451
|
+
query: import_v44.z.string()
|
|
452
|
+
}),
|
|
453
|
+
import_v44.z.object({
|
|
454
|
+
type: import_v44.z.literal("open_page"),
|
|
455
|
+
url: import_v44.z.string()
|
|
456
|
+
}),
|
|
457
|
+
import_v44.z.object({
|
|
458
|
+
type: import_v44.z.literal("find"),
|
|
459
|
+
url: import_v44.z.string(),
|
|
460
|
+
pattern: import_v44.z.string()
|
|
461
|
+
})
|
|
462
|
+
]).nullish()
|
|
463
|
+
})
|
|
448
464
|
});
|
|
449
465
|
|
|
450
466
|
// src/chat/openai-chat-prepare-tools.ts
|
|
@@ -2446,6 +2462,26 @@ function prepareResponsesTools({
|
|
|
2446
2462
|
}
|
|
2447
2463
|
|
|
2448
2464
|
// src/responses/openai-responses-language-model.ts
|
|
2465
|
+
var webSearchCallItem = import_v416.z.object({
|
|
2466
|
+
type: import_v416.z.literal("web_search_call"),
|
|
2467
|
+
id: import_v416.z.string(),
|
|
2468
|
+
status: import_v416.z.string(),
|
|
2469
|
+
action: import_v416.z.discriminatedUnion("type", [
|
|
2470
|
+
import_v416.z.object({
|
|
2471
|
+
type: import_v416.z.literal("search"),
|
|
2472
|
+
query: import_v416.z.string()
|
|
2473
|
+
}),
|
|
2474
|
+
import_v416.z.object({
|
|
2475
|
+
type: import_v416.z.literal("open_page"),
|
|
2476
|
+
url: import_v416.z.string()
|
|
2477
|
+
}),
|
|
2478
|
+
import_v416.z.object({
|
|
2479
|
+
type: import_v416.z.literal("find"),
|
|
2480
|
+
url: import_v416.z.string(),
|
|
2481
|
+
pattern: import_v416.z.string()
|
|
2482
|
+
})
|
|
2483
|
+
]).nullish()
|
|
2484
|
+
});
|
|
2449
2485
|
var TOP_LOGPROBS_MAX = 20;
|
|
2450
2486
|
var LOGPROBS_SCHEMA = import_v416.z.array(
|
|
2451
2487
|
import_v416.z.object({
|
|
@@ -2641,7 +2677,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2641
2677
|
};
|
|
2642
2678
|
}
|
|
2643
2679
|
async doGenerate(options) {
|
|
2644
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n
|
|
2680
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
2645
2681
|
const { args: body, warnings } = await this.getArgs(options);
|
|
2646
2682
|
const url = this.config.url({
|
|
2647
2683
|
path: "/responses",
|
|
@@ -2704,15 +2740,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2704
2740
|
arguments: import_v416.z.string(),
|
|
2705
2741
|
id: import_v416.z.string()
|
|
2706
2742
|
}),
|
|
2707
|
-
|
|
2708
|
-
type: import_v416.z.literal("web_search_call"),
|
|
2709
|
-
id: import_v416.z.string(),
|
|
2710
|
-
status: import_v416.z.string().optional(),
|
|
2711
|
-
action: import_v416.z.object({
|
|
2712
|
-
type: import_v416.z.literal("search"),
|
|
2713
|
-
query: import_v416.z.string().optional()
|
|
2714
|
-
}).nullish()
|
|
2715
|
-
}),
|
|
2743
|
+
webSearchCallItem,
|
|
2716
2744
|
import_v416.z.object({
|
|
2717
2745
|
type: import_v416.z.literal("computer_call"),
|
|
2718
2746
|
id: import_v416.z.string(),
|
|
@@ -2843,17 +2871,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2843
2871
|
type: "tool-call",
|
|
2844
2872
|
toolCallId: part.id,
|
|
2845
2873
|
toolName: "web_search_preview",
|
|
2846
|
-
input: (
|
|
2874
|
+
input: JSON.stringify({ action: part.action }),
|
|
2847
2875
|
providerExecuted: true
|
|
2848
2876
|
});
|
|
2849
2877
|
content.push({
|
|
2850
2878
|
type: "tool-result",
|
|
2851
2879
|
toolCallId: part.id,
|
|
2852
2880
|
toolName: "web_search_preview",
|
|
2853
|
-
result: {
|
|
2854
|
-
status: part.status || "completed",
|
|
2855
|
-
...((_l = part.action) == null ? void 0 : _l.query) && { query: part.action.query }
|
|
2856
|
-
},
|
|
2881
|
+
result: { status: part.status },
|
|
2857
2882
|
providerExecuted: true
|
|
2858
2883
|
});
|
|
2859
2884
|
break;
|
|
@@ -2911,15 +2936,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2911
2936
|
return {
|
|
2912
2937
|
content,
|
|
2913
2938
|
finishReason: mapOpenAIResponseFinishReason({
|
|
2914
|
-
finishReason: (
|
|
2939
|
+
finishReason: (_j = response.incomplete_details) == null ? void 0 : _j.reason,
|
|
2915
2940
|
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
2916
2941
|
}),
|
|
2917
2942
|
usage: {
|
|
2918
2943
|
inputTokens: response.usage.input_tokens,
|
|
2919
2944
|
outputTokens: response.usage.output_tokens,
|
|
2920
2945
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
2921
|
-
reasoningTokens: (
|
|
2922
|
-
cachedInputTokens: (
|
|
2946
|
+
reasoningTokens: (_l = (_k = response.usage.output_tokens_details) == null ? void 0 : _k.reasoning_tokens) != null ? _l : void 0,
|
|
2947
|
+
cachedInputTokens: (_n = (_m = response.usage.input_tokens_details) == null ? void 0 : _m.cached_tokens) != null ? _n : void 0
|
|
2923
2948
|
},
|
|
2924
2949
|
request: { body },
|
|
2925
2950
|
response: {
|
|
@@ -2971,7 +2996,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2971
2996
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2972
2997
|
},
|
|
2973
2998
|
transform(chunk, controller) {
|
|
2974
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p
|
|
2999
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2975
3000
|
if (options.includeRawChunks) {
|
|
2976
3001
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2977
3002
|
}
|
|
@@ -3078,20 +3103,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3078
3103
|
type: "tool-call",
|
|
3079
3104
|
toolCallId: value.item.id,
|
|
3080
3105
|
toolName: "web_search_preview",
|
|
3081
|
-
input: (
|
|
3106
|
+
input: JSON.stringify({ action: value.item.action }),
|
|
3082
3107
|
providerExecuted: true
|
|
3083
3108
|
});
|
|
3084
3109
|
controller.enqueue({
|
|
3085
3110
|
type: "tool-result",
|
|
3086
3111
|
toolCallId: value.item.id,
|
|
3087
3112
|
toolName: "web_search_preview",
|
|
3088
|
-
result: {
|
|
3089
|
-
type: "web_search_tool_result",
|
|
3090
|
-
status: value.item.status || "completed",
|
|
3091
|
-
...((_d = value.item.action) == null ? void 0 : _d.query) && {
|
|
3092
|
-
query: value.item.action.query
|
|
3093
|
-
}
|
|
3094
|
-
},
|
|
3113
|
+
result: { status: value.item.status },
|
|
3095
3114
|
providerExecuted: true
|
|
3096
3115
|
});
|
|
3097
3116
|
} else if (value.item.type === "computer_call") {
|
|
@@ -3158,7 +3177,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3158
3177
|
providerMetadata: {
|
|
3159
3178
|
openai: {
|
|
3160
3179
|
itemId: value.item.id,
|
|
3161
|
-
reasoningEncryptedContent: (
|
|
3180
|
+
reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
|
|
3162
3181
|
}
|
|
3163
3182
|
}
|
|
3164
3183
|
});
|
|
@@ -3193,7 +3212,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3193
3212
|
}
|
|
3194
3213
|
} else if (isResponseReasoningSummaryPartAddedChunk(value)) {
|
|
3195
3214
|
if (value.summary_index > 0) {
|
|
3196
|
-
(
|
|
3215
|
+
(_c = activeReasoning[value.item_id]) == null ? void 0 : _c.summaryParts.push(
|
|
3197
3216
|
value.summary_index
|
|
3198
3217
|
);
|
|
3199
3218
|
controller.enqueue({
|
|
@@ -3202,7 +3221,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3202
3221
|
providerMetadata: {
|
|
3203
3222
|
openai: {
|
|
3204
3223
|
itemId: value.item_id,
|
|
3205
|
-
reasoningEncryptedContent: (
|
|
3224
|
+
reasoningEncryptedContent: (_e = (_d = activeReasoning[value.item_id]) == null ? void 0 : _d.encryptedContent) != null ? _e : null
|
|
3206
3225
|
}
|
|
3207
3226
|
}
|
|
3208
3227
|
});
|
|
@@ -3220,20 +3239,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3220
3239
|
});
|
|
3221
3240
|
} else if (isResponseFinishedChunk(value)) {
|
|
3222
3241
|
finishReason = mapOpenAIResponseFinishReason({
|
|
3223
|
-
finishReason: (
|
|
3242
|
+
finishReason: (_f = value.response.incomplete_details) == null ? void 0 : _f.reason,
|
|
3224
3243
|
hasToolCalls
|
|
3225
3244
|
});
|
|
3226
3245
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
3227
3246
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
3228
3247
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
3229
|
-
usage.reasoningTokens = (
|
|
3230
|
-
usage.cachedInputTokens = (
|
|
3248
|
+
usage.reasoningTokens = (_h = (_g = value.response.usage.output_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : void 0;
|
|
3249
|
+
usage.cachedInputTokens = (_j = (_i = value.response.usage.input_tokens_details) == null ? void 0 : _i.cached_tokens) != null ? _j : void 0;
|
|
3231
3250
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
3232
3251
|
if (value.annotation.type === "url_citation") {
|
|
3233
3252
|
controller.enqueue({
|
|
3234
3253
|
type: "source",
|
|
3235
3254
|
sourceType: "url",
|
|
3236
|
-
id: (
|
|
3255
|
+
id: (_m = (_l = (_k = self.config).generateId) == null ? void 0 : _l.call(_k)) != null ? _m : (0, import_provider_utils14.generateId)(),
|
|
3237
3256
|
url: value.annotation.url,
|
|
3238
3257
|
title: value.annotation.title
|
|
3239
3258
|
});
|
|
@@ -3241,7 +3260,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3241
3260
|
controller.enqueue({
|
|
3242
3261
|
type: "source",
|
|
3243
3262
|
sourceType: "document",
|
|
3244
|
-
id: (
|
|
3263
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : (0, import_provider_utils14.generateId)(),
|
|
3245
3264
|
mediaType: "text/plain",
|
|
3246
3265
|
title: value.annotation.quote,
|
|
3247
3266
|
filename: value.annotation.file_id
|
|
@@ -3381,15 +3400,7 @@ var responseOutputItemDoneSchema = import_v416.z.object({
|
|
|
3381
3400
|
arguments: import_v416.z.string(),
|
|
3382
3401
|
status: import_v416.z.literal("completed")
|
|
3383
3402
|
}),
|
|
3384
|
-
|
|
3385
|
-
type: import_v416.z.literal("web_search_call"),
|
|
3386
|
-
id: import_v416.z.string(),
|
|
3387
|
-
status: import_v416.z.literal("completed"),
|
|
3388
|
-
action: import_v416.z.object({
|
|
3389
|
-
type: import_v416.z.literal("search"),
|
|
3390
|
-
query: import_v416.z.string().optional()
|
|
3391
|
-
}).nullish()
|
|
3392
|
-
}),
|
|
3403
|
+
webSearchCallItem,
|
|
3393
3404
|
import_v416.z.object({
|
|
3394
3405
|
type: import_v416.z.literal("computer_call"),
|
|
3395
3406
|
id: import_v416.z.string(),
|