@ai-sdk/openai 3.0.116 → 3.0.117
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 +12 -0
- package/dist/index.js +16 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +15 -11
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +15 -11
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/chat/openai-chat-api.ts +5 -0
- package/src/chat/openai-chat-language-model.ts +4 -1
- package/src/openai-stream-error.ts +4 -0
- package/src/responses/openai-responses-language-model.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 3.0.117
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a3e970b: fix(openai): expose Chat Completions audio transcripts as generated text
|
|
8
|
+
- f7f36d2: chore: enable dead code lint rules
|
|
9
|
+
- 57256a0: fix(openai): preserve retryability for early stream errors
|
|
10
|
+
- Updated dependencies [069a945]
|
|
11
|
+
- Updated dependencies [d1a36d2]
|
|
12
|
+
- Updated dependencies [f7f36d2]
|
|
13
|
+
- @ai-sdk/provider-utils@4.0.54
|
|
14
|
+
|
|
3
15
|
## 3.0.116
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -167,7 +167,8 @@ function createOpenAIStreamError({
|
|
|
167
167
|
statusCode: streamError == null ? 500 : getStatusCode(streamError),
|
|
168
168
|
responseHeaders,
|
|
169
169
|
responseBody: JSON.stringify(frame),
|
|
170
|
-
data: frame
|
|
170
|
+
data: frame,
|
|
171
|
+
isRetryable: streamError == null ? true : isRetryableStreamError(streamError, getStatusCode(streamError))
|
|
171
172
|
});
|
|
172
173
|
}
|
|
173
174
|
function parseStreamError(frame) {
|
|
@@ -581,6 +582,9 @@ var openaiChatResponseSchema = (0, import_provider_utils3.lazySchema)(
|
|
|
581
582
|
message: import_v42.z.object({
|
|
582
583
|
role: import_v42.z.literal("assistant").nullish(),
|
|
583
584
|
content: import_v42.z.string().nullish(),
|
|
585
|
+
audio: import_v42.z.object({
|
|
586
|
+
transcript: import_v42.z.string().nullish()
|
|
587
|
+
}).nullish(),
|
|
584
588
|
tool_calls: import_v42.z.array(
|
|
585
589
|
import_v42.z.object({
|
|
586
590
|
id: import_v42.z.string().nullish(),
|
|
@@ -1120,7 +1124,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
1120
1124
|
};
|
|
1121
1125
|
}
|
|
1122
1126
|
async doGenerate(options) {
|
|
1123
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
|
1127
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
1124
1128
|
const { args: body, warnings } = await this.getArgs(options);
|
|
1125
1129
|
const {
|
|
1126
1130
|
responseHeaders,
|
|
@@ -1148,19 +1152,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
1148
1152
|
});
|
|
1149
1153
|
}
|
|
1150
1154
|
const content = [];
|
|
1151
|
-
const text = choice.message.content;
|
|
1155
|
+
const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_a2 = choice.message.audio) == null ? void 0 : _a2.transcript;
|
|
1152
1156
|
if (text != null && text.length > 0) {
|
|
1153
1157
|
content.push({ type: "text", text });
|
|
1154
1158
|
}
|
|
1155
|
-
for (const toolCall of (
|
|
1159
|
+
for (const toolCall of (_b = choice.message.tool_calls) != null ? _b : []) {
|
|
1156
1160
|
content.push({
|
|
1157
1161
|
type: "tool-call",
|
|
1158
|
-
toolCallId: (
|
|
1162
|
+
toolCallId: (_c = toolCall.id) != null ? _c : (0, import_provider_utils5.generateId)(),
|
|
1159
1163
|
toolName: toolCall.function.name,
|
|
1160
1164
|
input: toolCall.function.arguments
|
|
1161
1165
|
});
|
|
1162
1166
|
}
|
|
1163
|
-
for (const annotation of (
|
|
1167
|
+
for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
|
|
1164
1168
|
content.push({
|
|
1165
1169
|
type: "source",
|
|
1166
1170
|
sourceType: "url",
|
|
@@ -1169,8 +1173,8 @@ var OpenAIChatLanguageModel = class {
|
|
|
1169
1173
|
title: annotation.url_citation.title
|
|
1170
1174
|
});
|
|
1171
1175
|
}
|
|
1172
|
-
const completionTokenDetails = (
|
|
1173
|
-
const promptTokenDetails = (
|
|
1176
|
+
const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
|
|
1177
|
+
const promptTokenDetails = (_f = response.usage) == null ? void 0 : _f.prompt_tokens_details;
|
|
1174
1178
|
const providerMetadata = { openai: {} };
|
|
1175
1179
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
1176
1180
|
providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
|
|
@@ -1178,14 +1182,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
1178
1182
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
|
|
1179
1183
|
providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
|
|
1180
1184
|
}
|
|
1181
|
-
if (((
|
|
1185
|
+
if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
|
|
1182
1186
|
providerMetadata.openai.logprobs = choice.logprobs.content;
|
|
1183
1187
|
}
|
|
1184
1188
|
return {
|
|
1185
1189
|
content,
|
|
1186
1190
|
finishReason: {
|
|
1187
1191
|
unified: mapOpenAIFinishReason(choice.finish_reason),
|
|
1188
|
-
raw: (
|
|
1192
|
+
raw: (_h = choice.finish_reason) != null ? _h : void 0
|
|
1189
1193
|
},
|
|
1190
1194
|
usage: convertOpenAIChatUsage(response.usage),
|
|
1191
1195
|
request: { body },
|
|
@@ -6890,7 +6894,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6890
6894
|
};
|
|
6891
6895
|
} else if (value.item.type === "shell_call_output") {
|
|
6892
6896
|
} else if (value.item.type === "message") {
|
|
6893
|
-
ongoingAnnotations.splice(0
|
|
6897
|
+
ongoingAnnotations.splice(0);
|
|
6894
6898
|
activeMessagePhase = (_b2 = value.item.phase) != null ? _b2 : void 0;
|
|
6895
6899
|
controller.enqueue({
|
|
6896
6900
|
type: "text-start",
|
|
@@ -8132,7 +8136,7 @@ var OpenAITranscriptionModel = class {
|
|
|
8132
8136
|
};
|
|
8133
8137
|
|
|
8134
8138
|
// src/version.ts
|
|
8135
|
-
var VERSION = true ? "3.0.
|
|
8139
|
+
var VERSION = true ? "3.0.117" : "0.0.0-test";
|
|
8136
8140
|
|
|
8137
8141
|
// src/openai-provider.ts
|
|
8138
8142
|
function createOpenAI(options = {}) {
|