@ai-sdk/openai 3.0.0-beta.28 → 3.0.0-beta.29
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
|
@@ -2292,6 +2292,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2292
2292
|
input.push(reasoningMessages[reasoningId]);
|
|
2293
2293
|
} else {
|
|
2294
2294
|
reasoningMessage.summary.push(...summaryParts);
|
|
2295
|
+
if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
|
|
2296
|
+
reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
|
|
2297
|
+
}
|
|
2295
2298
|
}
|
|
2296
2299
|
}
|
|
2297
2300
|
} else {
|
|
@@ -2637,6 +2640,11 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2637
2640
|
summary_index: import_v416.z.number(),
|
|
2638
2641
|
delta: import_v416.z.string()
|
|
2639
2642
|
}),
|
|
2643
|
+
import_v416.z.object({
|
|
2644
|
+
type: import_v416.z.literal("response.reasoning_summary_part.done"),
|
|
2645
|
+
item_id: import_v416.z.string(),
|
|
2646
|
+
summary_index: import_v416.z.number()
|
|
2647
|
+
}),
|
|
2640
2648
|
import_v416.z.object({
|
|
2641
2649
|
type: import_v416.z.literal("error"),
|
|
2642
2650
|
code: import_v416.z.string(),
|
|
@@ -3272,7 +3280,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3272
3280
|
tools: openaiTools2,
|
|
3273
3281
|
tool_choice: openaiToolChoice
|
|
3274
3282
|
},
|
|
3275
|
-
warnings: [...warnings, ...toolWarnings]
|
|
3283
|
+
warnings: [...warnings, ...toolWarnings],
|
|
3284
|
+
store
|
|
3276
3285
|
};
|
|
3277
3286
|
}
|
|
3278
3287
|
async doGenerate(options) {
|
|
@@ -3547,7 +3556,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3547
3556
|
const {
|
|
3548
3557
|
args: body,
|
|
3549
3558
|
warnings,
|
|
3550
|
-
webSearchToolName
|
|
3559
|
+
webSearchToolName,
|
|
3560
|
+
store
|
|
3551
3561
|
} = await this.getArgs(options);
|
|
3552
3562
|
const { responseHeaders, value: response } = await (0, import_provider_utils24.postJsonToApi)({
|
|
3553
3563
|
url: this.config.url({
|
|
@@ -3586,7 +3596,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3586
3596
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3587
3597
|
},
|
|
3588
3598
|
transform(chunk, controller) {
|
|
3589
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v
|
|
3599
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3590
3600
|
if (options.includeRawChunks) {
|
|
3591
3601
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3592
3602
|
}
|
|
@@ -3685,10 +3695,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3685
3695
|
}
|
|
3686
3696
|
}
|
|
3687
3697
|
});
|
|
3688
|
-
} else if (
|
|
3698
|
+
} else if (isResponseOutputItemAddedChunk(value) && value.item.type === "reasoning") {
|
|
3689
3699
|
activeReasoning[value.item.id] = {
|
|
3690
3700
|
encryptedContent: value.item.encrypted_content,
|
|
3691
|
-
summaryParts:
|
|
3701
|
+
summaryParts: { 0: "active" }
|
|
3692
3702
|
};
|
|
3693
3703
|
controller.enqueue({
|
|
3694
3704
|
type: "reasoning-start",
|
|
@@ -3816,9 +3826,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3816
3826
|
type: "text-end",
|
|
3817
3827
|
id: value.item.id
|
|
3818
3828
|
});
|
|
3819
|
-
} else if (
|
|
3829
|
+
} else if (value.item.type === "reasoning") {
|
|
3820
3830
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
3821
|
-
|
|
3831
|
+
const summaryPartIndices = Object.entries(
|
|
3832
|
+
activeReasoningPart.summaryParts
|
|
3833
|
+
).filter(
|
|
3834
|
+
([_, status]) => status === "active" || status === "can-conclude"
|
|
3835
|
+
).map(([summaryIndex]) => summaryIndex);
|
|
3836
|
+
for (const summaryIndex of summaryPartIndices) {
|
|
3822
3837
|
controller.enqueue({
|
|
3823
3838
|
type: "reasoning-end",
|
|
3824
3839
|
id: `${value.item.id}:${summaryIndex}`,
|
|
@@ -3903,23 +3918,34 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3903
3918
|
if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
|
|
3904
3919
|
logprobs.push(value.logprobs);
|
|
3905
3920
|
}
|
|
3906
|
-
} else if (
|
|
3921
|
+
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
3907
3922
|
if (value.summary_index > 0) {
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3923
|
+
const activeReasoningPart = activeReasoning[value.item_id];
|
|
3924
|
+
activeReasoningPart.summaryParts[value.summary_index] = "active";
|
|
3925
|
+
for (const summaryIndex of Object.keys(
|
|
3926
|
+
activeReasoningPart.summaryParts
|
|
3927
|
+
)) {
|
|
3928
|
+
if (activeReasoningPart.summaryParts[summaryIndex] === "can-conclude") {
|
|
3929
|
+
controller.enqueue({
|
|
3930
|
+
type: "reasoning-end",
|
|
3931
|
+
id: `${value.item_id}:${summaryIndex}`,
|
|
3932
|
+
providerMetadata: { openai: { itemId: value.item_id } }
|
|
3933
|
+
});
|
|
3934
|
+
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3911
3937
|
controller.enqueue({
|
|
3912
3938
|
type: "reasoning-start",
|
|
3913
3939
|
id: `${value.item_id}:${value.summary_index}`,
|
|
3914
3940
|
providerMetadata: {
|
|
3915
3941
|
openai: {
|
|
3916
3942
|
itemId: value.item_id,
|
|
3917
|
-
reasoningEncryptedContent: (
|
|
3943
|
+
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
|
|
3918
3944
|
}
|
|
3919
3945
|
}
|
|
3920
3946
|
});
|
|
3921
3947
|
}
|
|
3922
|
-
} else if (
|
|
3948
|
+
} else if (value.type === "response.reasoning_summary_text.delta") {
|
|
3923
3949
|
controller.enqueue({
|
|
3924
3950
|
type: "reasoning-delta",
|
|
3925
3951
|
id: `${value.item_id}:${value.summary_index}`,
|
|
@@ -3930,16 +3956,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3930
3956
|
}
|
|
3931
3957
|
}
|
|
3932
3958
|
});
|
|
3959
|
+
} else if (value.type === "response.reasoning_summary_part.done") {
|
|
3960
|
+
if (store) {
|
|
3961
|
+
controller.enqueue({
|
|
3962
|
+
type: "reasoning-end",
|
|
3963
|
+
id: `${value.item_id}:${value.summary_index}`,
|
|
3964
|
+
providerMetadata: {
|
|
3965
|
+
openai: { itemId: value.item_id }
|
|
3966
|
+
}
|
|
3967
|
+
});
|
|
3968
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
|
|
3969
|
+
} else {
|
|
3970
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
|
|
3971
|
+
}
|
|
3933
3972
|
} else if (isResponseFinishedChunk(value)) {
|
|
3934
3973
|
finishReason = mapOpenAIResponseFinishReason({
|
|
3935
|
-
finishReason: (
|
|
3974
|
+
finishReason: (_i = value.response.incomplete_details) == null ? void 0 : _i.reason,
|
|
3936
3975
|
hasFunctionCall
|
|
3937
3976
|
});
|
|
3938
3977
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
3939
3978
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
3940
3979
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
3941
|
-
usage.reasoningTokens = (
|
|
3942
|
-
usage.cachedInputTokens = (
|
|
3980
|
+
usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? void 0 : _j.reasoning_tokens) != null ? _k : void 0;
|
|
3981
|
+
usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? void 0 : _l.cached_tokens) != null ? _m : void 0;
|
|
3943
3982
|
if (typeof value.response.service_tier === "string") {
|
|
3944
3983
|
serviceTier = value.response.service_tier;
|
|
3945
3984
|
}
|
|
@@ -3948,7 +3987,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3948
3987
|
controller.enqueue({
|
|
3949
3988
|
type: "source",
|
|
3950
3989
|
sourceType: "url",
|
|
3951
|
-
id: (
|
|
3990
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : (0, import_provider_utils24.generateId)(),
|
|
3952
3991
|
url: value.annotation.url,
|
|
3953
3992
|
title: value.annotation.title
|
|
3954
3993
|
});
|
|
@@ -3956,10 +3995,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3956
3995
|
controller.enqueue({
|
|
3957
3996
|
type: "source",
|
|
3958
3997
|
sourceType: "document",
|
|
3959
|
-
id: (
|
|
3998
|
+
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : (0, import_provider_utils24.generateId)(),
|
|
3960
3999
|
mediaType: "text/plain",
|
|
3961
|
-
title: (
|
|
3962
|
-
filename: (
|
|
4000
|
+
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
4001
|
+
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id
|
|
3963
4002
|
});
|
|
3964
4003
|
}
|
|
3965
4004
|
} else if (isErrorChunk(value)) {
|
|
@@ -3998,9 +4037,6 @@ function isTextDeltaChunk(chunk) {
|
|
|
3998
4037
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
3999
4038
|
return chunk.type === "response.output_item.done";
|
|
4000
4039
|
}
|
|
4001
|
-
function isResponseOutputItemDoneReasoningChunk(chunk) {
|
|
4002
|
-
return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
|
|
4003
|
-
}
|
|
4004
4040
|
function isResponseFinishedChunk(chunk) {
|
|
4005
4041
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
4006
4042
|
}
|
|
@@ -4022,18 +4058,9 @@ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
|
4022
4058
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
4023
4059
|
return chunk.type === "response.output_item.added";
|
|
4024
4060
|
}
|
|
4025
|
-
function isResponseOutputItemAddedReasoningChunk(chunk) {
|
|
4026
|
-
return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
|
|
4027
|
-
}
|
|
4028
4061
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
4029
4062
|
return chunk.type === "response.output_text.annotation.added";
|
|
4030
4063
|
}
|
|
4031
|
-
function isResponseReasoningSummaryPartAddedChunk(chunk) {
|
|
4032
|
-
return chunk.type === "response.reasoning_summary_part.added";
|
|
4033
|
-
}
|
|
4034
|
-
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
4035
|
-
return chunk.type === "response.reasoning_summary_text.delta";
|
|
4036
|
-
}
|
|
4037
4064
|
function isErrorChunk(chunk) {
|
|
4038
4065
|
return chunk.type === "error";
|
|
4039
4066
|
}
|
|
@@ -4438,7 +4465,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4438
4465
|
};
|
|
4439
4466
|
|
|
4440
4467
|
// src/version.ts
|
|
4441
|
-
var VERSION = true ? "3.0.0-beta.
|
|
4468
|
+
var VERSION = true ? "3.0.0-beta.29" : "0.0.0-test";
|
|
4442
4469
|
|
|
4443
4470
|
// src/openai-provider.ts
|
|
4444
4471
|
function createOpenAI(options = {}) {
|