@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/index.mjs
CHANGED
|
@@ -2716,10 +2716,13 @@ var openaiResponsesChunkSchema = lazyValidator8(
|
|
|
2716
2716
|
}),
|
|
2717
2717
|
z16.object({
|
|
2718
2718
|
type: z16.literal("error"),
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2719
|
+
sequence_number: z16.number(),
|
|
2720
|
+
error: z16.object({
|
|
2721
|
+
type: z16.string(),
|
|
2722
|
+
code: z16.string(),
|
|
2723
|
+
message: z16.string(),
|
|
2724
|
+
param: z16.string().nullish()
|
|
2725
|
+
})
|
|
2723
2726
|
}),
|
|
2724
2727
|
z16.object({ type: z16.string() }).loose().transform((value) => ({
|
|
2725
2728
|
type: "unknown_chunk",
|
|
@@ -2732,13 +2735,15 @@ var openaiResponsesChunkSchema = lazyValidator8(
|
|
|
2732
2735
|
var openaiResponsesResponseSchema = lazyValidator8(
|
|
2733
2736
|
() => zodSchema14(
|
|
2734
2737
|
z16.object({
|
|
2735
|
-
id: z16.string(),
|
|
2736
|
-
created_at: z16.number(),
|
|
2738
|
+
id: z16.string().optional(),
|
|
2739
|
+
created_at: z16.number().optional(),
|
|
2737
2740
|
error: z16.object({
|
|
2738
|
-
|
|
2739
|
-
|
|
2741
|
+
message: z16.string(),
|
|
2742
|
+
type: z16.string(),
|
|
2743
|
+
param: z16.string().nullish(),
|
|
2744
|
+
code: z16.string()
|
|
2740
2745
|
}).nullish(),
|
|
2741
|
-
model: z16.string(),
|
|
2746
|
+
model: z16.string().optional(),
|
|
2742
2747
|
output: z16.array(
|
|
2743
2748
|
z16.discriminatedUnion("type", [
|
|
2744
2749
|
z16.object({
|
|
@@ -2780,7 +2785,18 @@ var openaiResponsesResponseSchema = lazyValidator8(
|
|
|
2780
2785
|
quote: z16.string().nullish()
|
|
2781
2786
|
}),
|
|
2782
2787
|
z16.object({
|
|
2783
|
-
type: z16.literal("container_file_citation")
|
|
2788
|
+
type: z16.literal("container_file_citation"),
|
|
2789
|
+
container_id: z16.string(),
|
|
2790
|
+
file_id: z16.string(),
|
|
2791
|
+
filename: z16.string().nullish(),
|
|
2792
|
+
start_index: z16.number().nullish(),
|
|
2793
|
+
end_index: z16.number().nullish(),
|
|
2794
|
+
index: z16.number().nullish()
|
|
2795
|
+
}),
|
|
2796
|
+
z16.object({
|
|
2797
|
+
type: z16.literal("file_path"),
|
|
2798
|
+
file_id: z16.string(),
|
|
2799
|
+
index: z16.number().nullish()
|
|
2784
2800
|
})
|
|
2785
2801
|
])
|
|
2786
2802
|
)
|
|
@@ -2819,7 +2835,10 @@ var openaiResponsesResponseSchema = lazyValidator8(
|
|
|
2819
2835
|
queries: z16.array(z16.string()),
|
|
2820
2836
|
results: z16.array(
|
|
2821
2837
|
z16.object({
|
|
2822
|
-
attributes: z16.record(
|
|
2838
|
+
attributes: z16.record(
|
|
2839
|
+
z16.string(),
|
|
2840
|
+
z16.union([z16.string(), z16.number(), z16.boolean()])
|
|
2841
|
+
),
|
|
2823
2842
|
file_id: z16.string(),
|
|
2824
2843
|
filename: z16.string(),
|
|
2825
2844
|
score: z16.number(),
|
|
@@ -2881,7 +2900,7 @@ var openaiResponsesResponseSchema = lazyValidator8(
|
|
|
2881
2900
|
)
|
|
2882
2901
|
})
|
|
2883
2902
|
])
|
|
2884
|
-
),
|
|
2903
|
+
).optional(),
|
|
2885
2904
|
service_tier: z16.string().nullish(),
|
|
2886
2905
|
incomplete_details: z16.object({ reason: z16.string() }).nullish(),
|
|
2887
2906
|
usage: z16.object({
|
|
@@ -2889,7 +2908,7 @@ var openaiResponsesResponseSchema = lazyValidator8(
|
|
|
2889
2908
|
input_tokens_details: z16.object({ cached_tokens: z16.number().nullish() }).nullish(),
|
|
2890
2909
|
output_tokens: z16.number(),
|
|
2891
2910
|
output_tokens_details: z16.object({ reasoning_tokens: z16.number().nullish() }).nullish()
|
|
2892
|
-
})
|
|
2911
|
+
}).optional()
|
|
2893
2912
|
})
|
|
2894
2913
|
)
|
|
2895
2914
|
);
|
|
@@ -3631,7 +3650,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3631
3650
|
}
|
|
3632
3651
|
}
|
|
3633
3652
|
const providerMetadata = {
|
|
3634
|
-
openai: {
|
|
3653
|
+
openai: {
|
|
3654
|
+
...response.id != null ? { responseId: response.id } : {}
|
|
3655
|
+
}
|
|
3635
3656
|
};
|
|
3636
3657
|
if (logprobs.length > 0) {
|
|
3637
3658
|
providerMetadata.openai.logprobs = logprobs;
|
|
@@ -3639,6 +3660,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3639
3660
|
if (typeof response.service_tier === "string") {
|
|
3640
3661
|
providerMetadata.openai.serviceTier = response.service_tier;
|
|
3641
3662
|
}
|
|
3663
|
+
const usage = response.usage;
|
|
3642
3664
|
return {
|
|
3643
3665
|
content,
|
|
3644
3666
|
finishReason: mapOpenAIResponseFinishReason({
|
|
@@ -3646,11 +3668,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3646
3668
|
hasFunctionCall
|
|
3647
3669
|
}),
|
|
3648
3670
|
usage: {
|
|
3649
|
-
inputTokens:
|
|
3650
|
-
outputTokens:
|
|
3651
|
-
totalTokens:
|
|
3652
|
-
reasoningTokens: (_q = (_p =
|
|
3653
|
-
cachedInputTokens: (_s = (_r =
|
|
3671
|
+
inputTokens: usage.input_tokens,
|
|
3672
|
+
outputTokens: usage.output_tokens,
|
|
3673
|
+
totalTokens: usage.input_tokens + usage.output_tokens,
|
|
3674
|
+
reasoningTokens: (_q = (_p = usage.output_tokens_details) == null ? void 0 : _p.reasoning_tokens) != null ? _q : void 0,
|
|
3675
|
+
cachedInputTokens: (_s = (_r = usage.input_tokens_details) == null ? void 0 : _r.cached_tokens) != null ? _s : void 0
|
|
3654
3676
|
},
|
|
3655
3677
|
request: { body },
|
|
3656
3678
|
response: {
|
|
@@ -3698,6 +3720,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3698
3720
|
const logprobs = [];
|
|
3699
3721
|
let responseId = null;
|
|
3700
3722
|
const ongoingToolCalls = {};
|
|
3723
|
+
const ongoingAnnotations = [];
|
|
3701
3724
|
let hasFunctionCall = false;
|
|
3702
3725
|
const activeReasoning = {};
|
|
3703
3726
|
let serviceTier;
|
|
@@ -3798,6 +3821,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3798
3821
|
providerExecuted: true
|
|
3799
3822
|
});
|
|
3800
3823
|
} else if (value.item.type === "message") {
|
|
3824
|
+
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
3801
3825
|
controller.enqueue({
|
|
3802
3826
|
type: "text-start",
|
|
3803
3827
|
id: value.item.id,
|
|
@@ -3823,7 +3847,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3823
3847
|
}
|
|
3824
3848
|
});
|
|
3825
3849
|
}
|
|
3826
|
-
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
3850
|
+
} else if (isResponseOutputItemDoneChunk(value) && value.item.type !== "message") {
|
|
3827
3851
|
if (value.item.type === "function_call") {
|
|
3828
3852
|
ongoingToolCalls[value.output_index] = void 0;
|
|
3829
3853
|
hasFunctionCall = true;
|
|
@@ -3933,11 +3957,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3933
3957
|
openai: { itemId: value.item.id }
|
|
3934
3958
|
}
|
|
3935
3959
|
});
|
|
3936
|
-
} else if (value.item.type === "message") {
|
|
3937
|
-
controller.enqueue({
|
|
3938
|
-
type: "text-end",
|
|
3939
|
-
id: value.item.id
|
|
3940
|
-
});
|
|
3941
3960
|
} else if (value.item.type === "reasoning") {
|
|
3942
3961
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
3943
3962
|
const summaryPartIndices = Object.entries(
|
|
@@ -4084,6 +4103,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4084
4103
|
serviceTier = value.response.service_tier;
|
|
4085
4104
|
}
|
|
4086
4105
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
4106
|
+
ongoingAnnotations.push(value.annotation);
|
|
4087
4107
|
if (value.annotation.type === "url_citation") {
|
|
4088
4108
|
controller.enqueue({
|
|
4089
4109
|
type: "source",
|
|
@@ -4109,6 +4129,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4109
4129
|
} : {}
|
|
4110
4130
|
});
|
|
4111
4131
|
}
|
|
4132
|
+
} else if (isResponseOutputItemDoneChunk(value) && value.item.type === "message") {
|
|
4133
|
+
controller.enqueue({
|
|
4134
|
+
type: "text-end",
|
|
4135
|
+
id: value.item.id,
|
|
4136
|
+
providerMetadata: {
|
|
4137
|
+
openai: {
|
|
4138
|
+
itemId: value.item.id,
|
|
4139
|
+
...ongoingAnnotations.length > 0 && {
|
|
4140
|
+
annotations: ongoingAnnotations
|
|
4141
|
+
}
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4144
|
+
});
|
|
4112
4145
|
} else if (isErrorChunk(value)) {
|
|
4113
4146
|
controller.enqueue({ type: "error", error: value });
|
|
4114
4147
|
}
|
|
@@ -4584,7 +4617,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4584
4617
|
};
|
|
4585
4618
|
|
|
4586
4619
|
// src/version.ts
|
|
4587
|
-
var VERSION = true ? "2.0.
|
|
4620
|
+
var VERSION = true ? "2.0.70" : "0.0.0-test";
|
|
4588
4621
|
|
|
4589
4622
|
// src/openai-provider.ts
|
|
4590
4623
|
function createOpenAI(options = {}) {
|