@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/internal/index.js
CHANGED
|
@@ -1767,42 +1767,50 @@ var OpenAIImageModel = class {
|
|
|
1767
1767
|
},
|
|
1768
1768
|
providerMetadata: {
|
|
1769
1769
|
openai: {
|
|
1770
|
-
images: response.data.map((item, index) => {
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
)
|
|
1784
|
-
};
|
|
1785
|
-
})
|
|
1770
|
+
images: response.data.map((item, index) => ({
|
|
1771
|
+
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1772
|
+
...response.created != null ? { created: response.created } : {},
|
|
1773
|
+
...response.size != null ? { size: response.size } : {},
|
|
1774
|
+
...response.quality != null ? { quality: response.quality } : {},
|
|
1775
|
+
...response.background != null ? { background: response.background } : {},
|
|
1776
|
+
...response.output_format != null ? { outputFormat: response.output_format } : {},
|
|
1777
|
+
...distributeTokenDetails(
|
|
1778
|
+
response.usage,
|
|
1779
|
+
index,
|
|
1780
|
+
response.data.length
|
|
1781
|
+
)
|
|
1782
|
+
}))
|
|
1786
1783
|
}
|
|
1787
1784
|
}
|
|
1788
1785
|
};
|
|
1789
1786
|
}
|
|
1790
1787
|
};
|
|
1791
|
-
function distributeTokenDetails(
|
|
1792
|
-
if (
|
|
1788
|
+
function distributeTokenDetails(usage, index, total) {
|
|
1789
|
+
if (usage == null) {
|
|
1793
1790
|
return {};
|
|
1794
1791
|
}
|
|
1795
1792
|
const result = {};
|
|
1796
|
-
|
|
1793
|
+
const details = usage.input_tokens_details;
|
|
1794
|
+
if ((details == null ? void 0 : details.image_tokens) != null) {
|
|
1797
1795
|
const base = Math.floor(details.image_tokens / total);
|
|
1798
1796
|
const remainder = details.image_tokens - base * (total - 1);
|
|
1799
1797
|
result.imageTokens = index === total - 1 ? remainder : base;
|
|
1800
1798
|
}
|
|
1801
|
-
if (details.text_tokens != null) {
|
|
1799
|
+
if ((details == null ? void 0 : details.text_tokens) != null) {
|
|
1802
1800
|
const base = Math.floor(details.text_tokens / total);
|
|
1803
1801
|
const remainder = details.text_tokens - base * (total - 1);
|
|
1804
1802
|
result.textTokens = index === total - 1 ? remainder : base;
|
|
1805
1803
|
}
|
|
1804
|
+
if (usage.input_tokens != null) {
|
|
1805
|
+
const base = Math.floor(usage.input_tokens / total);
|
|
1806
|
+
const remainder = usage.input_tokens - base * (total - 1);
|
|
1807
|
+
result.inputTokens = index === total - 1 ? remainder : base;
|
|
1808
|
+
}
|
|
1809
|
+
if (usage.output_tokens != null) {
|
|
1810
|
+
const base = Math.floor(usage.output_tokens / total);
|
|
1811
|
+
const remainder = usage.output_tokens - base * (total - 1);
|
|
1812
|
+
result.outputTokens = index === total - 1 ? remainder : base;
|
|
1813
|
+
}
|
|
1806
1814
|
return result;
|
|
1807
1815
|
}
|
|
1808
1816
|
|