@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/dist/index.mjs
CHANGED
|
@@ -2348,6 +2348,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2348
2348
|
input.push(reasoningMessages[reasoningId]);
|
|
2349
2349
|
} else {
|
|
2350
2350
|
reasoningMessage.summary.push(...summaryParts);
|
|
2351
|
+
if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
|
|
2352
|
+
reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
|
|
2353
|
+
}
|
|
2351
2354
|
}
|
|
2352
2355
|
}
|
|
2353
2356
|
} else {
|
|
@@ -2693,6 +2696,11 @@ var openaiResponsesChunkSchema = lazyValidator8(
|
|
|
2693
2696
|
summary_index: z16.number(),
|
|
2694
2697
|
delta: z16.string()
|
|
2695
2698
|
}),
|
|
2699
|
+
z16.object({
|
|
2700
|
+
type: z16.literal("response.reasoning_summary_part.done"),
|
|
2701
|
+
item_id: z16.string(),
|
|
2702
|
+
summary_index: z16.number()
|
|
2703
|
+
}),
|
|
2696
2704
|
z16.object({
|
|
2697
2705
|
type: z16.literal("error"),
|
|
2698
2706
|
code: z16.string(),
|
|
@@ -3332,7 +3340,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3332
3340
|
tools: openaiTools2,
|
|
3333
3341
|
tool_choice: openaiToolChoice
|
|
3334
3342
|
},
|
|
3335
|
-
warnings: [...warnings, ...toolWarnings]
|
|
3343
|
+
warnings: [...warnings, ...toolWarnings],
|
|
3344
|
+
store
|
|
3336
3345
|
};
|
|
3337
3346
|
}
|
|
3338
3347
|
async doGenerate(options) {
|
|
@@ -3607,7 +3616,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3607
3616
|
const {
|
|
3608
3617
|
args: body,
|
|
3609
3618
|
warnings,
|
|
3610
|
-
webSearchToolName
|
|
3619
|
+
webSearchToolName,
|
|
3620
|
+
store
|
|
3611
3621
|
} = await this.getArgs(options);
|
|
3612
3622
|
const { responseHeaders, value: response } = await postJsonToApi5({
|
|
3613
3623
|
url: this.config.url({
|
|
@@ -3646,7 +3656,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3646
3656
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3647
3657
|
},
|
|
3648
3658
|
transform(chunk, controller) {
|
|
3649
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v
|
|
3659
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3650
3660
|
if (options.includeRawChunks) {
|
|
3651
3661
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3652
3662
|
}
|
|
@@ -3745,10 +3755,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3745
3755
|
}
|
|
3746
3756
|
}
|
|
3747
3757
|
});
|
|
3748
|
-
} else if (
|
|
3758
|
+
} else if (isResponseOutputItemAddedChunk(value) && value.item.type === "reasoning") {
|
|
3749
3759
|
activeReasoning[value.item.id] = {
|
|
3750
3760
|
encryptedContent: value.item.encrypted_content,
|
|
3751
|
-
summaryParts:
|
|
3761
|
+
summaryParts: { 0: "active" }
|
|
3752
3762
|
};
|
|
3753
3763
|
controller.enqueue({
|
|
3754
3764
|
type: "reasoning-start",
|
|
@@ -3876,9 +3886,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3876
3886
|
type: "text-end",
|
|
3877
3887
|
id: value.item.id
|
|
3878
3888
|
});
|
|
3879
|
-
} else if (
|
|
3889
|
+
} else if (value.item.type === "reasoning") {
|
|
3880
3890
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
3881
|
-
|
|
3891
|
+
const summaryPartIndices = Object.entries(
|
|
3892
|
+
activeReasoningPart.summaryParts
|
|
3893
|
+
).filter(
|
|
3894
|
+
([_, status]) => status === "active" || status === "can-conclude"
|
|
3895
|
+
).map(([summaryIndex]) => summaryIndex);
|
|
3896
|
+
for (const summaryIndex of summaryPartIndices) {
|
|
3882
3897
|
controller.enqueue({
|
|
3883
3898
|
type: "reasoning-end",
|
|
3884
3899
|
id: `${value.item.id}:${summaryIndex}`,
|
|
@@ -3952,23 +3967,34 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3952
3967
|
if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
|
|
3953
3968
|
logprobs.push(value.logprobs);
|
|
3954
3969
|
}
|
|
3955
|
-
} else if (
|
|
3970
|
+
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
3956
3971
|
if (value.summary_index > 0) {
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3972
|
+
const activeReasoningPart = activeReasoning[value.item_id];
|
|
3973
|
+
activeReasoningPart.summaryParts[value.summary_index] = "active";
|
|
3974
|
+
for (const summaryIndex of Object.keys(
|
|
3975
|
+
activeReasoningPart.summaryParts
|
|
3976
|
+
)) {
|
|
3977
|
+
if (activeReasoningPart.summaryParts[summaryIndex] === "can-conclude") {
|
|
3978
|
+
controller.enqueue({
|
|
3979
|
+
type: "reasoning-end",
|
|
3980
|
+
id: `${value.item_id}:${summaryIndex}`,
|
|
3981
|
+
providerMetadata: { openai: { itemId: value.item_id } }
|
|
3982
|
+
});
|
|
3983
|
+
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3960
3986
|
controller.enqueue({
|
|
3961
3987
|
type: "reasoning-start",
|
|
3962
3988
|
id: `${value.item_id}:${value.summary_index}`,
|
|
3963
3989
|
providerMetadata: {
|
|
3964
3990
|
openai: {
|
|
3965
3991
|
itemId: value.item_id,
|
|
3966
|
-
reasoningEncryptedContent: (
|
|
3992
|
+
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
|
|
3967
3993
|
}
|
|
3968
3994
|
}
|
|
3969
3995
|
});
|
|
3970
3996
|
}
|
|
3971
|
-
} else if (
|
|
3997
|
+
} else if (value.type === "response.reasoning_summary_text.delta") {
|
|
3972
3998
|
controller.enqueue({
|
|
3973
3999
|
type: "reasoning-delta",
|
|
3974
4000
|
id: `${value.item_id}:${value.summary_index}`,
|
|
@@ -3979,16 +4005,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3979
4005
|
}
|
|
3980
4006
|
}
|
|
3981
4007
|
});
|
|
4008
|
+
} else if (value.type === "response.reasoning_summary_part.done") {
|
|
4009
|
+
if (store) {
|
|
4010
|
+
controller.enqueue({
|
|
4011
|
+
type: "reasoning-end",
|
|
4012
|
+
id: `${value.item_id}:${value.summary_index}`,
|
|
4013
|
+
providerMetadata: {
|
|
4014
|
+
openai: { itemId: value.item_id }
|
|
4015
|
+
}
|
|
4016
|
+
});
|
|
4017
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
|
|
4018
|
+
} else {
|
|
4019
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
|
|
4020
|
+
}
|
|
3982
4021
|
} else if (isResponseFinishedChunk(value)) {
|
|
3983
4022
|
finishReason = mapOpenAIResponseFinishReason({
|
|
3984
|
-
finishReason: (
|
|
4023
|
+
finishReason: (_i = value.response.incomplete_details) == null ? void 0 : _i.reason,
|
|
3985
4024
|
hasFunctionCall
|
|
3986
4025
|
});
|
|
3987
4026
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
3988
4027
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
3989
4028
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
3990
|
-
usage.reasoningTokens = (
|
|
3991
|
-
usage.cachedInputTokens = (
|
|
4029
|
+
usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? void 0 : _j.reasoning_tokens) != null ? _k : void 0;
|
|
4030
|
+
usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? void 0 : _l.cached_tokens) != null ? _m : void 0;
|
|
3992
4031
|
if (typeof value.response.service_tier === "string") {
|
|
3993
4032
|
serviceTier = value.response.service_tier;
|
|
3994
4033
|
}
|
|
@@ -3997,7 +4036,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3997
4036
|
controller.enqueue({
|
|
3998
4037
|
type: "source",
|
|
3999
4038
|
sourceType: "url",
|
|
4000
|
-
id: (
|
|
4039
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : generateId2(),
|
|
4001
4040
|
url: value.annotation.url,
|
|
4002
4041
|
title: value.annotation.title
|
|
4003
4042
|
});
|
|
@@ -4005,10 +4044,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4005
4044
|
controller.enqueue({
|
|
4006
4045
|
type: "source",
|
|
4007
4046
|
sourceType: "document",
|
|
4008
|
-
id: (
|
|
4047
|
+
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : generateId2(),
|
|
4009
4048
|
mediaType: "text/plain",
|
|
4010
|
-
title: (
|
|
4011
|
-
filename: (
|
|
4049
|
+
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
4050
|
+
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id
|
|
4012
4051
|
});
|
|
4013
4052
|
}
|
|
4014
4053
|
} else if (isErrorChunk(value)) {
|
|
@@ -4047,9 +4086,6 @@ function isTextDeltaChunk(chunk) {
|
|
|
4047
4086
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
4048
4087
|
return chunk.type === "response.output_item.done";
|
|
4049
4088
|
}
|
|
4050
|
-
function isResponseOutputItemDoneReasoningChunk(chunk) {
|
|
4051
|
-
return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
|
|
4052
|
-
}
|
|
4053
4089
|
function isResponseFinishedChunk(chunk) {
|
|
4054
4090
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
4055
4091
|
}
|
|
@@ -4068,18 +4104,9 @@ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
|
4068
4104
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
4069
4105
|
return chunk.type === "response.output_item.added";
|
|
4070
4106
|
}
|
|
4071
|
-
function isResponseOutputItemAddedReasoningChunk(chunk) {
|
|
4072
|
-
return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
|
|
4073
|
-
}
|
|
4074
4107
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
4075
4108
|
return chunk.type === "response.output_text.annotation.added";
|
|
4076
4109
|
}
|
|
4077
|
-
function isResponseReasoningSummaryPartAddedChunk(chunk) {
|
|
4078
|
-
return chunk.type === "response.reasoning_summary_part.added";
|
|
4079
|
-
}
|
|
4080
|
-
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
4081
|
-
return chunk.type === "response.reasoning_summary_text.delta";
|
|
4082
|
-
}
|
|
4083
4110
|
function isErrorChunk(chunk) {
|
|
4084
4111
|
return chunk.type === "error";
|
|
4085
4112
|
}
|
|
@@ -4502,7 +4529,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4502
4529
|
};
|
|
4503
4530
|
|
|
4504
4531
|
// src/version.ts
|
|
4505
|
-
var VERSION = true ? "2.0.
|
|
4532
|
+
var VERSION = true ? "2.0.52" : "0.0.0-test";
|
|
4506
4533
|
|
|
4507
4534
|
// src/openai-provider.ts
|
|
4508
4535
|
function createOpenAI(options = {}) {
|