@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/index.mjs
CHANGED
|
@@ -2210,7 +2210,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2210
2210
|
store,
|
|
2211
2211
|
hasLocalShellTool = false
|
|
2212
2212
|
}) {
|
|
2213
|
-
var _a, _b, _c, _d;
|
|
2213
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2214
2214
|
const input = [];
|
|
2215
2215
|
const warnings = [];
|
|
2216
2216
|
for (const { role, content } of prompt) {
|
|
@@ -2292,6 +2292,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2292
2292
|
switch (part.type) {
|
|
2293
2293
|
case "text": {
|
|
2294
2294
|
const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId;
|
|
2295
|
+
const phase = (_d = (_c = part.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.phase;
|
|
2295
2296
|
if (store && id != null) {
|
|
2296
2297
|
input.push({ type: "item_reference", id });
|
|
2297
2298
|
break;
|
|
@@ -2299,7 +2300,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
2299
2300
|
input.push({
|
|
2300
2301
|
role: "assistant",
|
|
2301
2302
|
content: [{ type: "output_text", text: part.text }],
|
|
2302
|
-
id
|
|
2303
|
+
id,
|
|
2304
|
+
...phase != null && { phase }
|
|
2303
2305
|
});
|
|
2304
2306
|
break;
|
|
2305
2307
|
}
|
|
@@ -2308,7 +2310,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2308
2310
|
if (part.providerExecuted) {
|
|
2309
2311
|
break;
|
|
2310
2312
|
}
|
|
2311
|
-
const id = (
|
|
2313
|
+
const id = (_f = (_e = part.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.itemId;
|
|
2312
2314
|
if (store && id != null) {
|
|
2313
2315
|
input.push({ type: "item_reference", id });
|
|
2314
2316
|
break;
|
|
@@ -2550,7 +2552,8 @@ var openaiResponsesChunkSchema = lazyValidator8(
|
|
|
2550
2552
|
item: z16.discriminatedUnion("type", [
|
|
2551
2553
|
z16.object({
|
|
2552
2554
|
type: z16.literal("message"),
|
|
2553
|
-
id: z16.string()
|
|
2555
|
+
id: z16.string(),
|
|
2556
|
+
phase: z16.enum(["commentary", "final_answer"]).nullish()
|
|
2554
2557
|
}),
|
|
2555
2558
|
z16.object({
|
|
2556
2559
|
type: z16.literal("reasoning"),
|
|
@@ -2603,7 +2606,8 @@ var openaiResponsesChunkSchema = lazyValidator8(
|
|
|
2603
2606
|
item: z16.discriminatedUnion("type", [
|
|
2604
2607
|
z16.object({
|
|
2605
2608
|
type: z16.literal("message"),
|
|
2606
|
-
id: z16.string()
|
|
2609
|
+
id: z16.string(),
|
|
2610
|
+
phase: z16.enum(["commentary", "final_answer"]).nullish()
|
|
2607
2611
|
}),
|
|
2608
2612
|
z16.object({
|
|
2609
2613
|
type: z16.literal("reasoning"),
|
|
@@ -2792,6 +2796,7 @@ var openaiResponsesResponseSchema = lazyValidator8(
|
|
|
2792
2796
|
type: z16.literal("message"),
|
|
2793
2797
|
role: z16.literal("assistant"),
|
|
2794
2798
|
id: z16.string(),
|
|
2799
|
+
phase: z16.enum(["commentary", "final_answer"]).nullish(),
|
|
2795
2800
|
content: z16.array(
|
|
2796
2801
|
z16.object({
|
|
2797
2802
|
type: z16.literal("output_text"),
|
|
@@ -3578,7 +3583,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3578
3583
|
text: contentPart.text,
|
|
3579
3584
|
providerMetadata: {
|
|
3580
3585
|
[providerKey]: {
|
|
3581
|
-
itemId: part.id
|
|
3586
|
+
itemId: part.id,
|
|
3587
|
+
...part.phase != null && { phase: part.phase }
|
|
3582
3588
|
}
|
|
3583
3589
|
}
|
|
3584
3590
|
});
|
|
@@ -3818,6 +3824,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3818
3824
|
let responseId = null;
|
|
3819
3825
|
const ongoingToolCalls = {};
|
|
3820
3826
|
const ongoingAnnotations = [];
|
|
3827
|
+
let activeMessagePhase;
|
|
3821
3828
|
let hasFunctionCall = false;
|
|
3822
3829
|
const activeReasoning = {};
|
|
3823
3830
|
let serviceTier;
|
|
@@ -3828,7 +3835,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3828
3835
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3829
3836
|
},
|
|
3830
3837
|
transform(chunk, controller) {
|
|
3831
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3838
|
+
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;
|
|
3832
3839
|
if (options.includeRawChunks) {
|
|
3833
3840
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3834
3841
|
}
|
|
@@ -3919,12 +3926,16 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3919
3926
|
});
|
|
3920
3927
|
} else if (value.item.type === "message") {
|
|
3921
3928
|
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
3929
|
+
activeMessagePhase = (_a = value.item.phase) != null ? _a : void 0;
|
|
3922
3930
|
controller.enqueue({
|
|
3923
3931
|
type: "text-start",
|
|
3924
3932
|
id: value.item.id,
|
|
3925
3933
|
providerMetadata: {
|
|
3926
3934
|
[providerKey]: {
|
|
3927
|
-
itemId: value.item.id
|
|
3935
|
+
itemId: value.item.id,
|
|
3936
|
+
...value.item.phase != null && {
|
|
3937
|
+
phase: value.item.phase
|
|
3938
|
+
}
|
|
3928
3939
|
}
|
|
3929
3940
|
}
|
|
3930
3941
|
});
|
|
@@ -3939,19 +3950,22 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3939
3950
|
providerMetadata: {
|
|
3940
3951
|
[providerKey]: {
|
|
3941
3952
|
itemId: value.item.id,
|
|
3942
|
-
reasoningEncryptedContent: (
|
|
3953
|
+
reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
|
|
3943
3954
|
}
|
|
3944
3955
|
}
|
|
3945
3956
|
});
|
|
3946
3957
|
}
|
|
3947
3958
|
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
3948
3959
|
if (value.item.type === "message") {
|
|
3960
|
+
const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
|
|
3961
|
+
activeMessagePhase = void 0;
|
|
3949
3962
|
controller.enqueue({
|
|
3950
3963
|
type: "text-end",
|
|
3951
3964
|
id: value.item.id,
|
|
3952
3965
|
providerMetadata: {
|
|
3953
3966
|
[providerKey]: {
|
|
3954
3967
|
itemId: value.item.id,
|
|
3968
|
+
...phase != null && { phase },
|
|
3955
3969
|
...ongoingAnnotations.length > 0 && {
|
|
3956
3970
|
annotations: ongoingAnnotations
|
|
3957
3971
|
}
|
|
@@ -4016,13 +4030,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4016
4030
|
toolName: "file_search",
|
|
4017
4031
|
result: {
|
|
4018
4032
|
queries: value.item.queries,
|
|
4019
|
-
results: (
|
|
4033
|
+
results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
|
|
4020
4034
|
attributes: result.attributes,
|
|
4021
4035
|
fileId: result.file_id,
|
|
4022
4036
|
filename: result.filename,
|
|
4023
4037
|
score: result.score,
|
|
4024
4038
|
text: result.text
|
|
4025
|
-
}))) != null ?
|
|
4039
|
+
}))) != null ? _e : null
|
|
4026
4040
|
},
|
|
4027
4041
|
providerExecuted: true
|
|
4028
4042
|
});
|
|
@@ -4081,7 +4095,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4081
4095
|
providerMetadata: {
|
|
4082
4096
|
[providerKey]: {
|
|
4083
4097
|
itemId: value.item.id,
|
|
4084
|
-
reasoningEncryptedContent: (
|
|
4098
|
+
reasoningEncryptedContent: (_f = value.item.encrypted_content) != null ? _f : null
|
|
4085
4099
|
}
|
|
4086
4100
|
}
|
|
4087
4101
|
});
|
|
@@ -4145,7 +4159,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4145
4159
|
id: value.item_id,
|
|
4146
4160
|
delta: value.delta
|
|
4147
4161
|
});
|
|
4148
|
-
if (((
|
|
4162
|
+
if (((_h = (_g = options.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.logprobs) && value.logprobs) {
|
|
4149
4163
|
logprobs.push(value.logprobs);
|
|
4150
4164
|
}
|
|
4151
4165
|
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
@@ -4172,7 +4186,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4172
4186
|
providerMetadata: {
|
|
4173
4187
|
[providerKey]: {
|
|
4174
4188
|
itemId: value.item_id,
|
|
4175
|
-
reasoningEncryptedContent: (
|
|
4189
|
+
reasoningEncryptedContent: (_j = (_i = activeReasoning[value.item_id]) == null ? void 0 : _i.encryptedContent) != null ? _j : null
|
|
4176
4190
|
}
|
|
4177
4191
|
}
|
|
4178
4192
|
});
|
|
@@ -4203,14 +4217,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4203
4217
|
}
|
|
4204
4218
|
} else if (isResponseFinishedChunk(value)) {
|
|
4205
4219
|
finishReason = mapOpenAIResponseFinishReason({
|
|
4206
|
-
finishReason: (
|
|
4220
|
+
finishReason: (_k = value.response.incomplete_details) == null ? void 0 : _k.reason,
|
|
4207
4221
|
hasFunctionCall
|
|
4208
4222
|
});
|
|
4209
4223
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
4210
4224
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
4211
4225
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
4212
|
-
usage.reasoningTokens = (
|
|
4213
|
-
usage.cachedInputTokens = (
|
|
4226
|
+
usage.reasoningTokens = (_m = (_l = value.response.usage.output_tokens_details) == null ? void 0 : _l.reasoning_tokens) != null ? _m : void 0;
|
|
4227
|
+
usage.cachedInputTokens = (_o = (_n = value.response.usage.input_tokens_details) == null ? void 0 : _n.cached_tokens) != null ? _o : void 0;
|
|
4214
4228
|
if (typeof value.response.service_tier === "string") {
|
|
4215
4229
|
serviceTier = value.response.service_tier;
|
|
4216
4230
|
}
|
|
@@ -4220,7 +4234,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4220
4234
|
controller.enqueue({
|
|
4221
4235
|
type: "source",
|
|
4222
4236
|
sourceType: "url",
|
|
4223
|
-
id: (
|
|
4237
|
+
id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
|
|
4224
4238
|
url: value.annotation.url,
|
|
4225
4239
|
title: value.annotation.title
|
|
4226
4240
|
});
|
|
@@ -4228,10 +4242,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4228
4242
|
controller.enqueue({
|
|
4229
4243
|
type: "source",
|
|
4230
4244
|
sourceType: "document",
|
|
4231
|
-
id: (
|
|
4245
|
+
id: (_u = (_t = (_s = self.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId2(),
|
|
4232
4246
|
mediaType: "text/plain",
|
|
4233
|
-
title: (
|
|
4234
|
-
filename: (
|
|
4247
|
+
title: (_w = (_v = value.annotation.quote) != null ? _v : value.annotation.filename) != null ? _w : "Document",
|
|
4248
|
+
filename: (_x = value.annotation.filename) != null ? _x : value.annotation.file_id,
|
|
4235
4249
|
...value.annotation.file_id ? {
|
|
4236
4250
|
providerMetadata: {
|
|
4237
4251
|
[providerKey]: {
|
|
@@ -4697,7 +4711,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4697
4711
|
};
|
|
4698
4712
|
|
|
4699
4713
|
// src/version.ts
|
|
4700
|
-
var VERSION = true ? "2.0.
|
|
4714
|
+
var VERSION = true ? "2.0.97" : "0.0.0-test";
|
|
4701
4715
|
|
|
4702
4716
|
// src/openai-provider.ts
|
|
4703
4717
|
function createOpenAI(options = {}) {
|