@ai-sdk/openai 3.0.0-beta.28 → 3.0.0-beta.29
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.mjs
CHANGED
|
@@ -2375,6 +2375,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2375
2375
|
input.push(reasoningMessages[reasoningId]);
|
|
2376
2376
|
} else {
|
|
2377
2377
|
reasoningMessage.summary.push(...summaryParts);
|
|
2378
|
+
if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
|
|
2379
|
+
reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
|
|
2380
|
+
}
|
|
2378
2381
|
}
|
|
2379
2382
|
}
|
|
2380
2383
|
} else {
|
|
@@ -2720,6 +2723,11 @@ var openaiResponsesChunkSchema = lazySchema12(
|
|
|
2720
2723
|
summary_index: z14.number(),
|
|
2721
2724
|
delta: z14.string()
|
|
2722
2725
|
}),
|
|
2726
|
+
z14.object({
|
|
2727
|
+
type: z14.literal("response.reasoning_summary_part.done"),
|
|
2728
|
+
item_id: z14.string(),
|
|
2729
|
+
summary_index: z14.number()
|
|
2730
|
+
}),
|
|
2723
2731
|
z14.object({
|
|
2724
2732
|
type: z14.literal("error"),
|
|
2725
2733
|
code: z14.string(),
|
|
@@ -3605,7 +3613,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3605
3613
|
tools: openaiTools,
|
|
3606
3614
|
tool_choice: openaiToolChoice
|
|
3607
3615
|
},
|
|
3608
|
-
warnings: [...warnings, ...toolWarnings]
|
|
3616
|
+
warnings: [...warnings, ...toolWarnings],
|
|
3617
|
+
store
|
|
3609
3618
|
};
|
|
3610
3619
|
}
|
|
3611
3620
|
async doGenerate(options) {
|
|
@@ -3880,7 +3889,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3880
3889
|
const {
|
|
3881
3890
|
args: body,
|
|
3882
3891
|
warnings,
|
|
3883
|
-
webSearchToolName
|
|
3892
|
+
webSearchToolName,
|
|
3893
|
+
store
|
|
3884
3894
|
} = await this.getArgs(options);
|
|
3885
3895
|
const { responseHeaders, value: response } = await postJsonToApi6({
|
|
3886
3896
|
url: this.config.url({
|
|
@@ -3919,7 +3929,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3919
3929
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3920
3930
|
},
|
|
3921
3931
|
transform(chunk, controller) {
|
|
3922
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v
|
|
3932
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3923
3933
|
if (options.includeRawChunks) {
|
|
3924
3934
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3925
3935
|
}
|
|
@@ -4018,10 +4028,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4018
4028
|
}
|
|
4019
4029
|
}
|
|
4020
4030
|
});
|
|
4021
|
-
} else if (
|
|
4031
|
+
} else if (isResponseOutputItemAddedChunk(value) && value.item.type === "reasoning") {
|
|
4022
4032
|
activeReasoning[value.item.id] = {
|
|
4023
4033
|
encryptedContent: value.item.encrypted_content,
|
|
4024
|
-
summaryParts:
|
|
4034
|
+
summaryParts: { 0: "active" }
|
|
4025
4035
|
};
|
|
4026
4036
|
controller.enqueue({
|
|
4027
4037
|
type: "reasoning-start",
|
|
@@ -4149,9 +4159,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4149
4159
|
type: "text-end",
|
|
4150
4160
|
id: value.item.id
|
|
4151
4161
|
});
|
|
4152
|
-
} else if (
|
|
4162
|
+
} else if (value.item.type === "reasoning") {
|
|
4153
4163
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
4154
|
-
|
|
4164
|
+
const summaryPartIndices = Object.entries(
|
|
4165
|
+
activeReasoningPart.summaryParts
|
|
4166
|
+
).filter(
|
|
4167
|
+
([_, status]) => status === "active" || status === "can-conclude"
|
|
4168
|
+
).map(([summaryIndex]) => summaryIndex);
|
|
4169
|
+
for (const summaryIndex of summaryPartIndices) {
|
|
4155
4170
|
controller.enqueue({
|
|
4156
4171
|
type: "reasoning-end",
|
|
4157
4172
|
id: `${value.item.id}:${summaryIndex}`,
|
|
@@ -4236,23 +4251,34 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4236
4251
|
if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
|
|
4237
4252
|
logprobs.push(value.logprobs);
|
|
4238
4253
|
}
|
|
4239
|
-
} else if (
|
|
4254
|
+
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
4240
4255
|
if (value.summary_index > 0) {
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4256
|
+
const activeReasoningPart = activeReasoning[value.item_id];
|
|
4257
|
+
activeReasoningPart.summaryParts[value.summary_index] = "active";
|
|
4258
|
+
for (const summaryIndex of Object.keys(
|
|
4259
|
+
activeReasoningPart.summaryParts
|
|
4260
|
+
)) {
|
|
4261
|
+
if (activeReasoningPart.summaryParts[summaryIndex] === "can-conclude") {
|
|
4262
|
+
controller.enqueue({
|
|
4263
|
+
type: "reasoning-end",
|
|
4264
|
+
id: `${value.item_id}:${summaryIndex}`,
|
|
4265
|
+
providerMetadata: { openai: { itemId: value.item_id } }
|
|
4266
|
+
});
|
|
4267
|
+
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
4268
|
+
}
|
|
4269
|
+
}
|
|
4244
4270
|
controller.enqueue({
|
|
4245
4271
|
type: "reasoning-start",
|
|
4246
4272
|
id: `${value.item_id}:${value.summary_index}`,
|
|
4247
4273
|
providerMetadata: {
|
|
4248
4274
|
openai: {
|
|
4249
4275
|
itemId: value.item_id,
|
|
4250
|
-
reasoningEncryptedContent: (
|
|
4276
|
+
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
|
|
4251
4277
|
}
|
|
4252
4278
|
}
|
|
4253
4279
|
});
|
|
4254
4280
|
}
|
|
4255
|
-
} else if (
|
|
4281
|
+
} else if (value.type === "response.reasoning_summary_text.delta") {
|
|
4256
4282
|
controller.enqueue({
|
|
4257
4283
|
type: "reasoning-delta",
|
|
4258
4284
|
id: `${value.item_id}:${value.summary_index}`,
|
|
@@ -4263,16 +4289,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4263
4289
|
}
|
|
4264
4290
|
}
|
|
4265
4291
|
});
|
|
4292
|
+
} else if (value.type === "response.reasoning_summary_part.done") {
|
|
4293
|
+
if (store) {
|
|
4294
|
+
controller.enqueue({
|
|
4295
|
+
type: "reasoning-end",
|
|
4296
|
+
id: `${value.item_id}:${value.summary_index}`,
|
|
4297
|
+
providerMetadata: {
|
|
4298
|
+
openai: { itemId: value.item_id }
|
|
4299
|
+
}
|
|
4300
|
+
});
|
|
4301
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
|
|
4302
|
+
} else {
|
|
4303
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
|
|
4304
|
+
}
|
|
4266
4305
|
} else if (isResponseFinishedChunk(value)) {
|
|
4267
4306
|
finishReason = mapOpenAIResponseFinishReason({
|
|
4268
|
-
finishReason: (
|
|
4307
|
+
finishReason: (_i = value.response.incomplete_details) == null ? void 0 : _i.reason,
|
|
4269
4308
|
hasFunctionCall
|
|
4270
4309
|
});
|
|
4271
4310
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
4272
4311
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
4273
4312
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
4274
|
-
usage.reasoningTokens = (
|
|
4275
|
-
usage.cachedInputTokens = (
|
|
4313
|
+
usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? void 0 : _j.reasoning_tokens) != null ? _k : void 0;
|
|
4314
|
+
usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? void 0 : _l.cached_tokens) != null ? _m : void 0;
|
|
4276
4315
|
if (typeof value.response.service_tier === "string") {
|
|
4277
4316
|
serviceTier = value.response.service_tier;
|
|
4278
4317
|
}
|
|
@@ -4281,7 +4320,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4281
4320
|
controller.enqueue({
|
|
4282
4321
|
type: "source",
|
|
4283
4322
|
sourceType: "url",
|
|
4284
|
-
id: (
|
|
4323
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : generateId2(),
|
|
4285
4324
|
url: value.annotation.url,
|
|
4286
4325
|
title: value.annotation.title
|
|
4287
4326
|
});
|
|
@@ -4289,10 +4328,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4289
4328
|
controller.enqueue({
|
|
4290
4329
|
type: "source",
|
|
4291
4330
|
sourceType: "document",
|
|
4292
|
-
id: (
|
|
4331
|
+
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : generateId2(),
|
|
4293
4332
|
mediaType: "text/plain",
|
|
4294
|
-
title: (
|
|
4295
|
-
filename: (
|
|
4333
|
+
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
4334
|
+
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id
|
|
4296
4335
|
});
|
|
4297
4336
|
}
|
|
4298
4337
|
} else if (isErrorChunk(value)) {
|
|
@@ -4331,9 +4370,6 @@ function isTextDeltaChunk(chunk) {
|
|
|
4331
4370
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
4332
4371
|
return chunk.type === "response.output_item.done";
|
|
4333
4372
|
}
|
|
4334
|
-
function isResponseOutputItemDoneReasoningChunk(chunk) {
|
|
4335
|
-
return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
|
|
4336
|
-
}
|
|
4337
4373
|
function isResponseFinishedChunk(chunk) {
|
|
4338
4374
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
4339
4375
|
}
|
|
@@ -4355,18 +4391,9 @@ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
|
4355
4391
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
4356
4392
|
return chunk.type === "response.output_item.added";
|
|
4357
4393
|
}
|
|
4358
|
-
function isResponseOutputItemAddedReasoningChunk(chunk) {
|
|
4359
|
-
return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
|
|
4360
|
-
}
|
|
4361
4394
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
4362
4395
|
return chunk.type === "response.output_text.annotation.added";
|
|
4363
4396
|
}
|
|
4364
|
-
function isResponseReasoningSummaryPartAddedChunk(chunk) {
|
|
4365
|
-
return chunk.type === "response.reasoning_summary_part.added";
|
|
4366
|
-
}
|
|
4367
|
-
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
4368
|
-
return chunk.type === "response.reasoning_summary_text.delta";
|
|
4369
|
-
}
|
|
4370
4397
|
function isErrorChunk(chunk) {
|
|
4371
4398
|
return chunk.type === "error";
|
|
4372
4399
|
}
|