@ai-sdk/openai 3.0.0-beta.28 → 3.0.0-beta.30
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 +13 -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 +2 -2
package/dist/internal/index.js
CHANGED
|
@@ -2360,6 +2360,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2360
2360
|
input.push(reasoningMessages[reasoningId]);
|
|
2361
2361
|
} else {
|
|
2362
2362
|
reasoningMessage.summary.push(...summaryParts);
|
|
2363
|
+
if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
|
|
2364
|
+
reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
|
|
2365
|
+
}
|
|
2363
2366
|
}
|
|
2364
2367
|
}
|
|
2365
2368
|
} else {
|
|
@@ -2705,6 +2708,11 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2705
2708
|
summary_index: import_v414.z.number(),
|
|
2706
2709
|
delta: import_v414.z.string()
|
|
2707
2710
|
}),
|
|
2711
|
+
import_v414.z.object({
|
|
2712
|
+
type: import_v414.z.literal("response.reasoning_summary_part.done"),
|
|
2713
|
+
item_id: import_v414.z.string(),
|
|
2714
|
+
summary_index: import_v414.z.number()
|
|
2715
|
+
}),
|
|
2708
2716
|
import_v414.z.object({
|
|
2709
2717
|
type: import_v414.z.literal("error"),
|
|
2710
2718
|
code: import_v414.z.string(),
|
|
@@ -3568,7 +3576,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3568
3576
|
tools: openaiTools,
|
|
3569
3577
|
tool_choice: openaiToolChoice
|
|
3570
3578
|
},
|
|
3571
|
-
warnings: [...warnings, ...toolWarnings]
|
|
3579
|
+
warnings: [...warnings, ...toolWarnings],
|
|
3580
|
+
store
|
|
3572
3581
|
};
|
|
3573
3582
|
}
|
|
3574
3583
|
async doGenerate(options) {
|
|
@@ -3843,7 +3852,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3843
3852
|
const {
|
|
3844
3853
|
args: body,
|
|
3845
3854
|
warnings,
|
|
3846
|
-
webSearchToolName
|
|
3855
|
+
webSearchToolName,
|
|
3856
|
+
store
|
|
3847
3857
|
} = await this.getArgs(options);
|
|
3848
3858
|
const { responseHeaders, value: response } = await (0, import_provider_utils29.postJsonToApi)({
|
|
3849
3859
|
url: this.config.url({
|
|
@@ -3882,7 +3892,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3882
3892
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3883
3893
|
},
|
|
3884
3894
|
transform(chunk, controller) {
|
|
3885
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v
|
|
3895
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3886
3896
|
if (options.includeRawChunks) {
|
|
3887
3897
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3888
3898
|
}
|
|
@@ -3981,10 +3991,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3981
3991
|
}
|
|
3982
3992
|
}
|
|
3983
3993
|
});
|
|
3984
|
-
} else if (
|
|
3994
|
+
} else if (isResponseOutputItemAddedChunk(value) && value.item.type === "reasoning") {
|
|
3985
3995
|
activeReasoning[value.item.id] = {
|
|
3986
3996
|
encryptedContent: value.item.encrypted_content,
|
|
3987
|
-
summaryParts:
|
|
3997
|
+
summaryParts: { 0: "active" }
|
|
3988
3998
|
};
|
|
3989
3999
|
controller.enqueue({
|
|
3990
4000
|
type: "reasoning-start",
|
|
@@ -4112,9 +4122,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4112
4122
|
type: "text-end",
|
|
4113
4123
|
id: value.item.id
|
|
4114
4124
|
});
|
|
4115
|
-
} else if (
|
|
4125
|
+
} else if (value.item.type === "reasoning") {
|
|
4116
4126
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
4117
|
-
|
|
4127
|
+
const summaryPartIndices = Object.entries(
|
|
4128
|
+
activeReasoningPart.summaryParts
|
|
4129
|
+
).filter(
|
|
4130
|
+
([_, status]) => status === "active" || status === "can-conclude"
|
|
4131
|
+
).map(([summaryIndex]) => summaryIndex);
|
|
4132
|
+
for (const summaryIndex of summaryPartIndices) {
|
|
4118
4133
|
controller.enqueue({
|
|
4119
4134
|
type: "reasoning-end",
|
|
4120
4135
|
id: `${value.item.id}:${summaryIndex}`,
|
|
@@ -4199,23 +4214,34 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4199
4214
|
if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
|
|
4200
4215
|
logprobs.push(value.logprobs);
|
|
4201
4216
|
}
|
|
4202
|
-
} else if (
|
|
4217
|
+
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
4203
4218
|
if (value.summary_index > 0) {
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4219
|
+
const activeReasoningPart = activeReasoning[value.item_id];
|
|
4220
|
+
activeReasoningPart.summaryParts[value.summary_index] = "active";
|
|
4221
|
+
for (const summaryIndex of Object.keys(
|
|
4222
|
+
activeReasoningPart.summaryParts
|
|
4223
|
+
)) {
|
|
4224
|
+
if (activeReasoningPart.summaryParts[summaryIndex] === "can-conclude") {
|
|
4225
|
+
controller.enqueue({
|
|
4226
|
+
type: "reasoning-end",
|
|
4227
|
+
id: `${value.item_id}:${summaryIndex}`,
|
|
4228
|
+
providerMetadata: { openai: { itemId: value.item_id } }
|
|
4229
|
+
});
|
|
4230
|
+
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4207
4233
|
controller.enqueue({
|
|
4208
4234
|
type: "reasoning-start",
|
|
4209
4235
|
id: `${value.item_id}:${value.summary_index}`,
|
|
4210
4236
|
providerMetadata: {
|
|
4211
4237
|
openai: {
|
|
4212
4238
|
itemId: value.item_id,
|
|
4213
|
-
reasoningEncryptedContent: (
|
|
4239
|
+
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
|
|
4214
4240
|
}
|
|
4215
4241
|
}
|
|
4216
4242
|
});
|
|
4217
4243
|
}
|
|
4218
|
-
} else if (
|
|
4244
|
+
} else if (value.type === "response.reasoning_summary_text.delta") {
|
|
4219
4245
|
controller.enqueue({
|
|
4220
4246
|
type: "reasoning-delta",
|
|
4221
4247
|
id: `${value.item_id}:${value.summary_index}`,
|
|
@@ -4226,16 +4252,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4226
4252
|
}
|
|
4227
4253
|
}
|
|
4228
4254
|
});
|
|
4255
|
+
} else if (value.type === "response.reasoning_summary_part.done") {
|
|
4256
|
+
if (store) {
|
|
4257
|
+
controller.enqueue({
|
|
4258
|
+
type: "reasoning-end",
|
|
4259
|
+
id: `${value.item_id}:${value.summary_index}`,
|
|
4260
|
+
providerMetadata: {
|
|
4261
|
+
openai: { itemId: value.item_id }
|
|
4262
|
+
}
|
|
4263
|
+
});
|
|
4264
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
|
|
4265
|
+
} else {
|
|
4266
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
|
|
4267
|
+
}
|
|
4229
4268
|
} else if (isResponseFinishedChunk(value)) {
|
|
4230
4269
|
finishReason = mapOpenAIResponseFinishReason({
|
|
4231
|
-
finishReason: (
|
|
4270
|
+
finishReason: (_i = value.response.incomplete_details) == null ? void 0 : _i.reason,
|
|
4232
4271
|
hasFunctionCall
|
|
4233
4272
|
});
|
|
4234
4273
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
4235
4274
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
4236
4275
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
4237
|
-
usage.reasoningTokens = (
|
|
4238
|
-
usage.cachedInputTokens = (
|
|
4276
|
+
usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? void 0 : _j.reasoning_tokens) != null ? _k : void 0;
|
|
4277
|
+
usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? void 0 : _l.cached_tokens) != null ? _m : void 0;
|
|
4239
4278
|
if (typeof value.response.service_tier === "string") {
|
|
4240
4279
|
serviceTier = value.response.service_tier;
|
|
4241
4280
|
}
|
|
@@ -4244,7 +4283,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4244
4283
|
controller.enqueue({
|
|
4245
4284
|
type: "source",
|
|
4246
4285
|
sourceType: "url",
|
|
4247
|
-
id: (
|
|
4286
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : (0, import_provider_utils29.generateId)(),
|
|
4248
4287
|
url: value.annotation.url,
|
|
4249
4288
|
title: value.annotation.title
|
|
4250
4289
|
});
|
|
@@ -4252,10 +4291,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4252
4291
|
controller.enqueue({
|
|
4253
4292
|
type: "source",
|
|
4254
4293
|
sourceType: "document",
|
|
4255
|
-
id: (
|
|
4294
|
+
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : (0, import_provider_utils29.generateId)(),
|
|
4256
4295
|
mediaType: "text/plain",
|
|
4257
|
-
title: (
|
|
4258
|
-
filename: (
|
|
4296
|
+
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
4297
|
+
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id
|
|
4259
4298
|
});
|
|
4260
4299
|
}
|
|
4261
4300
|
} else if (isErrorChunk(value)) {
|
|
@@ -4294,9 +4333,6 @@ function isTextDeltaChunk(chunk) {
|
|
|
4294
4333
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
4295
4334
|
return chunk.type === "response.output_item.done";
|
|
4296
4335
|
}
|
|
4297
|
-
function isResponseOutputItemDoneReasoningChunk(chunk) {
|
|
4298
|
-
return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
|
|
4299
|
-
}
|
|
4300
4336
|
function isResponseFinishedChunk(chunk) {
|
|
4301
4337
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
4302
4338
|
}
|
|
@@ -4318,18 +4354,9 @@ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
|
4318
4354
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
4319
4355
|
return chunk.type === "response.output_item.added";
|
|
4320
4356
|
}
|
|
4321
|
-
function isResponseOutputItemAddedReasoningChunk(chunk) {
|
|
4322
|
-
return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
|
|
4323
|
-
}
|
|
4324
4357
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
4325
4358
|
return chunk.type === "response.output_text.annotation.added";
|
|
4326
4359
|
}
|
|
4327
|
-
function isResponseReasoningSummaryPartAddedChunk(chunk) {
|
|
4328
|
-
return chunk.type === "response.reasoning_summary_part.added";
|
|
4329
|
-
}
|
|
4330
|
-
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
4331
|
-
return chunk.type === "response.reasoning_summary_text.delta";
|
|
4332
|
-
}
|
|
4333
4360
|
function isErrorChunk(chunk) {
|
|
4334
4361
|
return chunk.type === "error";
|
|
4335
4362
|
}
|