@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.js
CHANGED
|
@@ -2214,7 +2214,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2214
2214
|
store,
|
|
2215
2215
|
hasLocalShellTool = false
|
|
2216
2216
|
}) {
|
|
2217
|
-
var _a, _b, _c, _d;
|
|
2217
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2218
2218
|
const input = [];
|
|
2219
2219
|
const warnings = [];
|
|
2220
2220
|
for (const { role, content } of prompt) {
|
|
@@ -2296,6 +2296,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2296
2296
|
switch (part.type) {
|
|
2297
2297
|
case "text": {
|
|
2298
2298
|
const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId;
|
|
2299
|
+
const phase = (_d = (_c = part.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.phase;
|
|
2299
2300
|
if (store && id != null) {
|
|
2300
2301
|
input.push({ type: "item_reference", id });
|
|
2301
2302
|
break;
|
|
@@ -2303,7 +2304,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
2303
2304
|
input.push({
|
|
2304
2305
|
role: "assistant",
|
|
2305
2306
|
content: [{ type: "output_text", text: part.text }],
|
|
2306
|
-
id
|
|
2307
|
+
id,
|
|
2308
|
+
...phase != null && { phase }
|
|
2307
2309
|
});
|
|
2308
2310
|
break;
|
|
2309
2311
|
}
|
|
@@ -2312,7 +2314,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2312
2314
|
if (part.providerExecuted) {
|
|
2313
2315
|
break;
|
|
2314
2316
|
}
|
|
2315
|
-
const id = (
|
|
2317
|
+
const id = (_f = (_e = part.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.itemId;
|
|
2316
2318
|
if (store && id != null) {
|
|
2317
2319
|
input.push({ type: "item_reference", id });
|
|
2318
2320
|
break;
|
|
@@ -2551,7 +2553,8 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazyValidator)(
|
|
|
2551
2553
|
item: import_v414.z.discriminatedUnion("type", [
|
|
2552
2554
|
import_v414.z.object({
|
|
2553
2555
|
type: import_v414.z.literal("message"),
|
|
2554
|
-
id: import_v414.z.string()
|
|
2556
|
+
id: import_v414.z.string(),
|
|
2557
|
+
phase: import_v414.z.enum(["commentary", "final_answer"]).nullish()
|
|
2555
2558
|
}),
|
|
2556
2559
|
import_v414.z.object({
|
|
2557
2560
|
type: import_v414.z.literal("reasoning"),
|
|
@@ -2604,7 +2607,8 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazyValidator)(
|
|
|
2604
2607
|
item: import_v414.z.discriminatedUnion("type", [
|
|
2605
2608
|
import_v414.z.object({
|
|
2606
2609
|
type: import_v414.z.literal("message"),
|
|
2607
|
-
id: import_v414.z.string()
|
|
2610
|
+
id: import_v414.z.string(),
|
|
2611
|
+
phase: import_v414.z.enum(["commentary", "final_answer"]).nullish()
|
|
2608
2612
|
}),
|
|
2609
2613
|
import_v414.z.object({
|
|
2610
2614
|
type: import_v414.z.literal("reasoning"),
|
|
@@ -2793,6 +2797,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils21.lazyValidator)(
|
|
|
2793
2797
|
type: import_v414.z.literal("message"),
|
|
2794
2798
|
role: import_v414.z.literal("assistant"),
|
|
2795
2799
|
id: import_v414.z.string(),
|
|
2800
|
+
phase: import_v414.z.enum(["commentary", "final_answer"]).nullish(),
|
|
2796
2801
|
content: import_v414.z.array(
|
|
2797
2802
|
import_v414.z.object({
|
|
2798
2803
|
type: import_v414.z.literal("output_text"),
|
|
@@ -3809,7 +3814,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3809
3814
|
text: contentPart.text,
|
|
3810
3815
|
providerMetadata: {
|
|
3811
3816
|
[providerKey]: {
|
|
3812
|
-
itemId: part.id
|
|
3817
|
+
itemId: part.id,
|
|
3818
|
+
...part.phase != null && { phase: part.phase }
|
|
3813
3819
|
}
|
|
3814
3820
|
}
|
|
3815
3821
|
});
|
|
@@ -4049,6 +4055,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4049
4055
|
let responseId = null;
|
|
4050
4056
|
const ongoingToolCalls = {};
|
|
4051
4057
|
const ongoingAnnotations = [];
|
|
4058
|
+
let activeMessagePhase;
|
|
4052
4059
|
let hasFunctionCall = false;
|
|
4053
4060
|
const activeReasoning = {};
|
|
4054
4061
|
let serviceTier;
|
|
@@ -4059,7 +4066,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4059
4066
|
controller.enqueue({ type: "stream-start", warnings });
|
|
4060
4067
|
},
|
|
4061
4068
|
transform(chunk, controller) {
|
|
4062
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
4069
|
+
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;
|
|
4063
4070
|
if (options.includeRawChunks) {
|
|
4064
4071
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
4065
4072
|
}
|
|
@@ -4150,12 +4157,16 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4150
4157
|
});
|
|
4151
4158
|
} else if (value.item.type === "message") {
|
|
4152
4159
|
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
4160
|
+
activeMessagePhase = (_a = value.item.phase) != null ? _a : void 0;
|
|
4153
4161
|
controller.enqueue({
|
|
4154
4162
|
type: "text-start",
|
|
4155
4163
|
id: value.item.id,
|
|
4156
4164
|
providerMetadata: {
|
|
4157
4165
|
[providerKey]: {
|
|
4158
|
-
itemId: value.item.id
|
|
4166
|
+
itemId: value.item.id,
|
|
4167
|
+
...value.item.phase != null && {
|
|
4168
|
+
phase: value.item.phase
|
|
4169
|
+
}
|
|
4159
4170
|
}
|
|
4160
4171
|
}
|
|
4161
4172
|
});
|
|
@@ -4170,19 +4181,22 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4170
4181
|
providerMetadata: {
|
|
4171
4182
|
[providerKey]: {
|
|
4172
4183
|
itemId: value.item.id,
|
|
4173
|
-
reasoningEncryptedContent: (
|
|
4184
|
+
reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
|
|
4174
4185
|
}
|
|
4175
4186
|
}
|
|
4176
4187
|
});
|
|
4177
4188
|
}
|
|
4178
4189
|
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
4179
4190
|
if (value.item.type === "message") {
|
|
4191
|
+
const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
|
|
4192
|
+
activeMessagePhase = void 0;
|
|
4180
4193
|
controller.enqueue({
|
|
4181
4194
|
type: "text-end",
|
|
4182
4195
|
id: value.item.id,
|
|
4183
4196
|
providerMetadata: {
|
|
4184
4197
|
[providerKey]: {
|
|
4185
4198
|
itemId: value.item.id,
|
|
4199
|
+
...phase != null && { phase },
|
|
4186
4200
|
...ongoingAnnotations.length > 0 && {
|
|
4187
4201
|
annotations: ongoingAnnotations
|
|
4188
4202
|
}
|
|
@@ -4247,13 +4261,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4247
4261
|
toolName: "file_search",
|
|
4248
4262
|
result: {
|
|
4249
4263
|
queries: value.item.queries,
|
|
4250
|
-
results: (
|
|
4264
|
+
results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
|
|
4251
4265
|
attributes: result.attributes,
|
|
4252
4266
|
fileId: result.file_id,
|
|
4253
4267
|
filename: result.filename,
|
|
4254
4268
|
score: result.score,
|
|
4255
4269
|
text: result.text
|
|
4256
|
-
}))) != null ?
|
|
4270
|
+
}))) != null ? _e : null
|
|
4257
4271
|
},
|
|
4258
4272
|
providerExecuted: true
|
|
4259
4273
|
});
|
|
@@ -4312,7 +4326,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4312
4326
|
providerMetadata: {
|
|
4313
4327
|
[providerKey]: {
|
|
4314
4328
|
itemId: value.item.id,
|
|
4315
|
-
reasoningEncryptedContent: (
|
|
4329
|
+
reasoningEncryptedContent: (_f = value.item.encrypted_content) != null ? _f : null
|
|
4316
4330
|
}
|
|
4317
4331
|
}
|
|
4318
4332
|
});
|
|
@@ -4376,7 +4390,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4376
4390
|
id: value.item_id,
|
|
4377
4391
|
delta: value.delta
|
|
4378
4392
|
});
|
|
4379
|
-
if (((
|
|
4393
|
+
if (((_h = (_g = options.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.logprobs) && value.logprobs) {
|
|
4380
4394
|
logprobs.push(value.logprobs);
|
|
4381
4395
|
}
|
|
4382
4396
|
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
@@ -4403,7 +4417,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4403
4417
|
providerMetadata: {
|
|
4404
4418
|
[providerKey]: {
|
|
4405
4419
|
itemId: value.item_id,
|
|
4406
|
-
reasoningEncryptedContent: (
|
|
4420
|
+
reasoningEncryptedContent: (_j = (_i = activeReasoning[value.item_id]) == null ? void 0 : _i.encryptedContent) != null ? _j : null
|
|
4407
4421
|
}
|
|
4408
4422
|
}
|
|
4409
4423
|
});
|
|
@@ -4434,14 +4448,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4434
4448
|
}
|
|
4435
4449
|
} else if (isResponseFinishedChunk(value)) {
|
|
4436
4450
|
finishReason = mapOpenAIResponseFinishReason({
|
|
4437
|
-
finishReason: (
|
|
4451
|
+
finishReason: (_k = value.response.incomplete_details) == null ? void 0 : _k.reason,
|
|
4438
4452
|
hasFunctionCall
|
|
4439
4453
|
});
|
|
4440
4454
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
4441
4455
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
4442
4456
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
4443
|
-
usage.reasoningTokens = (
|
|
4444
|
-
usage.cachedInputTokens = (
|
|
4457
|
+
usage.reasoningTokens = (_m = (_l = value.response.usage.output_tokens_details) == null ? void 0 : _l.reasoning_tokens) != null ? _m : void 0;
|
|
4458
|
+
usage.cachedInputTokens = (_o = (_n = value.response.usage.input_tokens_details) == null ? void 0 : _n.cached_tokens) != null ? _o : void 0;
|
|
4445
4459
|
if (typeof value.response.service_tier === "string") {
|
|
4446
4460
|
serviceTier = value.response.service_tier;
|
|
4447
4461
|
}
|
|
@@ -4451,7 +4465,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4451
4465
|
controller.enqueue({
|
|
4452
4466
|
type: "source",
|
|
4453
4467
|
sourceType: "url",
|
|
4454
|
-
id: (
|
|
4468
|
+
id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0, import_provider_utils29.generateId)(),
|
|
4455
4469
|
url: value.annotation.url,
|
|
4456
4470
|
title: value.annotation.title
|
|
4457
4471
|
});
|
|
@@ -4459,10 +4473,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4459
4473
|
controller.enqueue({
|
|
4460
4474
|
type: "source",
|
|
4461
4475
|
sourceType: "document",
|
|
4462
|
-
id: (
|
|
4476
|
+
id: (_u = (_t = (_s = self.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : (0, import_provider_utils29.generateId)(),
|
|
4463
4477
|
mediaType: "text/plain",
|
|
4464
|
-
title: (
|
|
4465
|
-
filename: (
|
|
4478
|
+
title: (_w = (_v = value.annotation.quote) != null ? _v : value.annotation.filename) != null ? _w : "Document",
|
|
4479
|
+
filename: (_x = value.annotation.filename) != null ? _x : value.annotation.file_id,
|
|
4466
4480
|
...value.annotation.file_id ? {
|
|
4467
4481
|
providerMetadata: {
|
|
4468
4482
|
[providerKey]: {
|