@ai-sdk/openai 2.0.51 → 2.0.52
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 +60 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -33
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +59 -32
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +59 -32
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.js
CHANGED
|
@@ -2356,6 +2356,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2356
2356
|
input.push(reasoningMessages[reasoningId]);
|
|
2357
2357
|
} else {
|
|
2358
2358
|
reasoningMessage.summary.push(...summaryParts);
|
|
2359
|
+
if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
|
|
2360
|
+
reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
|
|
2361
|
+
}
|
|
2359
2362
|
}
|
|
2360
2363
|
}
|
|
2361
2364
|
} else {
|
|
@@ -2698,6 +2701,11 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazyValidator)(
|
|
|
2698
2701
|
summary_index: import_v414.z.number(),
|
|
2699
2702
|
delta: import_v414.z.string()
|
|
2700
2703
|
}),
|
|
2704
|
+
import_v414.z.object({
|
|
2705
|
+
type: import_v414.z.literal("response.reasoning_summary_part.done"),
|
|
2706
|
+
item_id: import_v414.z.string(),
|
|
2707
|
+
summary_index: import_v414.z.number()
|
|
2708
|
+
}),
|
|
2701
2709
|
import_v414.z.object({
|
|
2702
2710
|
type: import_v414.z.literal("error"),
|
|
2703
2711
|
code: import_v414.z.string(),
|
|
@@ -3560,7 +3568,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3560
3568
|
tools: openaiTools,
|
|
3561
3569
|
tool_choice: openaiToolChoice
|
|
3562
3570
|
},
|
|
3563
|
-
warnings: [...warnings, ...toolWarnings]
|
|
3571
|
+
warnings: [...warnings, ...toolWarnings],
|
|
3572
|
+
store
|
|
3564
3573
|
};
|
|
3565
3574
|
}
|
|
3566
3575
|
async doGenerate(options) {
|
|
@@ -3835,7 +3844,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3835
3844
|
const {
|
|
3836
3845
|
args: body,
|
|
3837
3846
|
warnings,
|
|
3838
|
-
webSearchToolName
|
|
3847
|
+
webSearchToolName,
|
|
3848
|
+
store
|
|
3839
3849
|
} = await this.getArgs(options);
|
|
3840
3850
|
const { responseHeaders, value: response } = await (0, import_provider_utils29.postJsonToApi)({
|
|
3841
3851
|
url: this.config.url({
|
|
@@ -3874,7 +3884,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3874
3884
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3875
3885
|
},
|
|
3876
3886
|
transform(chunk, controller) {
|
|
3877
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v
|
|
3887
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3878
3888
|
if (options.includeRawChunks) {
|
|
3879
3889
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3880
3890
|
}
|
|
@@ -3973,10 +3983,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3973
3983
|
}
|
|
3974
3984
|
}
|
|
3975
3985
|
});
|
|
3976
|
-
} else if (
|
|
3986
|
+
} else if (isResponseOutputItemAddedChunk(value) && value.item.type === "reasoning") {
|
|
3977
3987
|
activeReasoning[value.item.id] = {
|
|
3978
3988
|
encryptedContent: value.item.encrypted_content,
|
|
3979
|
-
summaryParts:
|
|
3989
|
+
summaryParts: { 0: "active" }
|
|
3980
3990
|
};
|
|
3981
3991
|
controller.enqueue({
|
|
3982
3992
|
type: "reasoning-start",
|
|
@@ -4104,9 +4114,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4104
4114
|
type: "text-end",
|
|
4105
4115
|
id: value.item.id
|
|
4106
4116
|
});
|
|
4107
|
-
} else if (
|
|
4117
|
+
} else if (value.item.type === "reasoning") {
|
|
4108
4118
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
4109
|
-
|
|
4119
|
+
const summaryPartIndices = Object.entries(
|
|
4120
|
+
activeReasoningPart.summaryParts
|
|
4121
|
+
).filter(
|
|
4122
|
+
([_, status]) => status === "active" || status === "can-conclude"
|
|
4123
|
+
).map(([summaryIndex]) => summaryIndex);
|
|
4124
|
+
for (const summaryIndex of summaryPartIndices) {
|
|
4110
4125
|
controller.enqueue({
|
|
4111
4126
|
type: "reasoning-end",
|
|
4112
4127
|
id: `${value.item.id}:${summaryIndex}`,
|
|
@@ -4180,23 +4195,34 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4180
4195
|
if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
|
|
4181
4196
|
logprobs.push(value.logprobs);
|
|
4182
4197
|
}
|
|
4183
|
-
} else if (
|
|
4198
|
+
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
4184
4199
|
if (value.summary_index > 0) {
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4200
|
+
const activeReasoningPart = activeReasoning[value.item_id];
|
|
4201
|
+
activeReasoningPart.summaryParts[value.summary_index] = "active";
|
|
4202
|
+
for (const summaryIndex of Object.keys(
|
|
4203
|
+
activeReasoningPart.summaryParts
|
|
4204
|
+
)) {
|
|
4205
|
+
if (activeReasoningPart.summaryParts[summaryIndex] === "can-conclude") {
|
|
4206
|
+
controller.enqueue({
|
|
4207
|
+
type: "reasoning-end",
|
|
4208
|
+
id: `${value.item_id}:${summaryIndex}`,
|
|
4209
|
+
providerMetadata: { openai: { itemId: value.item_id } }
|
|
4210
|
+
});
|
|
4211
|
+
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4188
4214
|
controller.enqueue({
|
|
4189
4215
|
type: "reasoning-start",
|
|
4190
4216
|
id: `${value.item_id}:${value.summary_index}`,
|
|
4191
4217
|
providerMetadata: {
|
|
4192
4218
|
openai: {
|
|
4193
4219
|
itemId: value.item_id,
|
|
4194
|
-
reasoningEncryptedContent: (
|
|
4220
|
+
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
|
|
4195
4221
|
}
|
|
4196
4222
|
}
|
|
4197
4223
|
});
|
|
4198
4224
|
}
|
|
4199
|
-
} else if (
|
|
4225
|
+
} else if (value.type === "response.reasoning_summary_text.delta") {
|
|
4200
4226
|
controller.enqueue({
|
|
4201
4227
|
type: "reasoning-delta",
|
|
4202
4228
|
id: `${value.item_id}:${value.summary_index}`,
|
|
@@ -4207,16 +4233,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4207
4233
|
}
|
|
4208
4234
|
}
|
|
4209
4235
|
});
|
|
4236
|
+
} else if (value.type === "response.reasoning_summary_part.done") {
|
|
4237
|
+
if (store) {
|
|
4238
|
+
controller.enqueue({
|
|
4239
|
+
type: "reasoning-end",
|
|
4240
|
+
id: `${value.item_id}:${value.summary_index}`,
|
|
4241
|
+
providerMetadata: {
|
|
4242
|
+
openai: { itemId: value.item_id }
|
|
4243
|
+
}
|
|
4244
|
+
});
|
|
4245
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
|
|
4246
|
+
} else {
|
|
4247
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
|
|
4248
|
+
}
|
|
4210
4249
|
} else if (isResponseFinishedChunk(value)) {
|
|
4211
4250
|
finishReason = mapOpenAIResponseFinishReason({
|
|
4212
|
-
finishReason: (
|
|
4251
|
+
finishReason: (_i = value.response.incomplete_details) == null ? void 0 : _i.reason,
|
|
4213
4252
|
hasFunctionCall
|
|
4214
4253
|
});
|
|
4215
4254
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
4216
4255
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
4217
4256
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
4218
|
-
usage.reasoningTokens = (
|
|
4219
|
-
usage.cachedInputTokens = (
|
|
4257
|
+
usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? void 0 : _j.reasoning_tokens) != null ? _k : void 0;
|
|
4258
|
+
usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? void 0 : _l.cached_tokens) != null ? _m : void 0;
|
|
4220
4259
|
if (typeof value.response.service_tier === "string") {
|
|
4221
4260
|
serviceTier = value.response.service_tier;
|
|
4222
4261
|
}
|
|
@@ -4225,7 +4264,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4225
4264
|
controller.enqueue({
|
|
4226
4265
|
type: "source",
|
|
4227
4266
|
sourceType: "url",
|
|
4228
|
-
id: (
|
|
4267
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : (0, import_provider_utils29.generateId)(),
|
|
4229
4268
|
url: value.annotation.url,
|
|
4230
4269
|
title: value.annotation.title
|
|
4231
4270
|
});
|
|
@@ -4233,10 +4272,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4233
4272
|
controller.enqueue({
|
|
4234
4273
|
type: "source",
|
|
4235
4274
|
sourceType: "document",
|
|
4236
|
-
id: (
|
|
4275
|
+
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : (0, import_provider_utils29.generateId)(),
|
|
4237
4276
|
mediaType: "text/plain",
|
|
4238
|
-
title: (
|
|
4239
|
-
filename: (
|
|
4277
|
+
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
4278
|
+
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id
|
|
4240
4279
|
});
|
|
4241
4280
|
}
|
|
4242
4281
|
} else if (isErrorChunk(value)) {
|
|
@@ -4275,9 +4314,6 @@ function isTextDeltaChunk(chunk) {
|
|
|
4275
4314
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
4276
4315
|
return chunk.type === "response.output_item.done";
|
|
4277
4316
|
}
|
|
4278
|
-
function isResponseOutputItemDoneReasoningChunk(chunk) {
|
|
4279
|
-
return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
|
|
4280
|
-
}
|
|
4281
4317
|
function isResponseFinishedChunk(chunk) {
|
|
4282
4318
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
4283
4319
|
}
|
|
@@ -4296,18 +4332,9 @@ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
|
4296
4332
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
4297
4333
|
return chunk.type === "response.output_item.added";
|
|
4298
4334
|
}
|
|
4299
|
-
function isResponseOutputItemAddedReasoningChunk(chunk) {
|
|
4300
|
-
return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
|
|
4301
|
-
}
|
|
4302
4335
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
4303
4336
|
return chunk.type === "response.output_text.annotation.added";
|
|
4304
4337
|
}
|
|
4305
|
-
function isResponseReasoningSummaryPartAddedChunk(chunk) {
|
|
4306
|
-
return chunk.type === "response.reasoning_summary_part.added";
|
|
4307
|
-
}
|
|
4308
|
-
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
4309
|
-
return chunk.type === "response.reasoning_summary_text.delta";
|
|
4310
|
-
}
|
|
4311
4338
|
function isErrorChunk(chunk) {
|
|
4312
4339
|
return chunk.type === "error";
|
|
4313
4340
|
}
|