@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.
- package/CHANGELOG.md +10 -0
- package/dist/index.js +16 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -21
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.js +16 -21
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +16 -21
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1703,7 +1703,7 @@ var OpenAITranscriptionModel = class {
|
|
|
1703
1703
|
}
|
|
1704
1704
|
getArgs({
|
|
1705
1705
|
audio,
|
|
1706
|
-
|
|
1706
|
+
mediaType,
|
|
1707
1707
|
providerOptions
|
|
1708
1708
|
}) {
|
|
1709
1709
|
const warnings = [];
|
|
@@ -1715,7 +1715,7 @@ var OpenAITranscriptionModel = class {
|
|
|
1715
1715
|
const formData = new FormData();
|
|
1716
1716
|
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array(audio)]);
|
|
1717
1717
|
formData.append("model", this.modelId);
|
|
1718
|
-
formData.append("file", new File([blob], "audio", { type:
|
|
1718
|
+
formData.append("file", new File([blob], "audio", { type: mediaType }));
|
|
1719
1719
|
if (openAIOptions) {
|
|
1720
1720
|
const transcriptionModelOptions = {
|
|
1721
1721
|
include: openAIOptions.include,
|
|
@@ -1737,10 +1737,14 @@ var OpenAITranscriptionModel = class {
|
|
|
1737
1737
|
};
|
|
1738
1738
|
}
|
|
1739
1739
|
async doGenerate(options) {
|
|
1740
|
-
var _a, _b, _c;
|
|
1740
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1741
1741
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1742
1742
|
const { formData, warnings } = this.getArgs(options);
|
|
1743
|
-
const {
|
|
1743
|
+
const {
|
|
1744
|
+
value: response,
|
|
1745
|
+
responseHeaders,
|
|
1746
|
+
rawValue: rawResponse
|
|
1747
|
+
} = await postFormDataToApi({
|
|
1744
1748
|
url: this.config.url({
|
|
1745
1749
|
path: "/audio/transcriptions",
|
|
1746
1750
|
modelId: this.modelId
|
|
@@ -1754,46 +1758,37 @@ var OpenAITranscriptionModel = class {
|
|
|
1754
1758
|
abortSignal: options.abortSignal,
|
|
1755
1759
|
fetch: this.config.fetch
|
|
1756
1760
|
});
|
|
1757
|
-
|
|
1758
|
-
if (response.language && response.language in languageMap) {
|
|
1759
|
-
language = languageMap[response.language];
|
|
1760
|
-
}
|
|
1761
|
+
const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
|
|
1761
1762
|
return {
|
|
1762
1763
|
text: response.text,
|
|
1763
|
-
segments: response.words.map((word) => ({
|
|
1764
|
+
segments: (_e = (_d = response.words) == null ? void 0 : _d.map((word) => ({
|
|
1764
1765
|
text: word.word,
|
|
1765
1766
|
startSecond: word.start,
|
|
1766
1767
|
endSecond: word.end
|
|
1767
|
-
})),
|
|
1768
|
+
}))) != null ? _e : [],
|
|
1768
1769
|
language,
|
|
1769
|
-
durationInSeconds: response.duration,
|
|
1770
|
+
durationInSeconds: (_f = response.duration) != null ? _f : void 0,
|
|
1770
1771
|
warnings,
|
|
1771
1772
|
response: {
|
|
1772
1773
|
timestamp: currentDate,
|
|
1773
1774
|
modelId: this.modelId,
|
|
1774
1775
|
headers: responseHeaders,
|
|
1775
|
-
body:
|
|
1776
|
-
},
|
|
1777
|
-
// When using format `verbose_json` on `whisper-1`, OpenAI includes the things like `task` and enhanced `segments` information.
|
|
1778
|
-
providerMetadata: {
|
|
1779
|
-
openai: {
|
|
1780
|
-
transcript: response
|
|
1781
|
-
}
|
|
1776
|
+
body: rawResponse
|
|
1782
1777
|
}
|
|
1783
1778
|
};
|
|
1784
1779
|
}
|
|
1785
1780
|
};
|
|
1786
1781
|
var openaiTranscriptionResponseSchema = z6.object({
|
|
1787
1782
|
text: z6.string(),
|
|
1788
|
-
language: z6.string().
|
|
1789
|
-
duration: z6.number().
|
|
1783
|
+
language: z6.string().nullish(),
|
|
1784
|
+
duration: z6.number().nullish(),
|
|
1790
1785
|
words: z6.array(
|
|
1791
1786
|
z6.object({
|
|
1792
1787
|
word: z6.string(),
|
|
1793
1788
|
start: z6.number(),
|
|
1794
1789
|
end: z6.number()
|
|
1795
1790
|
})
|
|
1796
|
-
)
|
|
1791
|
+
).nullish()
|
|
1797
1792
|
});
|
|
1798
1793
|
|
|
1799
1794
|
// src/responses/openai-responses-language-model.ts
|