@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.
@@ -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 (_a2 = choice.message.tool_calls) != null ? _a2 : []) {
1194
+ for (const toolCall of (_b = choice.message.tool_calls) != null ? _b : []) {
1191
1195
  content.push({
1192
1196
  type: "tool-call",
1193
- toolCallId: (_b = toolCall.id) != null ? _b : (0, import_provider_utils5.generateId)(),
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 (_c = choice.message.annotations) != null ? _c : []) {
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 = (_d = response.usage) == null ? void 0 : _d.completion_tokens_details;
1208
- const promptTokenDetails = (_e = response.usage) == null ? void 0 : _e.prompt_tokens_details;
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 (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
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: (_g = choice.finish_reason) != null ? _g : void 0
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, ongoingAnnotations.length);
7164
+ ongoingAnnotations.splice(0);
7161
7165
  activeMessagePhase = (_b2 = value.item.phase) != null ? _b2 : void 0;
7162
7166
  controller.enqueue({
7163
7167
  type: "text-start",