@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/dist/index.mjs
CHANGED
|
@@ -2342,6 +2342,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2342
2342
|
input.push(reasoningMessages[reasoningId]);
|
|
2343
2343
|
} else {
|
|
2344
2344
|
reasoningMessage.summary.push(...summaryParts);
|
|
2345
|
+
if ((providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent) != null) {
|
|
2346
|
+
reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
|
|
2347
|
+
}
|
|
2345
2348
|
}
|
|
2346
2349
|
}
|
|
2347
2350
|
} else {
|
|
@@ -2687,6 +2690,11 @@ var openaiResponsesChunkSchema = lazySchema14(
|
|
|
2687
2690
|
summary_index: z16.number(),
|
|
2688
2691
|
delta: z16.string()
|
|
2689
2692
|
}),
|
|
2693
|
+
z16.object({
|
|
2694
|
+
type: z16.literal("response.reasoning_summary_part.done"),
|
|
2695
|
+
item_id: z16.string(),
|
|
2696
|
+
summary_index: z16.number()
|
|
2697
|
+
}),
|
|
2690
2698
|
z16.object({
|
|
2691
2699
|
type: z16.literal("error"),
|
|
2692
2700
|
code: z16.string(),
|
|
@@ -3324,7 +3332,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3324
3332
|
tools: openaiTools2,
|
|
3325
3333
|
tool_choice: openaiToolChoice
|
|
3326
3334
|
},
|
|
3327
|
-
warnings: [...warnings, ...toolWarnings]
|
|
3335
|
+
warnings: [...warnings, ...toolWarnings],
|
|
3336
|
+
store
|
|
3328
3337
|
};
|
|
3329
3338
|
}
|
|
3330
3339
|
async doGenerate(options) {
|
|
@@ -3599,7 +3608,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3599
3608
|
const {
|
|
3600
3609
|
args: body,
|
|
3601
3610
|
warnings,
|
|
3602
|
-
webSearchToolName
|
|
3611
|
+
webSearchToolName,
|
|
3612
|
+
store
|
|
3603
3613
|
} = await this.getArgs(options);
|
|
3604
3614
|
const { responseHeaders, value: response } = await postJsonToApi5({
|
|
3605
3615
|
url: this.config.url({
|
|
@@ -3638,7 +3648,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3638
3648
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3639
3649
|
},
|
|
3640
3650
|
transform(chunk, controller) {
|
|
3641
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v
|
|
3651
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3642
3652
|
if (options.includeRawChunks) {
|
|
3643
3653
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3644
3654
|
}
|
|
@@ -3737,10 +3747,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3737
3747
|
}
|
|
3738
3748
|
}
|
|
3739
3749
|
});
|
|
3740
|
-
} else if (
|
|
3750
|
+
} else if (isResponseOutputItemAddedChunk(value) && value.item.type === "reasoning") {
|
|
3741
3751
|
activeReasoning[value.item.id] = {
|
|
3742
3752
|
encryptedContent: value.item.encrypted_content,
|
|
3743
|
-
summaryParts:
|
|
3753
|
+
summaryParts: { 0: "active" }
|
|
3744
3754
|
};
|
|
3745
3755
|
controller.enqueue({
|
|
3746
3756
|
type: "reasoning-start",
|
|
@@ -3868,9 +3878,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3868
3878
|
type: "text-end",
|
|
3869
3879
|
id: value.item.id
|
|
3870
3880
|
});
|
|
3871
|
-
} else if (
|
|
3881
|
+
} else if (value.item.type === "reasoning") {
|
|
3872
3882
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
3873
|
-
|
|
3883
|
+
const summaryPartIndices = Object.entries(
|
|
3884
|
+
activeReasoningPart.summaryParts
|
|
3885
|
+
).filter(
|
|
3886
|
+
([_, status]) => status === "active" || status === "can-conclude"
|
|
3887
|
+
).map(([summaryIndex]) => summaryIndex);
|
|
3888
|
+
for (const summaryIndex of summaryPartIndices) {
|
|
3874
3889
|
controller.enqueue({
|
|
3875
3890
|
type: "reasoning-end",
|
|
3876
3891
|
id: `${value.item.id}:${summaryIndex}`,
|
|
@@ -3955,23 +3970,34 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3955
3970
|
if (((_f = (_e = options.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.logprobs) && value.logprobs) {
|
|
3956
3971
|
logprobs.push(value.logprobs);
|
|
3957
3972
|
}
|
|
3958
|
-
} else if (
|
|
3973
|
+
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
3959
3974
|
if (value.summary_index > 0) {
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3975
|
+
const activeReasoningPart = activeReasoning[value.item_id];
|
|
3976
|
+
activeReasoningPart.summaryParts[value.summary_index] = "active";
|
|
3977
|
+
for (const summaryIndex of Object.keys(
|
|
3978
|
+
activeReasoningPart.summaryParts
|
|
3979
|
+
)) {
|
|
3980
|
+
if (activeReasoningPart.summaryParts[summaryIndex] === "can-conclude") {
|
|
3981
|
+
controller.enqueue({
|
|
3982
|
+
type: "reasoning-end",
|
|
3983
|
+
id: `${value.item_id}:${summaryIndex}`,
|
|
3984
|
+
providerMetadata: { openai: { itemId: value.item_id } }
|
|
3985
|
+
});
|
|
3986
|
+
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3963
3989
|
controller.enqueue({
|
|
3964
3990
|
type: "reasoning-start",
|
|
3965
3991
|
id: `${value.item_id}:${value.summary_index}`,
|
|
3966
3992
|
providerMetadata: {
|
|
3967
3993
|
openai: {
|
|
3968
3994
|
itemId: value.item_id,
|
|
3969
|
-
reasoningEncryptedContent: (
|
|
3995
|
+
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
|
|
3970
3996
|
}
|
|
3971
3997
|
}
|
|
3972
3998
|
});
|
|
3973
3999
|
}
|
|
3974
|
-
} else if (
|
|
4000
|
+
} else if (value.type === "response.reasoning_summary_text.delta") {
|
|
3975
4001
|
controller.enqueue({
|
|
3976
4002
|
type: "reasoning-delta",
|
|
3977
4003
|
id: `${value.item_id}:${value.summary_index}`,
|
|
@@ -3982,16 +4008,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3982
4008
|
}
|
|
3983
4009
|
}
|
|
3984
4010
|
});
|
|
4011
|
+
} else if (value.type === "response.reasoning_summary_part.done") {
|
|
4012
|
+
if (store) {
|
|
4013
|
+
controller.enqueue({
|
|
4014
|
+
type: "reasoning-end",
|
|
4015
|
+
id: `${value.item_id}:${value.summary_index}`,
|
|
4016
|
+
providerMetadata: {
|
|
4017
|
+
openai: { itemId: value.item_id }
|
|
4018
|
+
}
|
|
4019
|
+
});
|
|
4020
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
|
|
4021
|
+
} else {
|
|
4022
|
+
activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
|
|
4023
|
+
}
|
|
3985
4024
|
} else if (isResponseFinishedChunk(value)) {
|
|
3986
4025
|
finishReason = mapOpenAIResponseFinishReason({
|
|
3987
|
-
finishReason: (
|
|
4026
|
+
finishReason: (_i = value.response.incomplete_details) == null ? void 0 : _i.reason,
|
|
3988
4027
|
hasFunctionCall
|
|
3989
4028
|
});
|
|
3990
4029
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
3991
4030
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
3992
4031
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
3993
|
-
usage.reasoningTokens = (
|
|
3994
|
-
usage.cachedInputTokens = (
|
|
4032
|
+
usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? void 0 : _j.reasoning_tokens) != null ? _k : void 0;
|
|
4033
|
+
usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? void 0 : _l.cached_tokens) != null ? _m : void 0;
|
|
3995
4034
|
if (typeof value.response.service_tier === "string") {
|
|
3996
4035
|
serviceTier = value.response.service_tier;
|
|
3997
4036
|
}
|
|
@@ -4000,7 +4039,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4000
4039
|
controller.enqueue({
|
|
4001
4040
|
type: "source",
|
|
4002
4041
|
sourceType: "url",
|
|
4003
|
-
id: (
|
|
4042
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : generateId2(),
|
|
4004
4043
|
url: value.annotation.url,
|
|
4005
4044
|
title: value.annotation.title
|
|
4006
4045
|
});
|
|
@@ -4008,10 +4047,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4008
4047
|
controller.enqueue({
|
|
4009
4048
|
type: "source",
|
|
4010
4049
|
sourceType: "document",
|
|
4011
|
-
id: (
|
|
4050
|
+
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : generateId2(),
|
|
4012
4051
|
mediaType: "text/plain",
|
|
4013
|
-
title: (
|
|
4014
|
-
filename: (
|
|
4052
|
+
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
4053
|
+
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id
|
|
4015
4054
|
});
|
|
4016
4055
|
}
|
|
4017
4056
|
} else if (isErrorChunk(value)) {
|
|
@@ -4050,9 +4089,6 @@ function isTextDeltaChunk(chunk) {
|
|
|
4050
4089
|
function isResponseOutputItemDoneChunk(chunk) {
|
|
4051
4090
|
return chunk.type === "response.output_item.done";
|
|
4052
4091
|
}
|
|
4053
|
-
function isResponseOutputItemDoneReasoningChunk(chunk) {
|
|
4054
|
-
return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
|
|
4055
|
-
}
|
|
4056
4092
|
function isResponseFinishedChunk(chunk) {
|
|
4057
4093
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
4058
4094
|
}
|
|
@@ -4074,18 +4110,9 @@ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
|
4074
4110
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
4075
4111
|
return chunk.type === "response.output_item.added";
|
|
4076
4112
|
}
|
|
4077
|
-
function isResponseOutputItemAddedReasoningChunk(chunk) {
|
|
4078
|
-
return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
|
|
4079
|
-
}
|
|
4080
4113
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
4081
4114
|
return chunk.type === "response.output_text.annotation.added";
|
|
4082
4115
|
}
|
|
4083
|
-
function isResponseReasoningSummaryPartAddedChunk(chunk) {
|
|
4084
|
-
return chunk.type === "response.reasoning_summary_part.added";
|
|
4085
|
-
}
|
|
4086
|
-
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
4087
|
-
return chunk.type === "response.reasoning_summary_text.delta";
|
|
4088
|
-
}
|
|
4089
4116
|
function isErrorChunk(chunk) {
|
|
4090
4117
|
return chunk.type === "error";
|
|
4091
4118
|
}
|
|
@@ -4502,7 +4529,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4502
4529
|
};
|
|
4503
4530
|
|
|
4504
4531
|
// src/version.ts
|
|
4505
|
-
var VERSION = true ? "3.0.0-beta.
|
|
4532
|
+
var VERSION = true ? "3.0.0-beta.29" : "0.0.0-test";
|
|
4506
4533
|
|
|
4507
4534
|
// src/openai-provider.ts
|
|
4508
4535
|
function createOpenAI(options = {}) {
|