@ai-sdk/openai 2.0.128 → 2.0.129
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 +9 -0
- package/dist/index.js +18 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -15
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +17 -14
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +17 -14
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -419,6 +419,9 @@ var openaiChatResponseSchema = (0, import_provider_utils3.lazyValidator)(
|
|
|
419
419
|
message: import_v42.z.object({
|
|
420
420
|
role: import_v42.z.literal("assistant").nullish(),
|
|
421
421
|
content: import_v42.z.string().nullish(),
|
|
422
|
+
audio: import_v42.z.object({
|
|
423
|
+
transcript: import_v42.z.string().nullish()
|
|
424
|
+
}).nullish(),
|
|
422
425
|
tool_calls: import_v42.z.array(
|
|
423
426
|
import_v42.z.object({
|
|
424
427
|
id: import_v42.z.string().nullish(),
|
|
@@ -954,7 +957,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
954
957
|
};
|
|
955
958
|
}
|
|
956
959
|
async doGenerate(options) {
|
|
957
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
960
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
958
961
|
const { args: body, warnings } = await this.getArgs(options);
|
|
959
962
|
const {
|
|
960
963
|
responseHeaders,
|
|
@@ -982,19 +985,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
982
985
|
});
|
|
983
986
|
}
|
|
984
987
|
const content = [];
|
|
985
|
-
const text = choice.message.content;
|
|
988
|
+
const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_a2 = choice.message.audio) == null ? void 0 : _a2.transcript;
|
|
986
989
|
if (text != null && text.length > 0) {
|
|
987
990
|
content.push({ type: "text", text });
|
|
988
991
|
}
|
|
989
|
-
for (const toolCall of (
|
|
992
|
+
for (const toolCall of (_b = choice.message.tool_calls) != null ? _b : []) {
|
|
990
993
|
content.push({
|
|
991
994
|
type: "tool-call",
|
|
992
|
-
toolCallId: (
|
|
995
|
+
toolCallId: (_c = toolCall.id) != null ? _c : (0, import_provider_utils5.generateId)(),
|
|
993
996
|
toolName: toolCall.function.name,
|
|
994
997
|
input: toolCall.function.arguments
|
|
995
998
|
});
|
|
996
999
|
}
|
|
997
|
-
for (const annotation of (
|
|
1000
|
+
for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
|
|
998
1001
|
content.push({
|
|
999
1002
|
type: "source",
|
|
1000
1003
|
sourceType: "url",
|
|
@@ -1003,8 +1006,8 @@ var OpenAIChatLanguageModel = class {
|
|
|
1003
1006
|
title: annotation.url_citation.title
|
|
1004
1007
|
});
|
|
1005
1008
|
}
|
|
1006
|
-
const completionTokenDetails = (
|
|
1007
|
-
const promptTokenDetails = (
|
|
1009
|
+
const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
|
|
1010
|
+
const promptTokenDetails = (_f = response.usage) == null ? void 0 : _f.prompt_tokens_details;
|
|
1008
1011
|
const providerMetadata = { openai: {} };
|
|
1009
1012
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
1010
1013
|
providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
|
|
@@ -1017,18 +1020,18 @@ var OpenAIChatLanguageModel = class {
|
|
|
1017
1020
|
cacheWriteTokens: promptTokenDetails.cache_write_tokens
|
|
1018
1021
|
};
|
|
1019
1022
|
}
|
|
1020
|
-
if (((
|
|
1023
|
+
if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
|
|
1021
1024
|
providerMetadata.openai.logprobs = choice.logprobs.content;
|
|
1022
1025
|
}
|
|
1023
1026
|
return {
|
|
1024
1027
|
content,
|
|
1025
1028
|
finishReason: mapOpenAIFinishReason(choice.finish_reason),
|
|
1026
1029
|
usage: {
|
|
1027
|
-
inputTokens: (
|
|
1028
|
-
outputTokens: (
|
|
1029
|
-
totalTokens: (
|
|
1030
|
-
reasoningTokens: (
|
|
1031
|
-
cachedInputTokens: (
|
|
1030
|
+
inputTokens: (_i = (_h = response.usage) == null ? void 0 : _h.prompt_tokens) != null ? _i : void 0,
|
|
1031
|
+
outputTokens: (_k = (_j = response.usage) == null ? void 0 : _j.completion_tokens) != null ? _k : void 0,
|
|
1032
|
+
totalTokens: (_m = (_l = response.usage) == null ? void 0 : _l.total_tokens) != null ? _m : void 0,
|
|
1033
|
+
reasoningTokens: (_n = completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null ? _n : void 0,
|
|
1034
|
+
cachedInputTokens: (_o = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens) != null ? _o : void 0
|
|
1032
1035
|
},
|
|
1033
1036
|
request: { body },
|
|
1034
1037
|
response: {
|
|
@@ -4654,7 +4657,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4654
4657
|
providerExecuted: true
|
|
4655
4658
|
});
|
|
4656
4659
|
} else if (value.item.type === "message") {
|
|
4657
|
-
ongoingAnnotations.splice(0
|
|
4660
|
+
ongoingAnnotations.splice(0);
|
|
4658
4661
|
activeMessagePhase = (_a2 = value.item.phase) != null ? _a2 : void 0;
|
|
4659
4662
|
controller.enqueue({
|
|
4660
4663
|
type: "text-start",
|