@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.mjs
CHANGED
|
@@ -420,7 +420,23 @@ var webSearchPreviewArgsSchema = z4.object({
|
|
|
420
420
|
var webSearchPreview = createProviderDefinedToolFactory2({
|
|
421
421
|
id: "openai.web_search_preview",
|
|
422
422
|
name: "web_search_preview",
|
|
423
|
-
inputSchema: z4.object({
|
|
423
|
+
inputSchema: z4.object({
|
|
424
|
+
action: z4.discriminatedUnion("type", [
|
|
425
|
+
z4.object({
|
|
426
|
+
type: z4.literal("search"),
|
|
427
|
+
query: z4.string()
|
|
428
|
+
}),
|
|
429
|
+
z4.object({
|
|
430
|
+
type: z4.literal("open_page"),
|
|
431
|
+
url: z4.string()
|
|
432
|
+
}),
|
|
433
|
+
z4.object({
|
|
434
|
+
type: z4.literal("find"),
|
|
435
|
+
url: z4.string(),
|
|
436
|
+
pattern: z4.string()
|
|
437
|
+
})
|
|
438
|
+
]).nullish()
|
|
439
|
+
})
|
|
424
440
|
});
|
|
425
441
|
|
|
426
442
|
// src/chat/openai-chat-prepare-tools.ts
|
|
@@ -2466,6 +2482,26 @@ function prepareResponsesTools({
|
|
|
2466
2482
|
}
|
|
2467
2483
|
|
|
2468
2484
|
// src/responses/openai-responses-language-model.ts
|
|
2485
|
+
var webSearchCallItem = z16.object({
|
|
2486
|
+
type: z16.literal("web_search_call"),
|
|
2487
|
+
id: z16.string(),
|
|
2488
|
+
status: z16.string(),
|
|
2489
|
+
action: z16.discriminatedUnion("type", [
|
|
2490
|
+
z16.object({
|
|
2491
|
+
type: z16.literal("search"),
|
|
2492
|
+
query: z16.string()
|
|
2493
|
+
}),
|
|
2494
|
+
z16.object({
|
|
2495
|
+
type: z16.literal("open_page"),
|
|
2496
|
+
url: z16.string()
|
|
2497
|
+
}),
|
|
2498
|
+
z16.object({
|
|
2499
|
+
type: z16.literal("find"),
|
|
2500
|
+
url: z16.string(),
|
|
2501
|
+
pattern: z16.string()
|
|
2502
|
+
})
|
|
2503
|
+
]).nullish()
|
|
2504
|
+
});
|
|
2469
2505
|
var TOP_LOGPROBS_MAX = 20;
|
|
2470
2506
|
var LOGPROBS_SCHEMA = z16.array(
|
|
2471
2507
|
z16.object({
|
|
@@ -2661,7 +2697,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2661
2697
|
};
|
|
2662
2698
|
}
|
|
2663
2699
|
async doGenerate(options) {
|
|
2664
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n
|
|
2700
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
2665
2701
|
const { args: body, warnings } = await this.getArgs(options);
|
|
2666
2702
|
const url = this.config.url({
|
|
2667
2703
|
path: "/responses",
|
|
@@ -2724,15 +2760,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2724
2760
|
arguments: z16.string(),
|
|
2725
2761
|
id: z16.string()
|
|
2726
2762
|
}),
|
|
2727
|
-
|
|
2728
|
-
type: z16.literal("web_search_call"),
|
|
2729
|
-
id: z16.string(),
|
|
2730
|
-
status: z16.string().optional(),
|
|
2731
|
-
action: z16.object({
|
|
2732
|
-
type: z16.literal("search"),
|
|
2733
|
-
query: z16.string().optional()
|
|
2734
|
-
}).nullish()
|
|
2735
|
-
}),
|
|
2763
|
+
webSearchCallItem,
|
|
2736
2764
|
z16.object({
|
|
2737
2765
|
type: z16.literal("computer_call"),
|
|
2738
2766
|
id: z16.string(),
|
|
@@ -2863,17 +2891,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2863
2891
|
type: "tool-call",
|
|
2864
2892
|
toolCallId: part.id,
|
|
2865
2893
|
toolName: "web_search_preview",
|
|
2866
|
-
input: (
|
|
2894
|
+
input: JSON.stringify({ action: part.action }),
|
|
2867
2895
|
providerExecuted: true
|
|
2868
2896
|
});
|
|
2869
2897
|
content.push({
|
|
2870
2898
|
type: "tool-result",
|
|
2871
2899
|
toolCallId: part.id,
|
|
2872
2900
|
toolName: "web_search_preview",
|
|
2873
|
-
result: {
|
|
2874
|
-
status: part.status || "completed",
|
|
2875
|
-
...((_l = part.action) == null ? void 0 : _l.query) && { query: part.action.query }
|
|
2876
|
-
},
|
|
2901
|
+
result: { status: part.status },
|
|
2877
2902
|
providerExecuted: true
|
|
2878
2903
|
});
|
|
2879
2904
|
break;
|
|
@@ -2931,15 +2956,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2931
2956
|
return {
|
|
2932
2957
|
content,
|
|
2933
2958
|
finishReason: mapOpenAIResponseFinishReason({
|
|
2934
|
-
finishReason: (
|
|
2959
|
+
finishReason: (_j = response.incomplete_details) == null ? void 0 : _j.reason,
|
|
2935
2960
|
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
2936
2961
|
}),
|
|
2937
2962
|
usage: {
|
|
2938
2963
|
inputTokens: response.usage.input_tokens,
|
|
2939
2964
|
outputTokens: response.usage.output_tokens,
|
|
2940
2965
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
2941
|
-
reasoningTokens: (
|
|
2942
|
-
cachedInputTokens: (
|
|
2966
|
+
reasoningTokens: (_l = (_k = response.usage.output_tokens_details) == null ? void 0 : _k.reasoning_tokens) != null ? _l : void 0,
|
|
2967
|
+
cachedInputTokens: (_n = (_m = response.usage.input_tokens_details) == null ? void 0 : _m.cached_tokens) != null ? _n : void 0
|
|
2943
2968
|
},
|
|
2944
2969
|
request: { body },
|
|
2945
2970
|
response: {
|
|
@@ -2991,7 +3016,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2991
3016
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2992
3017
|
},
|
|
2993
3018
|
transform(chunk, controller) {
|
|
2994
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p
|
|
3019
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2995
3020
|
if (options.includeRawChunks) {
|
|
2996
3021
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2997
3022
|
}
|
|
@@ -3098,20 +3123,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3098
3123
|
type: "tool-call",
|
|
3099
3124
|
toolCallId: value.item.id,
|
|
3100
3125
|
toolName: "web_search_preview",
|
|
3101
|
-
input: (
|
|
3126
|
+
input: JSON.stringify({ action: value.item.action }),
|
|
3102
3127
|
providerExecuted: true
|
|
3103
3128
|
});
|
|
3104
3129
|
controller.enqueue({
|
|
3105
3130
|
type: "tool-result",
|
|
3106
3131
|
toolCallId: value.item.id,
|
|
3107
3132
|
toolName: "web_search_preview",
|
|
3108
|
-
result: {
|
|
3109
|
-
type: "web_search_tool_result",
|
|
3110
|
-
status: value.item.status || "completed",
|
|
3111
|
-
...((_d = value.item.action) == null ? void 0 : _d.query) && {
|
|
3112
|
-
query: value.item.action.query
|
|
3113
|
-
}
|
|
3114
|
-
},
|
|
3133
|
+
result: { status: value.item.status },
|
|
3115
3134
|
providerExecuted: true
|
|
3116
3135
|
});
|
|
3117
3136
|
} else if (value.item.type === "computer_call") {
|
|
@@ -3178,7 +3197,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3178
3197
|
providerMetadata: {
|
|
3179
3198
|
openai: {
|
|
3180
3199
|
itemId: value.item.id,
|
|
3181
|
-
reasoningEncryptedContent: (
|
|
3200
|
+
reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
|
|
3182
3201
|
}
|
|
3183
3202
|
}
|
|
3184
3203
|
});
|
|
@@ -3213,7 +3232,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3213
3232
|
}
|
|
3214
3233
|
} else if (isResponseReasoningSummaryPartAddedChunk(value)) {
|
|
3215
3234
|
if (value.summary_index > 0) {
|
|
3216
|
-
(
|
|
3235
|
+
(_c = activeReasoning[value.item_id]) == null ? void 0 : _c.summaryParts.push(
|
|
3217
3236
|
value.summary_index
|
|
3218
3237
|
);
|
|
3219
3238
|
controller.enqueue({
|
|
@@ -3222,7 +3241,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3222
3241
|
providerMetadata: {
|
|
3223
3242
|
openai: {
|
|
3224
3243
|
itemId: value.item_id,
|
|
3225
|
-
reasoningEncryptedContent: (
|
|
3244
|
+
reasoningEncryptedContent: (_e = (_d = activeReasoning[value.item_id]) == null ? void 0 : _d.encryptedContent) != null ? _e : null
|
|
3226
3245
|
}
|
|
3227
3246
|
}
|
|
3228
3247
|
});
|
|
@@ -3240,20 +3259,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3240
3259
|
});
|
|
3241
3260
|
} else if (isResponseFinishedChunk(value)) {
|
|
3242
3261
|
finishReason = mapOpenAIResponseFinishReason({
|
|
3243
|
-
finishReason: (
|
|
3262
|
+
finishReason: (_f = value.response.incomplete_details) == null ? void 0 : _f.reason,
|
|
3244
3263
|
hasToolCalls
|
|
3245
3264
|
});
|
|
3246
3265
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
3247
3266
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
3248
3267
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
3249
|
-
usage.reasoningTokens = (
|
|
3250
|
-
usage.cachedInputTokens = (
|
|
3268
|
+
usage.reasoningTokens = (_h = (_g = value.response.usage.output_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : void 0;
|
|
3269
|
+
usage.cachedInputTokens = (_j = (_i = value.response.usage.input_tokens_details) == null ? void 0 : _i.cached_tokens) != null ? _j : void 0;
|
|
3251
3270
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
3252
3271
|
if (value.annotation.type === "url_citation") {
|
|
3253
3272
|
controller.enqueue({
|
|
3254
3273
|
type: "source",
|
|
3255
3274
|
sourceType: "url",
|
|
3256
|
-
id: (
|
|
3275
|
+
id: (_m = (_l = (_k = self.config).generateId) == null ? void 0 : _l.call(_k)) != null ? _m : generateId2(),
|
|
3257
3276
|
url: value.annotation.url,
|
|
3258
3277
|
title: value.annotation.title
|
|
3259
3278
|
});
|
|
@@ -3261,7 +3280,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3261
3280
|
controller.enqueue({
|
|
3262
3281
|
type: "source",
|
|
3263
3282
|
sourceType: "document",
|
|
3264
|
-
id: (
|
|
3283
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : generateId2(),
|
|
3265
3284
|
mediaType: "text/plain",
|
|
3266
3285
|
title: value.annotation.quote,
|
|
3267
3286
|
filename: value.annotation.file_id
|
|
@@ -3401,15 +3420,7 @@ var responseOutputItemDoneSchema = z16.object({
|
|
|
3401
3420
|
arguments: z16.string(),
|
|
3402
3421
|
status: z16.literal("completed")
|
|
3403
3422
|
}),
|
|
3404
|
-
|
|
3405
|
-
type: z16.literal("web_search_call"),
|
|
3406
|
-
id: z16.string(),
|
|
3407
|
-
status: z16.literal("completed"),
|
|
3408
|
-
action: z16.object({
|
|
3409
|
-
type: z16.literal("search"),
|
|
3410
|
-
query: z16.string().optional()
|
|
3411
|
-
}).nullish()
|
|
3412
|
-
}),
|
|
3423
|
+
webSearchCallItem,
|
|
3413
3424
|
z16.object({
|
|
3414
3425
|
type: z16.literal("computer_call"),
|
|
3415
3426
|
id: z16.string(),
|