@ai-sdk/openai 2.0.128 → 2.0.129

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 2.0.129
4
+
5
+ ### Patch Changes
6
+
7
+ - 1c05ff4: fix(openai): expose Chat Completions audio transcripts as generated text
8
+ - bf29419: chore: enable dead code lint rules
9
+ - Updated dependencies [bf29419]
10
+ - @ai-sdk/provider-utils@3.0.39
11
+
3
12
  ## 2.0.128
4
13
 
5
14
  ### Patch Changes
package/dist/index.js CHANGED
@@ -390,6 +390,9 @@ var openaiChatResponseSchema = (0, import_provider_utils3.lazyValidator)(
390
390
  message: import_v42.z.object({
391
391
  role: import_v42.z.literal("assistant").nullish(),
392
392
  content: import_v42.z.string().nullish(),
393
+ audio: import_v42.z.object({
394
+ transcript: import_v42.z.string().nullish()
395
+ }).nullish(),
393
396
  tool_calls: import_v42.z.array(
394
397
  import_v42.z.object({
395
398
  id: import_v42.z.string().nullish(),
@@ -925,7 +928,7 @@ var OpenAIChatLanguageModel = class {
925
928
  };
926
929
  }
927
930
  async doGenerate(options) {
928
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
931
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
929
932
  const { args: body, warnings } = await this.getArgs(options);
930
933
  const {
931
934
  responseHeaders,
@@ -953,19 +956,19 @@ var OpenAIChatLanguageModel = class {
953
956
  });
954
957
  }
955
958
  const content = [];
956
- const text = choice.message.content;
959
+ const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_a2 = choice.message.audio) == null ? void 0 : _a2.transcript;
957
960
  if (text != null && text.length > 0) {
958
961
  content.push({ type: "text", text });
959
962
  }
960
- for (const toolCall of (_a2 = choice.message.tool_calls) != null ? _a2 : []) {
963
+ for (const toolCall of (_b = choice.message.tool_calls) != null ? _b : []) {
961
964
  content.push({
962
965
  type: "tool-call",
963
- toolCallId: (_b = toolCall.id) != null ? _b : (0, import_provider_utils5.generateId)(),
966
+ toolCallId: (_c = toolCall.id) != null ? _c : (0, import_provider_utils5.generateId)(),
964
967
  toolName: toolCall.function.name,
965
968
  input: toolCall.function.arguments
966
969
  });
967
970
  }
968
- for (const annotation of (_c = choice.message.annotations) != null ? _c : []) {
971
+ for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
969
972
  content.push({
970
973
  type: "source",
971
974
  sourceType: "url",
@@ -974,8 +977,8 @@ var OpenAIChatLanguageModel = class {
974
977
  title: annotation.url_citation.title
975
978
  });
976
979
  }
977
- const completionTokenDetails = (_d = response.usage) == null ? void 0 : _d.completion_tokens_details;
978
- const promptTokenDetails = (_e = response.usage) == null ? void 0 : _e.prompt_tokens_details;
980
+ const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
981
+ const promptTokenDetails = (_f = response.usage) == null ? void 0 : _f.prompt_tokens_details;
979
982
  const providerMetadata = { openai: {} };
980
983
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
981
984
  providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
@@ -988,18 +991,18 @@ var OpenAIChatLanguageModel = class {
988
991
  cacheWriteTokens: promptTokenDetails.cache_write_tokens
989
992
  };
990
993
  }
991
- if (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
994
+ if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
992
995
  providerMetadata.openai.logprobs = choice.logprobs.content;
993
996
  }
994
997
  return {
995
998
  content,
996
999
  finishReason: mapOpenAIFinishReason(choice.finish_reason),
997
1000
  usage: {
998
- inputTokens: (_h = (_g = response.usage) == null ? void 0 : _g.prompt_tokens) != null ? _h : void 0,
999
- outputTokens: (_j = (_i = response.usage) == null ? void 0 : _i.completion_tokens) != null ? _j : void 0,
1000
- totalTokens: (_l = (_k = response.usage) == null ? void 0 : _k.total_tokens) != null ? _l : void 0,
1001
- reasoningTokens: (_m = completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null ? _m : void 0,
1002
- cachedInputTokens: (_n = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens) != null ? _n : void 0
1001
+ inputTokens: (_i = (_h = response.usage) == null ? void 0 : _h.prompt_tokens) != null ? _i : void 0,
1002
+ outputTokens: (_k = (_j = response.usage) == null ? void 0 : _j.completion_tokens) != null ? _k : void 0,
1003
+ totalTokens: (_m = (_l = response.usage) == null ? void 0 : _l.total_tokens) != null ? _m : void 0,
1004
+ reasoningTokens: (_n = completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null ? _n : void 0,
1005
+ cachedInputTokens: (_o = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens) != null ? _o : void 0
1003
1006
  },
1004
1007
  request: { body },
1005
1008
  response: {
@@ -4342,7 +4345,7 @@ var OpenAIResponsesLanguageModel = class {
4342
4345
  providerExecuted: true
4343
4346
  });
4344
4347
  } else if (value.item.type === "message") {
4345
- ongoingAnnotations.splice(0, ongoingAnnotations.length);
4348
+ ongoingAnnotations.splice(0);
4346
4349
  activeMessagePhase = (_a2 = value.item.phase) != null ? _a2 : void 0;
4347
4350
  controller.enqueue({
4348
4351
  type: "text-start",
@@ -5140,7 +5143,7 @@ var OpenAITranscriptionModel = class {
5140
5143
  };
5141
5144
 
5142
5145
  // src/version.ts
5143
- var VERSION = true ? "2.0.128" : "0.0.0-test";
5146
+ var VERSION = true ? "2.0.129" : "0.0.0-test";
5144
5147
 
5145
5148
  // src/openai-provider.ts
5146
5149
  function createOpenAI(options = {}) {