@ai-sdk/openai 4.0.33 → 4.0.35
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 +14 -0
- package/dist/index.d.ts +18 -14
- package/dist/index.js +137 -89
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +4 -0
- package/dist/internal/index.js +117 -70
- package/dist/internal/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +12 -4
- package/src/openai-provider.ts +13 -9
- package/src/responses/openai-responses-api.ts +4 -0
- package/src/responses/openai-responses-language-model.ts +136 -89
- package/src/speech-translation/openai-speech-translation-model-options.ts +18 -0
- package/src/{translation/openai-translation-model.ts → speech-translation/openai-speech-translation-model.ts} +22 -22
- package/src/translation/openai-translation-model-options.ts +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.35
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [1937bef]
|
|
8
|
+
- @ai-sdk/provider-utils@5.0.24
|
|
9
|
+
|
|
10
|
+
## 4.0.34
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 73d48d0: fix(provider/openai): correlate rotating Responses API item IDs by output index
|
|
15
|
+
- bbd9b31: chore: rename `*TranslationModel` and its related types to `*SpeechTranslationModel` for consistency
|
|
16
|
+
|
|
3
17
|
## 4.0.33
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -240,6 +240,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
240
240
|
type: "response.output_text.delta";
|
|
241
241
|
item_id: string;
|
|
242
242
|
delta: string;
|
|
243
|
+
output_index?: number | null | undefined;
|
|
243
244
|
logprobs?: {
|
|
244
245
|
token: string;
|
|
245
246
|
logprob: number;
|
|
@@ -895,15 +896,18 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
895
896
|
type: "response.reasoning_summary_part.added";
|
|
896
897
|
item_id: string;
|
|
897
898
|
summary_index: number;
|
|
899
|
+
output_index?: number | null | undefined;
|
|
898
900
|
} | {
|
|
899
901
|
type: "response.reasoning_summary_text.delta";
|
|
900
902
|
item_id: string;
|
|
901
903
|
summary_index: number;
|
|
902
904
|
delta: string;
|
|
905
|
+
output_index?: number | null | undefined;
|
|
903
906
|
} | {
|
|
904
907
|
type: "response.reasoning_summary_part.done";
|
|
905
908
|
item_id: string;
|
|
906
909
|
summary_index: number;
|
|
910
|
+
output_index?: number | null | undefined;
|
|
907
911
|
} | {
|
|
908
912
|
type: "response.apply_patch_call_operation_diff.delta";
|
|
909
913
|
item_id: string;
|
|
@@ -1403,9 +1407,9 @@ declare const openAITranscriptionModelOptions: _ai_sdk_provider_utils.LazySchema
|
|
|
1403
1407
|
}>;
|
|
1404
1408
|
type OpenAITranscriptionModelOptions = InferSchema<typeof openAITranscriptionModelOptions>;
|
|
1405
1409
|
|
|
1406
|
-
type
|
|
1407
|
-
declare const
|
|
1408
|
-
type
|
|
1410
|
+
type OpenAISpeechTranslationModelId = 'gpt-realtime-translate' | (string & {});
|
|
1411
|
+
declare const openAISpeechTranslationModelOptions: _ai_sdk_provider_utils.LazySchema<Record<string, never>>;
|
|
1412
|
+
type OpenAISpeechTranslationModelOptions = InferSchema<typeof openAISpeechTranslationModelOptions>;
|
|
1409
1413
|
|
|
1410
1414
|
interface OpenAIProvider extends ProviderV4 {
|
|
1411
1415
|
(modelId: OpenAIResponsesModelId): Experimental_BatchLanguageModelV4;
|
|
@@ -1456,11 +1460,11 @@ interface OpenAIProvider extends ProviderV4 {
|
|
|
1456
1460
|
/**
|
|
1457
1461
|
* Creates an experimental model for streaming speech translation.
|
|
1458
1462
|
*/
|
|
1459
|
-
translation(modelId:
|
|
1463
|
+
translation(modelId: OpenAISpeechTranslationModelId): Experimental_SpeechTranslationModelV4;
|
|
1460
1464
|
/**
|
|
1461
1465
|
* Creates an experimental model for streaming speech translation.
|
|
1462
1466
|
*/
|
|
1463
|
-
speechTranslationModel(modelId:
|
|
1467
|
+
speechTranslationModel(modelId: OpenAISpeechTranslationModelId): Experimental_SpeechTranslationModelV4;
|
|
1464
1468
|
/**
|
|
1465
1469
|
* Creates a model for speech generation.
|
|
1466
1470
|
*/
|
|
@@ -1584,25 +1588,25 @@ type OpenAIConfig = {
|
|
|
1584
1588
|
fileIdPrefixes?: readonly string[];
|
|
1585
1589
|
};
|
|
1586
1590
|
|
|
1587
|
-
interface
|
|
1591
|
+
interface OpenAISpeechTranslationModelConfig extends OpenAIConfig {
|
|
1588
1592
|
_internal?: {
|
|
1589
1593
|
currentDate?: () => Date;
|
|
1590
1594
|
};
|
|
1591
1595
|
}
|
|
1592
|
-
declare class
|
|
1593
|
-
readonly modelId:
|
|
1596
|
+
declare class OpenAISpeechTranslationModel implements Experimental_SpeechTranslationModelV4 {
|
|
1597
|
+
readonly modelId: OpenAISpeechTranslationModelId;
|
|
1594
1598
|
private readonly config;
|
|
1595
1599
|
readonly specificationVersion = "v4";
|
|
1596
|
-
static [WORKFLOW_SERIALIZE](model:
|
|
1600
|
+
static [WORKFLOW_SERIALIZE](model: OpenAISpeechTranslationModel): {
|
|
1597
1601
|
modelId: string;
|
|
1598
1602
|
config: _ai_sdk_provider.JSONObject;
|
|
1599
1603
|
};
|
|
1600
1604
|
static [WORKFLOW_DESERIALIZE](options: {
|
|
1601
|
-
modelId:
|
|
1602
|
-
config:
|
|
1603
|
-
}):
|
|
1605
|
+
modelId: OpenAISpeechTranslationModelId;
|
|
1606
|
+
config: OpenAISpeechTranslationModelConfig;
|
|
1607
|
+
}): OpenAISpeechTranslationModel;
|
|
1604
1608
|
get provider(): string;
|
|
1605
|
-
constructor(modelId:
|
|
1609
|
+
constructor(modelId: OpenAISpeechTranslationModelId, config: OpenAISpeechTranslationModelConfig);
|
|
1606
1610
|
doStream(options: Experimental_SpeechTranslationModelV4StreamOptions): Promise<Awaited<ReturnType<Experimental_SpeechTranslationModelV4['doStream']>>>;
|
|
1607
1611
|
}
|
|
1608
1612
|
|
|
@@ -1722,4 +1726,4 @@ type OpenaiResponsesSourceDocumentProviderMetadata = {
|
|
|
1722
1726
|
|
|
1723
1727
|
declare const VERSION: string;
|
|
1724
1728
|
|
|
1725
|
-
export { OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel, type OpenAIRealtimeModelConfig as Experimental_OpenAIRealtimeModelConfig,
|
|
1729
|
+
export { OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel, type OpenAIRealtimeModelConfig as Experimental_OpenAIRealtimeModelConfig, OpenAISpeechTranslationModel as Experimental_OpenAISpeechTranslationModel, type OpenAISpeechTranslationModelId as Experimental_OpenAISpeechTranslationModelId, type OpenAISpeechTranslationModelOptions as Experimental_OpenAISpeechTranslationModelOptions, OpenAISpeechTranslationModel as Experimental_OpenAITranslationModel, type OpenAISpeechTranslationModelId as Experimental_OpenAITranslationModelId, type OpenAISpeechTranslationModelOptions as Experimental_OpenAITranslationModelOptions, type OpenAILanguageModelChatOptions as OpenAIChatLanguageModelOptions, type OpenAIComputerAction, type OpenAIComputerSafetyCheck, type OpenAIEmbeddingModelOptions, type OpenAIFilesOptions, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, type OpenAILanguageModelResponsesOptions, type OpenAIProvider, type OpenAIProviderSettings, type OpenAILanguageModelResponsesOptions as OpenAIResponsesProviderOptions, type OpenAISpeechModelOptions, type OpenAIToolOptions, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, VERSION, createOpenAI, openai };
|
package/dist/index.js
CHANGED
|
@@ -3504,6 +3504,7 @@ var openaiResponsesChunkSchema = lazySchema24(
|
|
|
3504
3504
|
z25.object({
|
|
3505
3505
|
type: z25.literal("response.output_text.delta"),
|
|
3506
3506
|
item_id: z25.string(),
|
|
3507
|
+
output_index: z25.number().nullish(),
|
|
3507
3508
|
delta: z25.string(),
|
|
3508
3509
|
logprobs: z25.array(
|
|
3509
3510
|
z25.object({
|
|
@@ -4028,17 +4029,20 @@ var openaiResponsesChunkSchema = lazySchema24(
|
|
|
4028
4029
|
z25.object({
|
|
4029
4030
|
type: z25.literal("response.reasoning_summary_part.added"),
|
|
4030
4031
|
item_id: z25.string(),
|
|
4032
|
+
output_index: z25.number().nullish(),
|
|
4031
4033
|
summary_index: z25.number()
|
|
4032
4034
|
}),
|
|
4033
4035
|
z25.object({
|
|
4034
4036
|
type: z25.literal("response.reasoning_summary_text.delta"),
|
|
4035
4037
|
item_id: z25.string(),
|
|
4038
|
+
output_index: z25.number().nullish(),
|
|
4036
4039
|
summary_index: z25.number(),
|
|
4037
4040
|
delta: z25.string()
|
|
4038
4041
|
}),
|
|
4039
4042
|
z25.object({
|
|
4040
4043
|
type: z25.literal("response.reasoning_summary_part.done"),
|
|
4041
4044
|
item_id: z25.string(),
|
|
4045
|
+
output_index: z25.number().nullish(),
|
|
4042
4046
|
summary_index: z25.number()
|
|
4043
4047
|
}),
|
|
4044
4048
|
z25.object({
|
|
@@ -6966,6 +6970,14 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6966
6970
|
let activeMessagePhase;
|
|
6967
6971
|
let hasFunctionCall = false;
|
|
6968
6972
|
const activeReasoning = {};
|
|
6973
|
+
const activeOutputItemIds = {};
|
|
6974
|
+
const resolveOutputItemId = ({
|
|
6975
|
+
itemId,
|
|
6976
|
+
outputIndex
|
|
6977
|
+
}) => {
|
|
6978
|
+
var _a2;
|
|
6979
|
+
return outputIndex == null ? itemId : (_a2 = activeOutputItemIds[outputIndex]) != null ? _a2 : itemId;
|
|
6980
|
+
};
|
|
6969
6981
|
let serviceTier;
|
|
6970
6982
|
let reasoningContext;
|
|
6971
6983
|
const hostedToolSearchCallIds = [];
|
|
@@ -6977,7 +6989,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
6977
6989
|
controller.enqueue({ type: "stream-start", warnings });
|
|
6978
6990
|
},
|
|
6979
6991
|
transform(chunk, controller) {
|
|
6980
|
-
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N
|
|
6992
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N;
|
|
6981
6993
|
if (options.includeRawChunks) {
|
|
6982
6994
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
6983
6995
|
}
|
|
@@ -7155,6 +7167,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7155
7167
|
};
|
|
7156
7168
|
} else if (value.item.type === "shell_call_output") {
|
|
7157
7169
|
} else if (value.item.type === "message") {
|
|
7170
|
+
activeOutputItemIds[value.output_index] = value.item.id;
|
|
7158
7171
|
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
7159
7172
|
activeMessagePhase = (_c = value.item.phase) != null ? _c : void 0;
|
|
7160
7173
|
controller.enqueue({
|
|
@@ -7170,6 +7183,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7170
7183
|
}
|
|
7171
7184
|
});
|
|
7172
7185
|
} else if (isResponseOutputItemAddedChunk(value) && value.item.type === "reasoning") {
|
|
7186
|
+
activeOutputItemIds[value.output_index] = value.item.id;
|
|
7173
7187
|
activeReasoning[value.item.id] = {
|
|
7174
7188
|
encryptedContent: value.item.encrypted_content,
|
|
7175
7189
|
summaryParts: { 0: "active" }
|
|
@@ -7187,14 +7201,18 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7187
7201
|
}
|
|
7188
7202
|
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
7189
7203
|
if (value.item.type === "message") {
|
|
7204
|
+
const itemId = resolveOutputItemId({
|
|
7205
|
+
itemId: value.item.id,
|
|
7206
|
+
outputIndex: value.output_index
|
|
7207
|
+
});
|
|
7190
7208
|
const phase = (_e = value.item.phase) != null ? _e : activeMessagePhase;
|
|
7191
7209
|
activeMessagePhase = void 0;
|
|
7192
7210
|
controller.enqueue({
|
|
7193
7211
|
type: "text-end",
|
|
7194
|
-
id:
|
|
7212
|
+
id: itemId,
|
|
7195
7213
|
providerMetadata: {
|
|
7196
7214
|
[providerOptionsName]: {
|
|
7197
|
-
itemId
|
|
7215
|
+
itemId,
|
|
7198
7216
|
...phase != null && { phase },
|
|
7199
7217
|
...ongoingAnnotations.length > 0 && {
|
|
7200
7218
|
annotations: ongoingAnnotations
|
|
@@ -7202,6 +7220,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7202
7220
|
}
|
|
7203
7221
|
}
|
|
7204
7222
|
});
|
|
7223
|
+
activeOutputItemIds[value.output_index] = void 0;
|
|
7205
7224
|
} else if (value.item.type === "function_call") {
|
|
7206
7225
|
ongoingToolCalls[value.output_index] = void 0;
|
|
7207
7226
|
hasFunctionCall = true;
|
|
@@ -7588,25 +7607,32 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7588
7607
|
}
|
|
7589
7608
|
});
|
|
7590
7609
|
} else if (value.item.type === "reasoning") {
|
|
7591
|
-
const
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
)
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7610
|
+
const itemId = resolveOutputItemId({
|
|
7611
|
+
itemId: value.item.id,
|
|
7612
|
+
outputIndex: value.output_index
|
|
7613
|
+
});
|
|
7614
|
+
const activeReasoningPart = activeReasoning[itemId];
|
|
7615
|
+
if (activeReasoningPart != null) {
|
|
7616
|
+
const summaryPartIndices = Object.entries(
|
|
7617
|
+
activeReasoningPart.summaryParts
|
|
7618
|
+
).filter(
|
|
7619
|
+
([_, status]) => status === "active" || status === "can-conclude"
|
|
7620
|
+
).map(([summaryIndex]) => summaryIndex);
|
|
7621
|
+
for (const summaryIndex of summaryPartIndices) {
|
|
7622
|
+
controller.enqueue({
|
|
7623
|
+
type: "reasoning-end",
|
|
7624
|
+
id: `${itemId}:${summaryIndex}`,
|
|
7625
|
+
providerMetadata: {
|
|
7626
|
+
[providerOptionsName]: {
|
|
7627
|
+
itemId,
|
|
7628
|
+
reasoningEncryptedContent: (_r = value.item.encrypted_content) != null ? _r : null
|
|
7629
|
+
}
|
|
7605
7630
|
}
|
|
7606
|
-
}
|
|
7607
|
-
}
|
|
7631
|
+
});
|
|
7632
|
+
}
|
|
7633
|
+
delete activeReasoning[itemId];
|
|
7608
7634
|
}
|
|
7609
|
-
|
|
7635
|
+
activeOutputItemIds[value.output_index] = void 0;
|
|
7610
7636
|
} else if (value.item.type === "compaction") {
|
|
7611
7637
|
controller.enqueue({
|
|
7612
7638
|
type: "custom",
|
|
@@ -7721,88 +7747,109 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7721
7747
|
modelId: value.response.model
|
|
7722
7748
|
});
|
|
7723
7749
|
} else if (isTextDeltaChunk(value)) {
|
|
7750
|
+
const itemId = resolveOutputItemId({
|
|
7751
|
+
itemId: value.item_id,
|
|
7752
|
+
outputIndex: value.output_index
|
|
7753
|
+
});
|
|
7724
7754
|
controller.enqueue({
|
|
7725
7755
|
type: "text-delta",
|
|
7726
|
-
id:
|
|
7756
|
+
id: itemId,
|
|
7727
7757
|
delta: value.delta
|
|
7728
7758
|
});
|
|
7729
7759
|
if (((_t = (_s = options.providerOptions) == null ? void 0 : _s[providerOptionsName]) == null ? void 0 : _t.logprobs) && value.logprobs) {
|
|
7730
7760
|
logprobs.push(value.logprobs);
|
|
7731
7761
|
}
|
|
7732
7762
|
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
7763
|
+
const itemId = resolveOutputItemId({
|
|
7764
|
+
itemId: value.item_id,
|
|
7765
|
+
outputIndex: value.output_index
|
|
7766
|
+
});
|
|
7733
7767
|
if (value.summary_index > 0) {
|
|
7734
|
-
const activeReasoningPart = activeReasoning[
|
|
7735
|
-
activeReasoningPart
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7768
|
+
const activeReasoningPart = activeReasoning[itemId];
|
|
7769
|
+
if (activeReasoningPart != null) {
|
|
7770
|
+
activeReasoningPart.summaryParts[value.summary_index] = "active";
|
|
7771
|
+
for (const summaryIndex of Object.keys(
|
|
7772
|
+
activeReasoningPart.summaryParts
|
|
7773
|
+
)) {
|
|
7774
|
+
if (activeReasoningPart.summaryParts[summaryIndex] === "can-conclude") {
|
|
7775
|
+
controller.enqueue({
|
|
7776
|
+
type: "reasoning-end",
|
|
7777
|
+
id: `${itemId}:${summaryIndex}`,
|
|
7778
|
+
providerMetadata: {
|
|
7779
|
+
[providerOptionsName]: {
|
|
7780
|
+
itemId
|
|
7781
|
+
}
|
|
7746
7782
|
}
|
|
7747
|
-
}
|
|
7748
|
-
|
|
7749
|
-
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
7750
|
-
}
|
|
7751
|
-
}
|
|
7752
|
-
controller.enqueue({
|
|
7753
|
-
type: "reasoning-start",
|
|
7754
|
-
id: `${value.item_id}:${value.summary_index}`,
|
|
7755
|
-
providerMetadata: {
|
|
7756
|
-
[providerOptionsName]: {
|
|
7757
|
-
itemId: value.item_id,
|
|
7758
|
-
reasoningEncryptedContent: (_v = (_u = activeReasoning[value.item_id]) == null ? void 0 : _u.encryptedContent) != null ? _v : null
|
|
7783
|
+
});
|
|
7784
|
+
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
7759
7785
|
}
|
|
7760
7786
|
}
|
|
7761
|
-
|
|
7787
|
+
controller.enqueue({
|
|
7788
|
+
type: "reasoning-start",
|
|
7789
|
+
id: `${itemId}:${value.summary_index}`,
|
|
7790
|
+
providerMetadata: {
|
|
7791
|
+
[providerOptionsName]: {
|
|
7792
|
+
itemId,
|
|
7793
|
+
reasoningEncryptedContent: (_u = activeReasoningPart.encryptedContent) != null ? _u : null
|
|
7794
|
+
}
|
|
7795
|
+
}
|
|
7796
|
+
});
|
|
7797
|
+
}
|
|
7762
7798
|
}
|
|
7763
7799
|
} else if (value.type === "response.reasoning_summary_text.delta") {
|
|
7800
|
+
const itemId = resolveOutputItemId({
|
|
7801
|
+
itemId: value.item_id,
|
|
7802
|
+
outputIndex: value.output_index
|
|
7803
|
+
});
|
|
7764
7804
|
controller.enqueue({
|
|
7765
7805
|
type: "reasoning-delta",
|
|
7766
|
-
id: `${
|
|
7806
|
+
id: `${itemId}:${value.summary_index}`,
|
|
7767
7807
|
delta: value.delta,
|
|
7768
7808
|
providerMetadata: {
|
|
7769
7809
|
[providerOptionsName]: {
|
|
7770
|
-
itemId
|
|
7810
|
+
itemId
|
|
7771
7811
|
}
|
|
7772
7812
|
}
|
|
7773
7813
|
});
|
|
7774
7814
|
} else if (value.type === "response.reasoning_summary_part.done") {
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7815
|
+
const itemId = resolveOutputItemId({
|
|
7816
|
+
itemId: value.item_id,
|
|
7817
|
+
outputIndex: value.output_index
|
|
7818
|
+
});
|
|
7819
|
+
const activeReasoningPart = activeReasoning[itemId];
|
|
7820
|
+
if (activeReasoningPart != null) {
|
|
7821
|
+
if (store) {
|
|
7822
|
+
controller.enqueue({
|
|
7823
|
+
type: "reasoning-end",
|
|
7824
|
+
id: `${itemId}:${value.summary_index}`,
|
|
7825
|
+
providerMetadata: {
|
|
7826
|
+
[providerOptionsName]: {
|
|
7827
|
+
itemId
|
|
7828
|
+
}
|
|
7782
7829
|
}
|
|
7783
|
-
}
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7830
|
+
});
|
|
7831
|
+
activeReasoningPart.summaryParts[value.summary_index] = "concluded";
|
|
7832
|
+
} else {
|
|
7833
|
+
activeReasoningPart.summaryParts[value.summary_index] = "can-conclude";
|
|
7834
|
+
}
|
|
7788
7835
|
}
|
|
7789
7836
|
} else if (isResponseFinishedChunk(value)) {
|
|
7790
7837
|
finishReason = {
|
|
7791
7838
|
unified: mapOpenAIResponseFinishReason({
|
|
7792
|
-
finishReason: (
|
|
7839
|
+
finishReason: (_v = value.response.incomplete_details) == null ? void 0 : _v.reason,
|
|
7793
7840
|
hasFunctionCall
|
|
7794
7841
|
}),
|
|
7795
|
-
raw: (
|
|
7842
|
+
raw: (_x = (_w = value.response.incomplete_details) == null ? void 0 : _w.reason) != null ? _x : void 0
|
|
7796
7843
|
};
|
|
7797
7844
|
usage = value.response.usage;
|
|
7798
7845
|
if (typeof value.response.service_tier === "string") {
|
|
7799
7846
|
serviceTier = value.response.service_tier;
|
|
7800
7847
|
}
|
|
7801
|
-
if (((
|
|
7848
|
+
if (((_y = value.response.reasoning) == null ? void 0 : _y.context) != null) {
|
|
7802
7849
|
reasoningContext = value.response.reasoning.context;
|
|
7803
7850
|
}
|
|
7804
7851
|
} else if (isResponseFailedChunk(value)) {
|
|
7805
|
-
const incompleteReason = (
|
|
7852
|
+
const incompleteReason = (_z = value.response.incomplete_details) == null ? void 0 : _z.reason;
|
|
7806
7853
|
finishReason = {
|
|
7807
7854
|
unified: incompleteReason ? mapOpenAIResponseFinishReason({
|
|
7808
7855
|
finishReason: incompleteReason,
|
|
@@ -7810,8 +7857,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7810
7857
|
}) : "error",
|
|
7811
7858
|
raw: incompleteReason != null ? incompleteReason : "error"
|
|
7812
7859
|
};
|
|
7813
|
-
usage = (
|
|
7814
|
-
if (((
|
|
7860
|
+
usage = (_A = value.response.usage) != null ? _A : void 0;
|
|
7861
|
+
if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
|
|
7815
7862
|
reasoningContext = value.response.reasoning.context;
|
|
7816
7863
|
}
|
|
7817
7864
|
if (!encounteredStreamError && value.response.error != null) {
|
|
@@ -7835,7 +7882,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7835
7882
|
controller.enqueue({
|
|
7836
7883
|
type: "source",
|
|
7837
7884
|
sourceType: "url",
|
|
7838
|
-
id: (
|
|
7885
|
+
id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : generateId2(),
|
|
7839
7886
|
url: value.annotation.url,
|
|
7840
7887
|
title: value.annotation.title
|
|
7841
7888
|
});
|
|
@@ -7843,7 +7890,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7843
7890
|
controller.enqueue({
|
|
7844
7891
|
type: "source",
|
|
7845
7892
|
sourceType: "document",
|
|
7846
|
-
id: (
|
|
7893
|
+
id: (_H = (_G = (_F = self.config).generateId) == null ? void 0 : _G.call(_F)) != null ? _H : generateId2(),
|
|
7847
7894
|
mediaType: "text/plain",
|
|
7848
7895
|
title: value.annotation.filename,
|
|
7849
7896
|
filename: value.annotation.filename,
|
|
@@ -7859,7 +7906,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7859
7906
|
controller.enqueue({
|
|
7860
7907
|
type: "source",
|
|
7861
7908
|
sourceType: "document",
|
|
7862
|
-
id: (
|
|
7909
|
+
id: (_K = (_J = (_I = self.config).generateId) == null ? void 0 : _J.call(_I)) != null ? _K : generateId2(),
|
|
7863
7910
|
mediaType: "text/plain",
|
|
7864
7911
|
title: value.annotation.filename,
|
|
7865
7912
|
filename: value.annotation.filename,
|
|
@@ -7875,7 +7922,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7875
7922
|
controller.enqueue({
|
|
7876
7923
|
type: "source",
|
|
7877
7924
|
sourceType: "document",
|
|
7878
|
-
id: (
|
|
7925
|
+
id: (_N = (_M = (_L = self.config).generateId) == null ? void 0 : _M.call(_L)) != null ? _N : generateId2(),
|
|
7879
7926
|
mediaType: "application/octet-stream",
|
|
7880
7927
|
title: value.annotation.file_id,
|
|
7881
7928
|
filename: value.annotation.file_id,
|
|
@@ -9559,7 +9606,7 @@ function getOpenAIRealtimeConnection(headers) {
|
|
|
9559
9606
|
};
|
|
9560
9607
|
}
|
|
9561
9608
|
|
|
9562
|
-
// src/translation/openai-translation-model.ts
|
|
9609
|
+
// src/speech-translation/openai-speech-translation-model.ts
|
|
9563
9610
|
import {
|
|
9564
9611
|
InvalidArgumentError as InvalidArgumentError2
|
|
9565
9612
|
} from "@ai-sdk/provider";
|
|
@@ -9576,18 +9623,18 @@ import {
|
|
|
9576
9623
|
waitForWebSocketBufferDrain as waitForWebSocketBufferDrain2
|
|
9577
9624
|
} from "@ai-sdk/provider-utils";
|
|
9578
9625
|
|
|
9579
|
-
// src/translation/openai-translation-model-options.ts
|
|
9626
|
+
// src/speech-translation/openai-speech-translation-model-options.ts
|
|
9580
9627
|
import {
|
|
9581
9628
|
lazySchema as lazySchema30,
|
|
9582
9629
|
zodSchema as zodSchema30
|
|
9583
9630
|
} from "@ai-sdk/provider-utils";
|
|
9584
9631
|
import { z as z32 } from "zod/v4";
|
|
9585
|
-
var
|
|
9632
|
+
var openAISpeechTranslationModelOptions = lazySchema30(
|
|
9586
9633
|
() => zodSchema30(z32.object({}))
|
|
9587
9634
|
);
|
|
9588
9635
|
|
|
9589
|
-
// src/translation/openai-translation-model.ts
|
|
9590
|
-
var
|
|
9636
|
+
// src/speech-translation/openai-speech-translation-model.ts
|
|
9637
|
+
var OpenAISpeechTranslationModel = class _OpenAISpeechTranslationModel {
|
|
9591
9638
|
constructor(modelId, config) {
|
|
9592
9639
|
this.modelId = modelId;
|
|
9593
9640
|
this.config = config;
|
|
@@ -9600,7 +9647,7 @@ var OpenAITranslationModel = class _OpenAITranslationModel {
|
|
|
9600
9647
|
});
|
|
9601
9648
|
}
|
|
9602
9649
|
static [WORKFLOW_DESERIALIZE9](options) {
|
|
9603
|
-
return new
|
|
9650
|
+
return new _OpenAISpeechTranslationModel(options.modelId, options.config);
|
|
9604
9651
|
}
|
|
9605
9652
|
get provider() {
|
|
9606
9653
|
return this.config.provider;
|
|
@@ -9617,10 +9664,10 @@ var OpenAITranslationModel = class _OpenAITranslationModel {
|
|
|
9617
9664
|
await parseProviderOptions10({
|
|
9618
9665
|
provider: "openai",
|
|
9619
9666
|
providerOptions: options.providerOptions,
|
|
9620
|
-
schema:
|
|
9667
|
+
schema: openAISpeechTranslationModelOptions
|
|
9621
9668
|
});
|
|
9622
9669
|
const warnings = [];
|
|
9623
|
-
|
|
9670
|
+
validateOpenAISpeechTranslationInputAudioFormat(options.inputAudioFormat);
|
|
9624
9671
|
if (options.sourceLanguage != null) {
|
|
9625
9672
|
warnings.push({
|
|
9626
9673
|
type: "unsupported",
|
|
@@ -9636,7 +9683,7 @@ var OpenAITranslationModel = class _OpenAITranslationModel {
|
|
|
9636
9683
|
});
|
|
9637
9684
|
}
|
|
9638
9685
|
const headers = combineHeaders10((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), options.headers);
|
|
9639
|
-
const sessionUpdate =
|
|
9686
|
+
const sessionUpdate = buildOpenAIRealtimeSpeechTranslationSession({
|
|
9640
9687
|
targetLanguage: options.targetLanguage
|
|
9641
9688
|
});
|
|
9642
9689
|
return {
|
|
@@ -9645,7 +9692,7 @@ var OpenAITranslationModel = class _OpenAITranslationModel {
|
|
|
9645
9692
|
timestamp: currentDate,
|
|
9646
9693
|
modelId: this.modelId
|
|
9647
9694
|
},
|
|
9648
|
-
stream:
|
|
9695
|
+
stream: createOpenAIRealtimeSpeechTranslationStream({
|
|
9649
9696
|
webSocket: this.config.webSocket,
|
|
9650
9697
|
url: toWebSocketUrl2(
|
|
9651
9698
|
this.config.url({
|
|
@@ -9663,7 +9710,7 @@ var OpenAITranslationModel = class _OpenAITranslationModel {
|
|
|
9663
9710
|
};
|
|
9664
9711
|
}
|
|
9665
9712
|
};
|
|
9666
|
-
function
|
|
9713
|
+
function createOpenAIRealtimeSpeechTranslationStream({
|
|
9667
9714
|
webSocket,
|
|
9668
9715
|
url,
|
|
9669
9716
|
headers,
|
|
@@ -9826,7 +9873,7 @@ function createOpenAIRealtimeTranslationStream({
|
|
|
9826
9873
|
}
|
|
9827
9874
|
});
|
|
9828
9875
|
}
|
|
9829
|
-
function
|
|
9876
|
+
function buildOpenAIRealtimeSpeechTranslationSession({
|
|
9830
9877
|
targetLanguage
|
|
9831
9878
|
}) {
|
|
9832
9879
|
return {
|
|
@@ -9846,7 +9893,7 @@ function buildOpenAIRealtimeTranslationSession({
|
|
|
9846
9893
|
}
|
|
9847
9894
|
};
|
|
9848
9895
|
}
|
|
9849
|
-
function
|
|
9896
|
+
function validateOpenAISpeechTranslationInputAudioFormat(inputAudioFormat) {
|
|
9850
9897
|
if (inputAudioFormat.type !== "audio/pcm" || inputAudioFormat.rate != null && inputAudioFormat.rate !== 24e3) {
|
|
9851
9898
|
throw new InvalidArgumentError2({
|
|
9852
9899
|
argument: "inputAudioFormat",
|
|
@@ -9961,7 +10008,7 @@ var OpenAISkills = class {
|
|
|
9961
10008
|
};
|
|
9962
10009
|
|
|
9963
10010
|
// src/version.ts
|
|
9964
|
-
var VERSION = true ? "4.0.
|
|
10011
|
+
var VERSION = true ? "4.0.35" : "0.0.0-test";
|
|
9965
10012
|
|
|
9966
10013
|
// src/openai-provider.ts
|
|
9967
10014
|
function createOpenAI(options = {}) {
|
|
@@ -10019,8 +10066,8 @@ function createOpenAI(options = {}) {
|
|
|
10019
10066
|
fetch: options.fetch,
|
|
10020
10067
|
webSocket: options.webSocket
|
|
10021
10068
|
});
|
|
10022
|
-
const
|
|
10023
|
-
provider: `${providerName}.translation`,
|
|
10069
|
+
const createSpeechTranslationModel = (modelId) => new OpenAISpeechTranslationModel(modelId, {
|
|
10070
|
+
provider: `${providerName}.speech-translation`,
|
|
10024
10071
|
url: ({ path }) => `${baseURL}${path}`,
|
|
10025
10072
|
headers: getHeaders,
|
|
10026
10073
|
fetch: options.fetch,
|
|
@@ -10101,8 +10148,8 @@ function createOpenAI(options = {}) {
|
|
|
10101
10148
|
provider.imageModel = createImageModel;
|
|
10102
10149
|
provider.transcription = createTranscriptionModel;
|
|
10103
10150
|
provider.transcriptionModel = createTranscriptionModel;
|
|
10104
|
-
provider.translation =
|
|
10105
|
-
provider.speechTranslationModel =
|
|
10151
|
+
provider.translation = createSpeechTranslationModel;
|
|
10152
|
+
provider.speechTranslationModel = createSpeechTranslationModel;
|
|
10106
10153
|
provider.speech = createSpeechModel;
|
|
10107
10154
|
provider.speechModel = createSpeechModel;
|
|
10108
10155
|
provider.files = createFiles;
|
|
@@ -10114,7 +10161,8 @@ function createOpenAI(options = {}) {
|
|
|
10114
10161
|
var openai = createOpenAI();
|
|
10115
10162
|
export {
|
|
10116
10163
|
OpenAIRealtimeModel as Experimental_OpenAIRealtimeModel,
|
|
10117
|
-
|
|
10164
|
+
OpenAISpeechTranslationModel as Experimental_OpenAISpeechTranslationModel,
|
|
10165
|
+
OpenAISpeechTranslationModel as Experimental_OpenAITranslationModel,
|
|
10118
10166
|
VERSION,
|
|
10119
10167
|
createOpenAI,
|
|
10120
10168
|
openai
|