@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.
@@ -145,7 +145,8 @@ function createOpenAIStreamError({
145
145
  statusCode: streamError == null ? 500 : getStatusCode(streamError),
146
146
  responseHeaders,
147
147
  responseBody: JSON.stringify(frame),
148
- data: frame
148
+ data: frame,
149
+ isRetryable: streamError == null ? true : isRetryableStreamError(streamError, getStatusCode(streamError))
149
150
  });
150
151
  }
151
152
  function parseStreamError(frame) {
@@ -564,6 +565,9 @@ var openaiChatResponseSchema = lazySchema(
564
565
  message: z2.object({
565
566
  role: z2.literal("assistant").nullish(),
566
567
  content: z2.string().nullish(),
568
+ audio: z2.object({
569
+ transcript: z2.string().nullish()
570
+ }).nullish(),
567
571
  tool_calls: z2.array(
568
572
  z2.object({
569
573
  id: z2.string().nullish(),
@@ -1108,7 +1112,7 @@ var OpenAIChatLanguageModel = class {
1108
1112
  };
1109
1113
  }
1110
1114
  async doGenerate(options) {
1111
- var _a2, _b, _c, _d, _e, _f, _g;
1115
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
1112
1116
  const { args: body, warnings } = await this.getArgs(options);
1113
1117
  const {
1114
1118
  responseHeaders,
@@ -1136,19 +1140,19 @@ var OpenAIChatLanguageModel = class {
1136
1140
  });
1137
1141
  }
1138
1142
  const content = [];
1139
- const text = choice.message.content;
1143
+ const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_a2 = choice.message.audio) == null ? void 0 : _a2.transcript;
1140
1144
  if (text != null && text.length > 0) {
1141
1145
  content.push({ type: "text", text });
1142
1146
  }
1143
- for (const toolCall of (_a2 = choice.message.tool_calls) != null ? _a2 : []) {
1147
+ for (const toolCall of (_b = choice.message.tool_calls) != null ? _b : []) {
1144
1148
  content.push({
1145
1149
  type: "tool-call",
1146
- toolCallId: (_b = toolCall.id) != null ? _b : generateId(),
1150
+ toolCallId: (_c = toolCall.id) != null ? _c : generateId(),
1147
1151
  toolName: toolCall.function.name,
1148
1152
  input: toolCall.function.arguments
1149
1153
  });
1150
1154
  }
1151
- for (const annotation of (_c = choice.message.annotations) != null ? _c : []) {
1155
+ for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
1152
1156
  content.push({
1153
1157
  type: "source",
1154
1158
  sourceType: "url",
@@ -1157,8 +1161,8 @@ var OpenAIChatLanguageModel = class {
1157
1161
  title: annotation.url_citation.title
1158
1162
  });
1159
1163
  }
1160
- const completionTokenDetails = (_d = response.usage) == null ? void 0 : _d.completion_tokens_details;
1161
- const promptTokenDetails = (_e = response.usage) == null ? void 0 : _e.prompt_tokens_details;
1164
+ const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
1165
+ const promptTokenDetails = (_f = response.usage) == null ? void 0 : _f.prompt_tokens_details;
1162
1166
  const providerMetadata = { openai: {} };
1163
1167
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
1164
1168
  providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
@@ -1166,14 +1170,14 @@ var OpenAIChatLanguageModel = class {
1166
1170
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
1167
1171
  providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
1168
1172
  }
1169
- if (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
1173
+ if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
1170
1174
  providerMetadata.openai.logprobs = choice.logprobs.content;
1171
1175
  }
1172
1176
  return {
1173
1177
  content,
1174
1178
  finishReason: {
1175
1179
  unified: mapOpenAIFinishReason(choice.finish_reason),
1176
- raw: (_g = choice.finish_reason) != null ? _g : void 0
1180
+ raw: (_h = choice.finish_reason) != null ? _h : void 0
1177
1181
  },
1178
1182
  usage: convertOpenAIChatUsage(response.usage),
1179
1183
  request: { body },
@@ -7238,7 +7242,7 @@ var OpenAIResponsesLanguageModel = class {
7238
7242
  };
7239
7243
  } else if (value.item.type === "shell_call_output") {
7240
7244
  } else if (value.item.type === "message") {
7241
- ongoingAnnotations.splice(0, ongoingAnnotations.length);
7245
+ ongoingAnnotations.splice(0);
7242
7246
  activeMessagePhase = (_b2 = value.item.phase) != null ? _b2 : void 0;
7243
7247
  controller.enqueue({
7244
7248
  type: "text-start",