@ai-sdk/openai 2.0.51 → 2.0.52
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 +6 -0
- package/dist/index.js +60 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -33
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +59 -32
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +59 -32
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -2283,6 +2283,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2283
2283
|
input.push(reasoningMessages[reasoningId]);
|
|
2284
2284
|
} else {
|
|
2285
2285
|
reasoningMessage.summary.push(...summaryParts);
|
|
2286
|
+
if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
|
|
2287
|
+
reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
|
|
2288
|
+
}
|
|
2286
2289
|
}
|
|
2287
2290
|
}
|
|
2288
2291
|
} else {
|
|
@@ -2625,6 +2628,11 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazyValidator)(
|
|
|
2625
2628
|
summary_index: import_v416.z.number(),
|
|
2626
2629
|
delta: import_v416.z.string()
|
|
2627
2630
|
}),
|
|
2631
|
+
import_v416.z.object({
|
|
2632
|
+
type: import_v416.z.literal("response.reasoning_summary_part.done"),
|
|
2633
|
+
item_id: import_v416.z.string(),
|
|
2634
|
+
summary_index: import_v416.z.number()
|
|
2635
|
+
}),
|
|
2628
2636
|
import_v416.z.object({
|
|
2629
2637
|
type: import_v416.z.literal("error"),
|
|
2630
2638
|
code: import_v416.z.string(),
|
|
@@ -3259,7 +3267,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3259
3267
|
tools: openaiTools2,
|
|
3260
3268
|
tool_choice: openaiToolChoice
|
|
3261
3269
|
},
|
|
3262
|
-
warnings: [...warnings, ...toolWarnings]
|
|
3270
|
+
warnings: [...warnings, ...toolWarnings],
|
|
3271
|
+
store
|
|
3263
3272
|
};
|
|
3264
3273
|
}
|
|
3265
3274
|
async doGenerate(options) {
|
|
@@ -3534,7 +3543,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3534
3543
|
const {
|
|
3535
3544
|
args: body,
|
|
3536
3545
|
warnings,
|
|
3537
|
-
webSearchToolName
|
|
3546
|
+
webSearchToolName,
|
|
3547
|
+
store
|
|
3538
3548
|
} = await this.getArgs(options);
|
|
3539
3549
|
const { responseHeaders, value: response } = await (0, import_provider_utils24.postJsonToApi)({
|
|
3540
3550
|
url: this.config.url({
|
|
@@ -3573,7 +3583,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3573
3583
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3574
3584
|
},
|
|
3575
3585
|
transform(chunk, controller) {
|
|
3576
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v
|
|
3586
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3577
3587
|
if (options.includeRawChunks) {
|
|
3578
3588
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3579
3589
|
}
|
|
@@ -3672,10 +3682,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3672
3682
|
}
|
|
3673
3683
|
}
|
|
3674
3684
|
});
|
|
3675
|
-
} else if (
|
|
3685
|
+
} else if (isResponseOutputItemAddedChunk(value) && value.item.type === "reasoning") {
|
|
3676
3686
|
activeReasoning[value.item.id] = {
|
|
3677
3687
|
encryptedContent: value.item.encrypted_content,
|
|
3678
|
-
summaryParts:
|
|
3688
|
+
summaryParts: { 0: "active" }
|
|
3679
3689
|
};
|
|
3680
3690
|
controller.enqueue({
|
|
3681
3691
|
type: "reasoning-start",
|
|
@@ -3803,9 +3813,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3803
3813
|
type: "text-end",
|
|
3804
3814
|
id: value.item.id
|
|
3805
3815
|
});
|
|
3806
|
-
} else if (
|
|
3816
|
+
} else if (value.item.type === "reasoning") {
|
|
3807
3817
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
3808
|
-
|
|
3818
|
+
const summaryPartIndices = Object.entries(
|
|
3819
|
+
activeReasoningPart.summaryParts
|
|
3820
|
+
).filter(
|
|
3821
|
+
([_, status]) => status === "active" || status === "can-conclude"
|
|
3822
|
+
).map(([summaryIndex]) => summaryIndex);
|
|
3823
|
+
for (const summaryIndex of summaryPartIndices) {
|
|
3809
3824
|
controller.enqueue({
|
|
3810
3825
|
type: "reasoning-end",
|
|
3811
3826
|
id: `${value.item.id}:${summaryIndex}`,
|
|
@@ -3879,23 +3894,34 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3879
3894
|
if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
|
|
3880
3895
|
logprobs.push(value.logprobs);
|
|
3881
3896
|
}
|
|
3882
|
-
} else if (
|
|
3897
|
+
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
3883
3898
|
if (value.summary_index > 0) {
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3899
|
+
const activeReasoningPart = activeReasoning[value.item_id];
|
|
3900
|
+
activeReasoningPart.summaryParts[value.summary_index] = "active";
|
|
3901
|
+
for (const summaryIndex of Object.keys(
|
|
3902
|
+
activeReasoningPart.summaryParts
|
|
3903
|
+
)) {
|
|
3904
|
+
if (activeReasoningPart.summaryParts[summaryIndex] === "can-conclude") {
|
|
3905
|
+
controller.enqueue({
|
|
3906
|
+
type: "reasoning-end",
|
|
3907
|
+
id: `${value.item_id}:${summaryIndex}`,
|
|
3908
|
+
providerMetadata: { openai: { itemId: value.item_id } }
|
|
3909
|
+
});
|
|
3910
|
+
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3887
3913
|
controller.enqueue({
|
|
3888
3914
|
type: "reasoning-start",
|
|
3889
3915
|
id: `${value.item_id}:${value.summary_index}`,
|
|
3890
3916
|
providerMetadata: {
|
|
3891
3917
|
openai: {
|
|
3892
3918
|
itemId: value.item_id,
|
|
3893
|
-
reasoningEncryptedContent: (
|
|
3919
|
+
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
|
|
3894
3920
|
}
|
|
3895
3921
|
}
|
|
3896
3922
|
});
|
|
3897
3923
|
}
|
|
3898
|
-
} else if (
|
|
3924
|
+
} else if (value.type === "response.reasoning_summary_text.delta") {
|
|
3899
3925
|
controller.enqueue({
|
|
3900
3926
|
type: "reasoning-delta",
|
|
3901
3927
|
id: `${value.item_id}:${value.summary_index}`,
|
|
@@ -3906,16 +3932,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3906
3932
|
}
|
|
3907
3933
|
}
|
|
3908
3934
|
});
|
|
3935
|
+
} else if (value.type === "response.reasoning_summary_part.done") {
|
|
3936
|
+
if (store) {
|
|
3937
|
+
controller.enqueue({
|
|
3938
|
+
type: "reasoning-end",
|
|
3939
|
+
id: `${value.item_id}:${value.summary_index}`,
|
|
3940
|
+
providerMetadata: {
|
|
3941
|
+
openai: { itemId: value.item_id }
|
|
3942
|
+
}
|
|
3943
|
+
});
|
|
3944
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
|
|
3945
|
+
} else {
|
|
3946
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
|
|
3947
|
+
}
|
|
3909
3948
|
} else if (isResponseFinishedChunk(value)) {
|
|
3910
3949
|
finishReason = mapOpenAIResponseFinishReason({
|
|
3911
|
-
finishReason: (
|
|
3950
|
+
finishReason: (_i = value.response.incomplete_details) == null ? void 0 : _i.reason,
|
|
3912
3951
|
hasFunctionCall
|
|
3913
3952
|
});
|
|
3914
3953
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
3915
3954
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
3916
3955
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
3917
|
-
usage.reasoningTokens = (
|
|
3918
|
-
usage.cachedInputTokens = (
|
|
3956
|
+
usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? void 0 : _j.reasoning_tokens) != null ? _k : void 0;
|
|
3957
|
+
usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? void 0 : _l.cached_tokens) != null ? _m : void 0;
|
|
3919
3958
|
if (typeof value.response.service_tier === "string") {
|
|
3920
3959
|
serviceTier = value.response.service_tier;
|
|
3921
3960
|
}
|
|
@@ -3924,7 +3963,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3924
3963
|
controller.enqueue({
|
|
3925
3964
|
type: "source",
|
|
3926
3965
|
sourceType: "url",
|
|
3927
|
-
id: (
|
|
3966
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : (0, import_provider_utils24.generateId)(),
|
|
3928
3967
|
url: value.annotation.url,
|
|
3929
3968
|
title: value.annotation.title
|
|
3930
3969
|
});
|
|
@@ -3932,10 +3971,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3932
3971
|
controller.enqueue({
|
|
3933
3972
|
type: "source",
|
|
3934
3973
|
sourceType: "document",
|
|
3935
|
-
id: (
|
|
3974
|
+
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : (0, import_provider_utils24.generateId)(),
|
|
3936
3975
|
mediaType: "text/plain",
|
|
3937
|
-
title: (
|
|
3938
|
-
filename: (
|
|
3976
|
+
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
3977
|
+
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id
|
|
3939
3978
|
});
|
|
3940
3979
|
}
|
|
3941
3980
|
} else if (isErrorChunk(value)) {
|
|
@@ -3974,9 +4013,6 @@ function isTextDeltaChunk(chunk) {
|
|
|
3974
4013
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
3975
4014
|
return chunk.type === "response.output_item.done";
|
|
3976
4015
|
}
|
|
3977
|
-
function isResponseOutputItemDoneReasoningChunk(chunk) {
|
|
3978
|
-
return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
|
|
3979
|
-
}
|
|
3980
4016
|
function isResponseFinishedChunk(chunk) {
|
|
3981
4017
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
3982
4018
|
}
|
|
@@ -3995,18 +4031,9 @@ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
|
3995
4031
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
3996
4032
|
return chunk.type === "response.output_item.added";
|
|
3997
4033
|
}
|
|
3998
|
-
function isResponseOutputItemAddedReasoningChunk(chunk) {
|
|
3999
|
-
return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
|
|
4000
|
-
}
|
|
4001
4034
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
4002
4035
|
return chunk.type === "response.output_text.annotation.added";
|
|
4003
4036
|
}
|
|
4004
|
-
function isResponseReasoningSummaryPartAddedChunk(chunk) {
|
|
4005
|
-
return chunk.type === "response.reasoning_summary_part.added";
|
|
4006
|
-
}
|
|
4007
|
-
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
4008
|
-
return chunk.type === "response.reasoning_summary_text.delta";
|
|
4009
|
-
}
|
|
4010
4037
|
function isErrorChunk(chunk) {
|
|
4011
4038
|
return chunk.type === "error";
|
|
4012
4039
|
}
|
|
@@ -4411,7 +4438,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4411
4438
|
};
|
|
4412
4439
|
|
|
4413
4440
|
// src/version.ts
|
|
4414
|
-
var VERSION = true ? "2.0.
|
|
4441
|
+
var VERSION = true ? "2.0.52" : "0.0.0-test";
|
|
4415
4442
|
|
|
4416
4443
|
// src/openai-provider.ts
|
|
4417
4444
|
function createOpenAI(options = {}) {
|