@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/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1745,42 +1745,50 @@ var OpenAIImageModel = class {
|
|
|
1745
1745
|
},
|
|
1746
1746
|
providerMetadata: {
|
|
1747
1747
|
openai: {
|
|
1748
|
-
images: response.data.map((item, index) => {
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
)
|
|
1762
|
-
};
|
|
1763
|
-
})
|
|
1748
|
+
images: response.data.map((item, index) => ({
|
|
1749
|
+
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1750
|
+
...response.created != null ? { created: response.created } : {},
|
|
1751
|
+
...response.size != null ? { size: response.size } : {},
|
|
1752
|
+
...response.quality != null ? { quality: response.quality } : {},
|
|
1753
|
+
...response.background != null ? { background: response.background } : {},
|
|
1754
|
+
...response.output_format != null ? { outputFormat: response.output_format } : {},
|
|
1755
|
+
...distributeTokenDetails(
|
|
1756
|
+
response.usage,
|
|
1757
|
+
index,
|
|
1758
|
+
response.data.length
|
|
1759
|
+
)
|
|
1760
|
+
}))
|
|
1764
1761
|
}
|
|
1765
1762
|
}
|
|
1766
1763
|
};
|
|
1767
1764
|
}
|
|
1768
1765
|
};
|
|
1769
|
-
function distributeTokenDetails(
|
|
1770
|
-
if (
|
|
1766
|
+
function distributeTokenDetails(usage, index, total) {
|
|
1767
|
+
if (usage == null) {
|
|
1771
1768
|
return {};
|
|
1772
1769
|
}
|
|
1773
1770
|
const result = {};
|
|
1774
|
-
|
|
1771
|
+
const details = usage.input_tokens_details;
|
|
1772
|
+
if ((details == null ? void 0 : details.image_tokens) != null) {
|
|
1775
1773
|
const base = Math.floor(details.image_tokens / total);
|
|
1776
1774
|
const remainder = details.image_tokens - base * (total - 1);
|
|
1777
1775
|
result.imageTokens = index === total - 1 ? remainder : base;
|
|
1778
1776
|
}
|
|
1779
|
-
if (details.text_tokens != null) {
|
|
1777
|
+
if ((details == null ? void 0 : details.text_tokens) != null) {
|
|
1780
1778
|
const base = Math.floor(details.text_tokens / total);
|
|
1781
1779
|
const remainder = details.text_tokens - base * (total - 1);
|
|
1782
1780
|
result.textTokens = index === total - 1 ? remainder : base;
|
|
1783
1781
|
}
|
|
1782
|
+
if (usage.input_tokens != null) {
|
|
1783
|
+
const base = Math.floor(usage.input_tokens / total);
|
|
1784
|
+
const remainder = usage.input_tokens - base * (total - 1);
|
|
1785
|
+
result.inputTokens = index === total - 1 ? remainder : base;
|
|
1786
|
+
}
|
|
1787
|
+
if (usage.output_tokens != null) {
|
|
1788
|
+
const base = Math.floor(usage.output_tokens / total);
|
|
1789
|
+
const remainder = usage.output_tokens - base * (total - 1);
|
|
1790
|
+
result.outputTokens = index === total - 1 ? remainder : base;
|
|
1791
|
+
}
|
|
1784
1792
|
return result;
|
|
1785
1793
|
}
|
|
1786
1794
|
|
|
@@ -4590,7 +4598,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4590
4598
|
};
|
|
4591
4599
|
|
|
4592
4600
|
// src/version.ts
|
|
4593
|
-
var VERSION = true ? "2.0.
|
|
4601
|
+
var VERSION = true ? "2.0.92" : "0.0.0-test";
|
|
4594
4602
|
|
|
4595
4603
|
// src/openai-provider.ts
|
|
4596
4604
|
function createOpenAI(options = {}) {
|