@ai-sdk/openai 1.3.8 → 1.3.9

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.
@@ -1689,7 +1689,7 @@ var OpenAITranscriptionModel = class {
1689
1689
  }
1690
1690
  getArgs({
1691
1691
  audio,
1692
- mimeType,
1692
+ mediaType,
1693
1693
  providerOptions
1694
1694
  }) {
1695
1695
  const warnings = [];
@@ -1701,7 +1701,7 @@ var OpenAITranscriptionModel = class {
1701
1701
  const formData = new FormData();
1702
1702
  const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils7.convertBase64ToUint8Array)(audio)]);
1703
1703
  formData.append("model", this.modelId);
1704
- formData.append("file", new File([blob], "audio", { type: mimeType }));
1704
+ formData.append("file", new File([blob], "audio", { type: mediaType }));
1705
1705
  if (openAIOptions) {
1706
1706
  const transcriptionModelOptions = {
1707
1707
  include: openAIOptions.include,
@@ -1723,10 +1723,14 @@ var OpenAITranscriptionModel = class {
1723
1723
  };
1724
1724
  }
1725
1725
  async doGenerate(options) {
1726
- var _a, _b, _c;
1726
+ var _a, _b, _c, _d, _e, _f;
1727
1727
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1728
1728
  const { formData, warnings } = this.getArgs(options);
1729
- const { value: response, responseHeaders } = await (0, import_provider_utils7.postFormDataToApi)({
1729
+ const {
1730
+ value: response,
1731
+ responseHeaders,
1732
+ rawValue: rawResponse
1733
+ } = await (0, import_provider_utils7.postFormDataToApi)({
1730
1734
  url: this.config.url({
1731
1735
  path: "/audio/transcriptions",
1732
1736
  modelId: this.modelId
@@ -1740,46 +1744,37 @@ var OpenAITranscriptionModel = class {
1740
1744
  abortSignal: options.abortSignal,
1741
1745
  fetch: this.config.fetch
1742
1746
  });
1743
- let language;
1744
- if (response.language && response.language in languageMap) {
1745
- language = languageMap[response.language];
1746
- }
1747
+ const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
1747
1748
  return {
1748
1749
  text: response.text,
1749
- segments: response.words.map((word) => ({
1750
+ segments: (_e = (_d = response.words) == null ? void 0 : _d.map((word) => ({
1750
1751
  text: word.word,
1751
1752
  startSecond: word.start,
1752
1753
  endSecond: word.end
1753
- })),
1754
+ }))) != null ? _e : [],
1754
1755
  language,
1755
- durationInSeconds: response.duration,
1756
+ durationInSeconds: (_f = response.duration) != null ? _f : void 0,
1756
1757
  warnings,
1757
1758
  response: {
1758
1759
  timestamp: currentDate,
1759
1760
  modelId: this.modelId,
1760
1761
  headers: responseHeaders,
1761
- body: response
1762
- },
1763
- // When using format `verbose_json` on `whisper-1`, OpenAI includes the things like `task` and enhanced `segments` information.
1764
- providerMetadata: {
1765
- openai: {
1766
- transcript: response
1767
- }
1762
+ body: rawResponse
1768
1763
  }
1769
1764
  };
1770
1765
  }
1771
1766
  };
1772
1767
  var openaiTranscriptionResponseSchema = import_zod6.z.object({
1773
1768
  text: import_zod6.z.string(),
1774
- language: import_zod6.z.string().optional(),
1775
- duration: import_zod6.z.number().optional(),
1769
+ language: import_zod6.z.string().nullish(),
1770
+ duration: import_zod6.z.number().nullish(),
1776
1771
  words: import_zod6.z.array(
1777
1772
  import_zod6.z.object({
1778
1773
  word: import_zod6.z.string(),
1779
1774
  start: import_zod6.z.number(),
1780
1775
  end: import_zod6.z.number()
1781
1776
  })
1782
- )
1777
+ ).nullish()
1783
1778
  });
1784
1779
 
1785
1780
  // src/responses/openai-responses-language-model.ts