@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/dist/index.mjs CHANGED
@@ -153,7 +153,8 @@ function createOpenAIStreamError({
153
153
  statusCode: streamError == null ? 500 : getStatusCode(streamError),
154
154
  responseHeaders,
155
155
  responseBody: JSON.stringify(frame),
156
- data: frame
156
+ data: frame,
157
+ isRetryable: streamError == null ? true : isRetryableStreamError(streamError, getStatusCode(streamError))
157
158
  });
158
159
  }
159
160
  function parseStreamError(frame) {
@@ -572,6 +573,9 @@ var openaiChatResponseSchema = lazySchema(
572
573
  message: z2.object({
573
574
  role: z2.literal("assistant").nullish(),
574
575
  content: z2.string().nullish(),
576
+ audio: z2.object({
577
+ transcript: z2.string().nullish()
578
+ }).nullish(),
575
579
  tool_calls: z2.array(
576
580
  z2.object({
577
581
  id: z2.string().nullish(),
@@ -1116,7 +1120,7 @@ var OpenAIChatLanguageModel = class {
1116
1120
  };
1117
1121
  }
1118
1122
  async doGenerate(options) {
1119
- var _a2, _b, _c, _d, _e, _f, _g;
1123
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
1120
1124
  const { args: body, warnings } = await this.getArgs(options);
1121
1125
  const {
1122
1126
  responseHeaders,
@@ -1144,19 +1148,19 @@ var OpenAIChatLanguageModel = class {
1144
1148
  });
1145
1149
  }
1146
1150
  const content = [];
1147
- const text = choice.message.content;
1151
+ const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_a2 = choice.message.audio) == null ? void 0 : _a2.transcript;
1148
1152
  if (text != null && text.length > 0) {
1149
1153
  content.push({ type: "text", text });
1150
1154
  }
1151
- for (const toolCall of (_a2 = choice.message.tool_calls) != null ? _a2 : []) {
1155
+ for (const toolCall of (_b = choice.message.tool_calls) != null ? _b : []) {
1152
1156
  content.push({
1153
1157
  type: "tool-call",
1154
- toolCallId: (_b = toolCall.id) != null ? _b : generateId(),
1158
+ toolCallId: (_c = toolCall.id) != null ? _c : generateId(),
1155
1159
  toolName: toolCall.function.name,
1156
1160
  input: toolCall.function.arguments
1157
1161
  });
1158
1162
  }
1159
- for (const annotation of (_c = choice.message.annotations) != null ? _c : []) {
1163
+ for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
1160
1164
  content.push({
1161
1165
  type: "source",
1162
1166
  sourceType: "url",
@@ -1165,8 +1169,8 @@ var OpenAIChatLanguageModel = class {
1165
1169
  title: annotation.url_citation.title
1166
1170
  });
1167
1171
  }
1168
- const completionTokenDetails = (_d = response.usage) == null ? void 0 : _d.completion_tokens_details;
1169
- const promptTokenDetails = (_e = response.usage) == null ? void 0 : _e.prompt_tokens_details;
1172
+ const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
1173
+ const promptTokenDetails = (_f = response.usage) == null ? void 0 : _f.prompt_tokens_details;
1170
1174
  const providerMetadata = { openai: {} };
1171
1175
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
1172
1176
  providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
@@ -1174,14 +1178,14 @@ var OpenAIChatLanguageModel = class {
1174
1178
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
1175
1179
  providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
1176
1180
  }
1177
- if (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
1181
+ if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
1178
1182
  providerMetadata.openai.logprobs = choice.logprobs.content;
1179
1183
  }
1180
1184
  return {
1181
1185
  content,
1182
1186
  finishReason: {
1183
1187
  unified: mapOpenAIFinishReason(choice.finish_reason),
1184
- raw: (_g = choice.finish_reason) != null ? _g : void 0
1188
+ raw: (_h = choice.finish_reason) != null ? _h : void 0
1185
1189
  },
1186
1190
  usage: convertOpenAIChatUsage(response.usage),
1187
1191
  request: { body },
@@ -6996,7 +7000,7 @@ var OpenAIResponsesLanguageModel = class {
6996
7000
  };
6997
7001
  } else if (value.item.type === "shell_call_output") {
6998
7002
  } else if (value.item.type === "message") {
6999
- ongoingAnnotations.splice(0, ongoingAnnotations.length);
7003
+ ongoingAnnotations.splice(0);
7000
7004
  activeMessagePhase = (_b2 = value.item.phase) != null ? _b2 : void 0;
7001
7005
  controller.enqueue({
7002
7006
  type: "text-start",
@@ -8256,7 +8260,7 @@ var OpenAITranscriptionModel = class {
8256
8260
  };
8257
8261
 
8258
8262
  // src/version.ts
8259
- var VERSION = true ? "3.0.116" : "0.0.0-test";
8263
+ var VERSION = true ? "3.0.117" : "0.0.0-test";
8260
8264
 
8261
8265
  // src/openai-provider.ts
8262
8266
  function createOpenAI(options = {}) {