@ai-sdk/openai 2.0.91 → 2.0.92
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 +6 -0
- package/dist/index.js +29 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -21
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +28 -20
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +28 -20
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1771,42 +1771,50 @@ var OpenAIImageModel = class {
|
|
|
1771
1771
|
},
|
|
1772
1772
|
providerMetadata: {
|
|
1773
1773
|
openai: {
|
|
1774
|
-
images: response.data.map((item, index) => {
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
)
|
|
1788
|
-
};
|
|
1789
|
-
})
|
|
1774
|
+
images: response.data.map((item, index) => ({
|
|
1775
|
+
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1776
|
+
...response.created != null ? { created: response.created } : {},
|
|
1777
|
+
...response.size != null ? { size: response.size } : {},
|
|
1778
|
+
...response.quality != null ? { quality: response.quality } : {},
|
|
1779
|
+
...response.background != null ? { background: response.background } : {},
|
|
1780
|
+
...response.output_format != null ? { outputFormat: response.output_format } : {},
|
|
1781
|
+
...distributeTokenDetails(
|
|
1782
|
+
response.usage,
|
|
1783
|
+
index,
|
|
1784
|
+
response.data.length
|
|
1785
|
+
)
|
|
1786
|
+
}))
|
|
1790
1787
|
}
|
|
1791
1788
|
}
|
|
1792
1789
|
};
|
|
1793
1790
|
}
|
|
1794
1791
|
};
|
|
1795
|
-
function distributeTokenDetails(
|
|
1796
|
-
if (
|
|
1792
|
+
function distributeTokenDetails(usage, index, total) {
|
|
1793
|
+
if (usage == null) {
|
|
1797
1794
|
return {};
|
|
1798
1795
|
}
|
|
1799
1796
|
const result = {};
|
|
1800
|
-
|
|
1797
|
+
const details = usage.input_tokens_details;
|
|
1798
|
+
if ((details == null ? void 0 : details.image_tokens) != null) {
|
|
1801
1799
|
const base = Math.floor(details.image_tokens / total);
|
|
1802
1800
|
const remainder = details.image_tokens - base * (total - 1);
|
|
1803
1801
|
result.imageTokens = index === total - 1 ? remainder : base;
|
|
1804
1802
|
}
|
|
1805
|
-
if (details.text_tokens != null) {
|
|
1803
|
+
if ((details == null ? void 0 : details.text_tokens) != null) {
|
|
1806
1804
|
const base = Math.floor(details.text_tokens / total);
|
|
1807
1805
|
const remainder = details.text_tokens - base * (total - 1);
|
|
1808
1806
|
result.textTokens = index === total - 1 ? remainder : base;
|
|
1809
1807
|
}
|
|
1808
|
+
if (usage.input_tokens != null) {
|
|
1809
|
+
const base = Math.floor(usage.input_tokens / total);
|
|
1810
|
+
const remainder = usage.input_tokens - base * (total - 1);
|
|
1811
|
+
result.inputTokens = index === total - 1 ? remainder : base;
|
|
1812
|
+
}
|
|
1813
|
+
if (usage.output_tokens != null) {
|
|
1814
|
+
const base = Math.floor(usage.output_tokens / total);
|
|
1815
|
+
const remainder = usage.output_tokens - base * (total - 1);
|
|
1816
|
+
result.outputTokens = index === total - 1 ? remainder : base;
|
|
1817
|
+
}
|
|
1810
1818
|
return result;
|
|
1811
1819
|
}
|
|
1812
1820
|
|
|
@@ -4681,7 +4689,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4681
4689
|
};
|
|
4682
4690
|
|
|
4683
4691
|
// src/version.ts
|
|
4684
|
-
var VERSION = true ? "2.0.
|
|
4692
|
+
var VERSION = true ? "2.0.92" : "0.0.0-test";
|
|
4685
4693
|
|
|
4686
4694
|
// src/openai-provider.ts
|
|
4687
4695
|
function createOpenAI(options = {}) {
|