@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/dist/internal/index.js
CHANGED
|
@@ -202,7 +202,8 @@ function createOpenAIStreamError({
|
|
|
202
202
|
statusCode: streamError == null ? 500 : getStatusCode(streamError),
|
|
203
203
|
responseHeaders,
|
|
204
204
|
responseBody: JSON.stringify(frame),
|
|
205
|
-
data: frame
|
|
205
|
+
data: frame,
|
|
206
|
+
isRetryable: streamError == null ? true : isRetryableStreamError(streamError, getStatusCode(streamError))
|
|
206
207
|
});
|
|
207
208
|
}
|
|
208
209
|
function parseStreamError(frame) {
|
|
@@ -616,6 +617,9 @@ var openaiChatResponseSchema = (0, import_provider_utils3.lazySchema)(
|
|
|
616
617
|
message: import_v42.z.object({
|
|
617
618
|
role: import_v42.z.literal("assistant").nullish(),
|
|
618
619
|
content: import_v42.z.string().nullish(),
|
|
620
|
+
audio: import_v42.z.object({
|
|
621
|
+
transcript: import_v42.z.string().nullish()
|
|
622
|
+
}).nullish(),
|
|
619
623
|
tool_calls: import_v42.z.array(
|
|
620
624
|
import_v42.z.object({
|
|
621
625
|
id: import_v42.z.string().nullish(),
|
|
@@ -1155,7 +1159,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
1155
1159
|
};
|
|
1156
1160
|
}
|
|
1157
1161
|
async doGenerate(options) {
|
|
1158
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
|
1162
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
1159
1163
|
const { args: body, warnings } = await this.getArgs(options);
|
|
1160
1164
|
const {
|
|
1161
1165
|
responseHeaders,
|
|
@@ -1183,19 +1187,19 @@ var OpenAIChatLanguageModel = class {
|
|
|
1183
1187
|
});
|
|
1184
1188
|
}
|
|
1185
1189
|
const content = [];
|
|
1186
|
-
const text = choice.message.content;
|
|
1190
|
+
const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_a2 = choice.message.audio) == null ? void 0 : _a2.transcript;
|
|
1187
1191
|
if (text != null && text.length > 0) {
|
|
1188
1192
|
content.push({ type: "text", text });
|
|
1189
1193
|
}
|
|
1190
|
-
for (const toolCall of (
|
|
1194
|
+
for (const toolCall of (_b = choice.message.tool_calls) != null ? _b : []) {
|
|
1191
1195
|
content.push({
|
|
1192
1196
|
type: "tool-call",
|
|
1193
|
-
toolCallId: (
|
|
1197
|
+
toolCallId: (_c = toolCall.id) != null ? _c : (0, import_provider_utils5.generateId)(),
|
|
1194
1198
|
toolName: toolCall.function.name,
|
|
1195
1199
|
input: toolCall.function.arguments
|
|
1196
1200
|
});
|
|
1197
1201
|
}
|
|
1198
|
-
for (const annotation of (
|
|
1202
|
+
for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
|
|
1199
1203
|
content.push({
|
|
1200
1204
|
type: "source",
|
|
1201
1205
|
sourceType: "url",
|
|
@@ -1204,8 +1208,8 @@ var OpenAIChatLanguageModel = class {
|
|
|
1204
1208
|
title: annotation.url_citation.title
|
|
1205
1209
|
});
|
|
1206
1210
|
}
|
|
1207
|
-
const completionTokenDetails = (
|
|
1208
|
-
const promptTokenDetails = (
|
|
1211
|
+
const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
|
|
1212
|
+
const promptTokenDetails = (_f = response.usage) == null ? void 0 : _f.prompt_tokens_details;
|
|
1209
1213
|
const providerMetadata = { openai: {} };
|
|
1210
1214
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
1211
1215
|
providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
|
|
@@ -1213,14 +1217,14 @@ var OpenAIChatLanguageModel = class {
|
|
|
1213
1217
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
|
|
1214
1218
|
providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
|
|
1215
1219
|
}
|
|
1216
|
-
if (((
|
|
1220
|
+
if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
|
|
1217
1221
|
providerMetadata.openai.logprobs = choice.logprobs.content;
|
|
1218
1222
|
}
|
|
1219
1223
|
return {
|
|
1220
1224
|
content,
|
|
1221
1225
|
finishReason: {
|
|
1222
1226
|
unified: mapOpenAIFinishReason(choice.finish_reason),
|
|
1223
|
-
raw: (
|
|
1227
|
+
raw: (_h = choice.finish_reason) != null ? _h : void 0
|
|
1224
1228
|
},
|
|
1225
1229
|
usage: convertOpenAIChatUsage(response.usage),
|
|
1226
1230
|
request: { body },
|
|
@@ -7157,7 +7161,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7157
7161
|
};
|
|
7158
7162
|
} else if (value.item.type === "shell_call_output") {
|
|
7159
7163
|
} else if (value.item.type === "message") {
|
|
7160
|
-
ongoingAnnotations.splice(0
|
|
7164
|
+
ongoingAnnotations.splice(0);
|
|
7161
7165
|
activeMessagePhase = (_b2 = value.item.phase) != null ? _b2 : void 0;
|
|
7162
7166
|
controller.enqueue({
|
|
7163
7167
|
type: "text-start",
|