@ai-sdk/openai 2.0.95 → 2.0.97
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 +14 -0
- package/dist/index.js +36 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -22
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +35 -21
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +35 -21
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -2247,7 +2247,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2247
2247
|
store,
|
|
2248
2248
|
hasLocalShellTool = false
|
|
2249
2249
|
}) {
|
|
2250
|
-
var _a, _b, _c, _d;
|
|
2250
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2251
2251
|
const input = [];
|
|
2252
2252
|
const warnings = [];
|
|
2253
2253
|
for (const { role, content } of prompt) {
|
|
@@ -2329,6 +2329,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2329
2329
|
switch (part.type) {
|
|
2330
2330
|
case "text": {
|
|
2331
2331
|
const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId;
|
|
2332
|
+
const phase = (_d = (_c = part.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.phase;
|
|
2332
2333
|
if (store && id != null) {
|
|
2333
2334
|
input.push({ type: "item_reference", id });
|
|
2334
2335
|
break;
|
|
@@ -2336,7 +2337,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
2336
2337
|
input.push({
|
|
2337
2338
|
role: "assistant",
|
|
2338
2339
|
content: [{ type: "output_text", text: part.text }],
|
|
2339
|
-
id
|
|
2340
|
+
id,
|
|
2341
|
+
...phase != null && { phase }
|
|
2340
2342
|
});
|
|
2341
2343
|
break;
|
|
2342
2344
|
}
|
|
@@ -2345,7 +2347,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2345
2347
|
if (part.providerExecuted) {
|
|
2346
2348
|
break;
|
|
2347
2349
|
}
|
|
2348
|
-
const id = (
|
|
2350
|
+
const id = (_f = (_e = part.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.itemId;
|
|
2349
2351
|
if (store && id != null) {
|
|
2350
2352
|
input.push({ type: "item_reference", id });
|
|
2351
2353
|
break;
|
|
@@ -2587,7 +2589,8 @@ var openaiResponsesChunkSchema = lazyValidator11(
|
|
|
2587
2589
|
item: z14.discriminatedUnion("type", [
|
|
2588
2590
|
z14.object({
|
|
2589
2591
|
type: z14.literal("message"),
|
|
2590
|
-
id: z14.string()
|
|
2592
|
+
id: z14.string(),
|
|
2593
|
+
phase: z14.enum(["commentary", "final_answer"]).nullish()
|
|
2591
2594
|
}),
|
|
2592
2595
|
z14.object({
|
|
2593
2596
|
type: z14.literal("reasoning"),
|
|
@@ -2640,7 +2643,8 @@ var openaiResponsesChunkSchema = lazyValidator11(
|
|
|
2640
2643
|
item: z14.discriminatedUnion("type", [
|
|
2641
2644
|
z14.object({
|
|
2642
2645
|
type: z14.literal("message"),
|
|
2643
|
-
id: z14.string()
|
|
2646
|
+
id: z14.string(),
|
|
2647
|
+
phase: z14.enum(["commentary", "final_answer"]).nullish()
|
|
2644
2648
|
}),
|
|
2645
2649
|
z14.object({
|
|
2646
2650
|
type: z14.literal("reasoning"),
|
|
@@ -2829,6 +2833,7 @@ var openaiResponsesResponseSchema = lazyValidator11(
|
|
|
2829
2833
|
type: z14.literal("message"),
|
|
2830
2834
|
role: z14.literal("assistant"),
|
|
2831
2835
|
id: z14.string(),
|
|
2836
|
+
phase: z14.enum(["commentary", "final_answer"]).nullish(),
|
|
2832
2837
|
content: z14.array(
|
|
2833
2838
|
z14.object({
|
|
2834
2839
|
type: z14.literal("output_text"),
|
|
@@ -3870,7 +3875,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3870
3875
|
text: contentPart.text,
|
|
3871
3876
|
providerMetadata: {
|
|
3872
3877
|
[providerKey]: {
|
|
3873
|
-
itemId: part.id
|
|
3878
|
+
itemId: part.id,
|
|
3879
|
+
...part.phase != null && { phase: part.phase }
|
|
3874
3880
|
}
|
|
3875
3881
|
}
|
|
3876
3882
|
});
|
|
@@ -4110,6 +4116,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4110
4116
|
let responseId = null;
|
|
4111
4117
|
const ongoingToolCalls = {};
|
|
4112
4118
|
const ongoingAnnotations = [];
|
|
4119
|
+
let activeMessagePhase;
|
|
4113
4120
|
let hasFunctionCall = false;
|
|
4114
4121
|
const activeReasoning = {};
|
|
4115
4122
|
let serviceTier;
|
|
@@ -4120,7 +4127,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4120
4127
|
controller.enqueue({ type: "stream-start", warnings });
|
|
4121
4128
|
},
|
|
4122
4129
|
transform(chunk, controller) {
|
|
4123
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
4130
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
4124
4131
|
if (options.includeRawChunks) {
|
|
4125
4132
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
4126
4133
|
}
|
|
@@ -4211,12 +4218,16 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4211
4218
|
});
|
|
4212
4219
|
} else if (value.item.type === "message") {
|
|
4213
4220
|
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
4221
|
+
activeMessagePhase = (_a = value.item.phase) != null ? _a : void 0;
|
|
4214
4222
|
controller.enqueue({
|
|
4215
4223
|
type: "text-start",
|
|
4216
4224
|
id: value.item.id,
|
|
4217
4225
|
providerMetadata: {
|
|
4218
4226
|
[providerKey]: {
|
|
4219
|
-
itemId: value.item.id
|
|
4227
|
+
itemId: value.item.id,
|
|
4228
|
+
...value.item.phase != null && {
|
|
4229
|
+
phase: value.item.phase
|
|
4230
|
+
}
|
|
4220
4231
|
}
|
|
4221
4232
|
}
|
|
4222
4233
|
});
|
|
@@ -4231,19 +4242,22 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4231
4242
|
providerMetadata: {
|
|
4232
4243
|
[providerKey]: {
|
|
4233
4244
|
itemId: value.item.id,
|
|
4234
|
-
reasoningEncryptedContent: (
|
|
4245
|
+
reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
|
|
4235
4246
|
}
|
|
4236
4247
|
}
|
|
4237
4248
|
});
|
|
4238
4249
|
}
|
|
4239
4250
|
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
4240
4251
|
if (value.item.type === "message") {
|
|
4252
|
+
const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
|
|
4253
|
+
activeMessagePhase = void 0;
|
|
4241
4254
|
controller.enqueue({
|
|
4242
4255
|
type: "text-end",
|
|
4243
4256
|
id: value.item.id,
|
|
4244
4257
|
providerMetadata: {
|
|
4245
4258
|
[providerKey]: {
|
|
4246
4259
|
itemId: value.item.id,
|
|
4260
|
+
...phase != null && { phase },
|
|
4247
4261
|
...ongoingAnnotations.length > 0 && {
|
|
4248
4262
|
annotations: ongoingAnnotations
|
|
4249
4263
|
}
|
|
@@ -4308,13 +4322,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4308
4322
|
toolName: "file_search",
|
|
4309
4323
|
result: {
|
|
4310
4324
|
queries: value.item.queries,
|
|
4311
|
-
results: (
|
|
4325
|
+
results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
|
|
4312
4326
|
attributes: result.attributes,
|
|
4313
4327
|
fileId: result.file_id,
|
|
4314
4328
|
filename: result.filename,
|
|
4315
4329
|
score: result.score,
|
|
4316
4330
|
text: result.text
|
|
4317
|
-
}))) != null ?
|
|
4331
|
+
}))) != null ? _e : null
|
|
4318
4332
|
},
|
|
4319
4333
|
providerExecuted: true
|
|
4320
4334
|
});
|
|
@@ -4373,7 +4387,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4373
4387
|
providerMetadata: {
|
|
4374
4388
|
[providerKey]: {
|
|
4375
4389
|
itemId: value.item.id,
|
|
4376
|
-
reasoningEncryptedContent: (
|
|
4390
|
+
reasoningEncryptedContent: (_f = value.item.encrypted_content) != null ? _f : null
|
|
4377
4391
|
}
|
|
4378
4392
|
}
|
|
4379
4393
|
});
|
|
@@ -4437,7 +4451,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4437
4451
|
id: value.item_id,
|
|
4438
4452
|
delta: value.delta
|
|
4439
4453
|
});
|
|
4440
|
-
if (((
|
|
4454
|
+
if (((_h = (_g = options.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.logprobs) && value.logprobs) {
|
|
4441
4455
|
logprobs.push(value.logprobs);
|
|
4442
4456
|
}
|
|
4443
4457
|
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
@@ -4464,7 +4478,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4464
4478
|
providerMetadata: {
|
|
4465
4479
|
[providerKey]: {
|
|
4466
4480
|
itemId: value.item_id,
|
|
4467
|
-
reasoningEncryptedContent: (
|
|
4481
|
+
reasoningEncryptedContent: (_j = (_i = activeReasoning[value.item_id]) == null ? void 0 : _i.encryptedContent) != null ? _j : null
|
|
4468
4482
|
}
|
|
4469
4483
|
}
|
|
4470
4484
|
});
|
|
@@ -4495,14 +4509,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4495
4509
|
}
|
|
4496
4510
|
} else if (isResponseFinishedChunk(value)) {
|
|
4497
4511
|
finishReason = mapOpenAIResponseFinishReason({
|
|
4498
|
-
finishReason: (
|
|
4512
|
+
finishReason: (_k = value.response.incomplete_details) == null ? void 0 : _k.reason,
|
|
4499
4513
|
hasFunctionCall
|
|
4500
4514
|
});
|
|
4501
4515
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
4502
4516
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
4503
4517
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
4504
|
-
usage.reasoningTokens = (
|
|
4505
|
-
usage.cachedInputTokens = (
|
|
4518
|
+
usage.reasoningTokens = (_m = (_l = value.response.usage.output_tokens_details) == null ? void 0 : _l.reasoning_tokens) != null ? _m : void 0;
|
|
4519
|
+
usage.cachedInputTokens = (_o = (_n = value.response.usage.input_tokens_details) == null ? void 0 : _n.cached_tokens) != null ? _o : void 0;
|
|
4506
4520
|
if (typeof value.response.service_tier === "string") {
|
|
4507
4521
|
serviceTier = value.response.service_tier;
|
|
4508
4522
|
}
|
|
@@ -4512,7 +4526,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4512
4526
|
controller.enqueue({
|
|
4513
4527
|
type: "source",
|
|
4514
4528
|
sourceType: "url",
|
|
4515
|
-
id: (
|
|
4529
|
+
id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
|
|
4516
4530
|
url: value.annotation.url,
|
|
4517
4531
|
title: value.annotation.title
|
|
4518
4532
|
});
|
|
@@ -4520,10 +4534,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4520
4534
|
controller.enqueue({
|
|
4521
4535
|
type: "source",
|
|
4522
4536
|
sourceType: "document",
|
|
4523
|
-
id: (
|
|
4537
|
+
id: (_u = (_t = (_s = self.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId2(),
|
|
4524
4538
|
mediaType: "text/plain",
|
|
4525
|
-
title: (
|
|
4526
|
-
filename: (
|
|
4539
|
+
title: (_w = (_v = value.annotation.quote) != null ? _v : value.annotation.filename) != null ? _w : "Document",
|
|
4540
|
+
filename: (_x = value.annotation.filename) != null ? _x : value.annotation.file_id,
|
|
4527
4541
|
...value.annotation.file_id ? {
|
|
4528
4542
|
providerMetadata: {
|
|
4529
4543
|
[providerKey]: {
|