@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/index.mjs
CHANGED
|
@@ -382,6 +382,9 @@ var openaiChatResponseSchema = lazyValidator(
|
|
|
382
382
|
message: z2.object({
|
|
383
383
|
role: z2.literal("assistant").nullish(),
|
|
384
384
|
content: z2.string().nullish(),
|
|
385
|
+
audio: z2.object({
|
|
386
|
+
transcript: z2.string().nullish()
|
|
387
|
+
}).nullish(),
|
|
385
388
|
tool_calls: z2.array(
|
|
386
389
|
z2.object({
|
|
387
390
|
id: z2.string().nullish(),
|
|
@@ -922,7 +925,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
922
925
|
};
|
|
923
926
|
}
|
|
924
927
|
async doGenerate(options) {
|
|
925
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
928
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
926
929
|
const { args: body, warnings } = await this.getArgs(options);
|
|
927
930
|
const {
|
|
928
931
|
responseHeaders,
|
|
@@ -950,19 +953,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
950
953
|
});
|
|
951
954
|
}
|
|
952
955
|
const content = [];
|
|
953
|
-
const text = choice.message.content;
|
|
956
|
+
const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_a2 = choice.message.audio) == null ? void 0 : _a2.transcript;
|
|
954
957
|
if (text != null && text.length > 0) {
|
|
955
958
|
content.push({ type: "text", text });
|
|
956
959
|
}
|
|
957
|
-
for (const toolCall of (
|
|
960
|
+
for (const toolCall of (_b = choice.message.tool_calls) != null ? _b : []) {
|
|
958
961
|
content.push({
|
|
959
962
|
type: "tool-call",
|
|
960
|
-
toolCallId: (
|
|
963
|
+
toolCallId: (_c = toolCall.id) != null ? _c : generateId(),
|
|
961
964
|
toolName: toolCall.function.name,
|
|
962
965
|
input: toolCall.function.arguments
|
|
963
966
|
});
|
|
964
967
|
}
|
|
965
|
-
for (const annotation of (
|
|
968
|
+
for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
|
|
966
969
|
content.push({
|
|
967
970
|
type: "source",
|
|
968
971
|
sourceType: "url",
|
|
@@ -971,8 +974,8 @@ var OpenAIChatLanguageModel = class {
|
|
|
971
974
|
title: annotation.url_citation.title
|
|
972
975
|
});
|
|
973
976
|
}
|
|
974
|
-
const completionTokenDetails = (
|
|
975
|
-
const promptTokenDetails = (
|
|
977
|
+
const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
|
|
978
|
+
const promptTokenDetails = (_f = response.usage) == null ? void 0 : _f.prompt_tokens_details;
|
|
976
979
|
const providerMetadata = { openai: {} };
|
|
977
980
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
978
981
|
providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
|
|
@@ -985,18 +988,18 @@ var OpenAIChatLanguageModel = class {
|
|
|
985
988
|
cacheWriteTokens: promptTokenDetails.cache_write_tokens
|
|
986
989
|
};
|
|
987
990
|
}
|
|
988
|
-
if (((
|
|
991
|
+
if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
|
|
989
992
|
providerMetadata.openai.logprobs = choice.logprobs.content;
|
|
990
993
|
}
|
|
991
994
|
return {
|
|
992
995
|
content,
|
|
993
996
|
finishReason: mapOpenAIFinishReason(choice.finish_reason),
|
|
994
997
|
usage: {
|
|
995
|
-
inputTokens: (
|
|
996
|
-
outputTokens: (
|
|
997
|
-
totalTokens: (
|
|
998
|
-
reasoningTokens: (
|
|
999
|
-
cachedInputTokens: (
|
|
998
|
+
inputTokens: (_i = (_h = response.usage) == null ? void 0 : _h.prompt_tokens) != null ? _i : void 0,
|
|
999
|
+
outputTokens: (_k = (_j = response.usage) == null ? void 0 : _j.completion_tokens) != null ? _k : void 0,
|
|
1000
|
+
totalTokens: (_m = (_l = response.usage) == null ? void 0 : _l.total_tokens) != null ? _m : void 0,
|
|
1001
|
+
reasoningTokens: (_n = completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null ? _n : void 0,
|
|
1002
|
+
cachedInputTokens: (_o = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens) != null ? _o : void 0
|
|
1000
1003
|
},
|
|
1001
1004
|
request: { body },
|
|
1002
1005
|
response: {
|
|
@@ -4420,7 +4423,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4420
4423
|
providerExecuted: true
|
|
4421
4424
|
});
|
|
4422
4425
|
} else if (value.item.type === "message") {
|
|
4423
|
-
ongoingAnnotations.splice(0
|
|
4426
|
+
ongoingAnnotations.splice(0);
|
|
4424
4427
|
activeMessagePhase = (_a2 = value.item.phase) != null ? _a2 : void 0;
|
|
4425
4428
|
controller.enqueue({
|
|
4426
4429
|
type: "text-start",
|
|
@@ -5236,7 +5239,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5236
5239
|
};
|
|
5237
5240
|
|
|
5238
5241
|
// src/version.ts
|
|
5239
|
-
var VERSION = true ? "2.0.
|
|
5242
|
+
var VERSION = true ? "2.0.129" : "0.0.0-test";
|
|
5240
5243
|
|
|
5241
5244
|
// src/openai-provider.ts
|
|
5242
5245
|
function createOpenAI(options = {}) {
|