@ai-sdk/openai 2.0.68 → 2.0.70
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 +12 -0
- package/dist/index.js +59 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -26
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +58 -25
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +58 -25
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -2754,10 +2754,13 @@ var openaiResponsesChunkSchema = lazyValidator11(
|
|
|
2754
2754
|
}),
|
|
2755
2755
|
z14.object({
|
|
2756
2756
|
type: z14.literal("error"),
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2757
|
+
sequence_number: z14.number(),
|
|
2758
|
+
error: z14.object({
|
|
2759
|
+
type: z14.string(),
|
|
2760
|
+
code: z14.string(),
|
|
2761
|
+
message: z14.string(),
|
|
2762
|
+
param: z14.string().nullish()
|
|
2763
|
+
})
|
|
2761
2764
|
}),
|
|
2762
2765
|
z14.object({ type: z14.string() }).loose().transform((value) => ({
|
|
2763
2766
|
type: "unknown_chunk",
|
|
@@ -2770,13 +2773,15 @@ var openaiResponsesChunkSchema = lazyValidator11(
|
|
|
2770
2773
|
var openaiResponsesResponseSchema = lazyValidator11(
|
|
2771
2774
|
() => zodSchema12(
|
|
2772
2775
|
z14.object({
|
|
2773
|
-
id: z14.string(),
|
|
2774
|
-
created_at: z14.number(),
|
|
2776
|
+
id: z14.string().optional(),
|
|
2777
|
+
created_at: z14.number().optional(),
|
|
2775
2778
|
error: z14.object({
|
|
2776
|
-
|
|
2777
|
-
|
|
2779
|
+
message: z14.string(),
|
|
2780
|
+
type: z14.string(),
|
|
2781
|
+
param: z14.string().nullish(),
|
|
2782
|
+
code: z14.string()
|
|
2778
2783
|
}).nullish(),
|
|
2779
|
-
model: z14.string(),
|
|
2784
|
+
model: z14.string().optional(),
|
|
2780
2785
|
output: z14.array(
|
|
2781
2786
|
z14.discriminatedUnion("type", [
|
|
2782
2787
|
z14.object({
|
|
@@ -2818,7 +2823,18 @@ var openaiResponsesResponseSchema = lazyValidator11(
|
|
|
2818
2823
|
quote: z14.string().nullish()
|
|
2819
2824
|
}),
|
|
2820
2825
|
z14.object({
|
|
2821
|
-
type: z14.literal("container_file_citation")
|
|
2826
|
+
type: z14.literal("container_file_citation"),
|
|
2827
|
+
container_id: z14.string(),
|
|
2828
|
+
file_id: z14.string(),
|
|
2829
|
+
filename: z14.string().nullish(),
|
|
2830
|
+
start_index: z14.number().nullish(),
|
|
2831
|
+
end_index: z14.number().nullish(),
|
|
2832
|
+
index: z14.number().nullish()
|
|
2833
|
+
}),
|
|
2834
|
+
z14.object({
|
|
2835
|
+
type: z14.literal("file_path"),
|
|
2836
|
+
file_id: z14.string(),
|
|
2837
|
+
index: z14.number().nullish()
|
|
2822
2838
|
})
|
|
2823
2839
|
])
|
|
2824
2840
|
)
|
|
@@ -2857,7 +2873,10 @@ var openaiResponsesResponseSchema = lazyValidator11(
|
|
|
2857
2873
|
queries: z14.array(z14.string()),
|
|
2858
2874
|
results: z14.array(
|
|
2859
2875
|
z14.object({
|
|
2860
|
-
attributes: z14.record(
|
|
2876
|
+
attributes: z14.record(
|
|
2877
|
+
z14.string(),
|
|
2878
|
+
z14.union([z14.string(), z14.number(), z14.boolean()])
|
|
2879
|
+
),
|
|
2861
2880
|
file_id: z14.string(),
|
|
2862
2881
|
filename: z14.string(),
|
|
2863
2882
|
score: z14.number(),
|
|
@@ -2919,7 +2938,7 @@ var openaiResponsesResponseSchema = lazyValidator11(
|
|
|
2919
2938
|
)
|
|
2920
2939
|
})
|
|
2921
2940
|
])
|
|
2922
|
-
),
|
|
2941
|
+
).optional(),
|
|
2923
2942
|
service_tier: z14.string().nullish(),
|
|
2924
2943
|
incomplete_details: z14.object({ reason: z14.string() }).nullish(),
|
|
2925
2944
|
usage: z14.object({
|
|
@@ -2927,7 +2946,7 @@ var openaiResponsesResponseSchema = lazyValidator11(
|
|
|
2927
2946
|
input_tokens_details: z14.object({ cached_tokens: z14.number().nullish() }).nullish(),
|
|
2928
2947
|
output_tokens: z14.number(),
|
|
2929
2948
|
output_tokens_details: z14.object({ reasoning_tokens: z14.number().nullish() }).nullish()
|
|
2930
|
-
})
|
|
2949
|
+
}).optional()
|
|
2931
2950
|
})
|
|
2932
2951
|
)
|
|
2933
2952
|
);
|
|
@@ -3923,7 +3942,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3923
3942
|
}
|
|
3924
3943
|
}
|
|
3925
3944
|
const providerMetadata = {
|
|
3926
|
-
openai: {
|
|
3945
|
+
openai: {
|
|
3946
|
+
...response.id != null ? { responseId: response.id } : {}
|
|
3947
|
+
}
|
|
3927
3948
|
};
|
|
3928
3949
|
if (logprobs.length > 0) {
|
|
3929
3950
|
providerMetadata.openai.logprobs = logprobs;
|
|
@@ -3931,6 +3952,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3931
3952
|
if (typeof response.service_tier === "string") {
|
|
3932
3953
|
providerMetadata.openai.serviceTier = response.service_tier;
|
|
3933
3954
|
}
|
|
3955
|
+
const usage = response.usage;
|
|
3934
3956
|
return {
|
|
3935
3957
|
content,
|
|
3936
3958
|
finishReason: mapOpenAIResponseFinishReason({
|
|
@@ -3938,11 +3960,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3938
3960
|
hasFunctionCall
|
|
3939
3961
|
}),
|
|
3940
3962
|
usage: {
|
|
3941
|
-
inputTokens:
|
|
3942
|
-
outputTokens:
|
|
3943
|
-
totalTokens:
|
|
3944
|
-
reasoningTokens: (_q = (_p =
|
|
3945
|
-
cachedInputTokens: (_s = (_r =
|
|
3963
|
+
inputTokens: usage.input_tokens,
|
|
3964
|
+
outputTokens: usage.output_tokens,
|
|
3965
|
+
totalTokens: usage.input_tokens + usage.output_tokens,
|
|
3966
|
+
reasoningTokens: (_q = (_p = usage.output_tokens_details) == null ? void 0 : _p.reasoning_tokens) != null ? _q : void 0,
|
|
3967
|
+
cachedInputTokens: (_s = (_r = usage.input_tokens_details) == null ? void 0 : _r.cached_tokens) != null ? _s : void 0
|
|
3946
3968
|
},
|
|
3947
3969
|
request: { body },
|
|
3948
3970
|
response: {
|
|
@@ -3990,6 +4012,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3990
4012
|
const logprobs = [];
|
|
3991
4013
|
let responseId = null;
|
|
3992
4014
|
const ongoingToolCalls = {};
|
|
4015
|
+
const ongoingAnnotations = [];
|
|
3993
4016
|
let hasFunctionCall = false;
|
|
3994
4017
|
const activeReasoning = {};
|
|
3995
4018
|
let serviceTier;
|
|
@@ -4090,6 +4113,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4090
4113
|
providerExecuted: true
|
|
4091
4114
|
});
|
|
4092
4115
|
} else if (value.item.type === "message") {
|
|
4116
|
+
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
4093
4117
|
controller.enqueue({
|
|
4094
4118
|
type: "text-start",
|
|
4095
4119
|
id: value.item.id,
|
|
@@ -4115,7 +4139,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4115
4139
|
}
|
|
4116
4140
|
});
|
|
4117
4141
|
}
|
|
4118
|
-
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
4142
|
+
} else if (isResponseOutputItemDoneChunk(value) && value.item.type !== "message") {
|
|
4119
4143
|
if (value.item.type === "function_call") {
|
|
4120
4144
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4121
4145
|
hasFunctionCall = true;
|
|
@@ -4225,11 +4249,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4225
4249
|
openai: { itemId: value.item.id }
|
|
4226
4250
|
}
|
|
4227
4251
|
});
|
|
4228
|
-
} else if (value.item.type === "message") {
|
|
4229
|
-
controller.enqueue({
|
|
4230
|
-
type: "text-end",
|
|
4231
|
-
id: value.item.id
|
|
4232
|
-
});
|
|
4233
4252
|
} else if (value.item.type === "reasoning") {
|
|
4234
4253
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
4235
4254
|
const summaryPartIndices = Object.entries(
|
|
@@ -4376,6 +4395,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4376
4395
|
serviceTier = value.response.service_tier;
|
|
4377
4396
|
}
|
|
4378
4397
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
4398
|
+
ongoingAnnotations.push(value.annotation);
|
|
4379
4399
|
if (value.annotation.type === "url_citation") {
|
|
4380
4400
|
controller.enqueue({
|
|
4381
4401
|
type: "source",
|
|
@@ -4401,6 +4421,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4401
4421
|
} : {}
|
|
4402
4422
|
});
|
|
4403
4423
|
}
|
|
4424
|
+
} else if (isResponseOutputItemDoneChunk(value) && value.item.type === "message") {
|
|
4425
|
+
controller.enqueue({
|
|
4426
|
+
type: "text-end",
|
|
4427
|
+
id: value.item.id,
|
|
4428
|
+
providerMetadata: {
|
|
4429
|
+
openai: {
|
|
4430
|
+
itemId: value.item.id,
|
|
4431
|
+
...ongoingAnnotations.length > 0 && {
|
|
4432
|
+
annotations: ongoingAnnotations
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
}
|
|
4436
|
+
});
|
|
4404
4437
|
} else if (isErrorChunk(value)) {
|
|
4405
4438
|
controller.enqueue({ type: "error", error: value });
|
|
4406
4439
|
}
|