@ai-sdk/openai 2.0.90 → 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 +12 -0
- package/dist/index.js +36 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +35 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +35 -2
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1771,19 +1771,52 @@ var OpenAIImageModel = class {
|
|
|
1771
1771
|
},
|
|
1772
1772
|
providerMetadata: {
|
|
1773
1773
|
openai: {
|
|
1774
|
-
images: response.data.map((item) => ({
|
|
1774
|
+
images: response.data.map((item, index) => ({
|
|
1775
1775
|
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1776
1776
|
...response.created != null ? { created: response.created } : {},
|
|
1777
1777
|
...response.size != null ? { size: response.size } : {},
|
|
1778
1778
|
...response.quality != null ? { quality: response.quality } : {},
|
|
1779
1779
|
...response.background != null ? { background: response.background } : {},
|
|
1780
|
-
...response.output_format != null ? { outputFormat: response.output_format } : {}
|
|
1780
|
+
...response.output_format != null ? { outputFormat: response.output_format } : {},
|
|
1781
|
+
...distributeTokenDetails(
|
|
1782
|
+
response.usage,
|
|
1783
|
+
index,
|
|
1784
|
+
response.data.length
|
|
1785
|
+
)
|
|
1781
1786
|
}))
|
|
1782
1787
|
}
|
|
1783
1788
|
}
|
|
1784
1789
|
};
|
|
1785
1790
|
}
|
|
1786
1791
|
};
|
|
1792
|
+
function distributeTokenDetails(usage, index, total) {
|
|
1793
|
+
if (usage == null) {
|
|
1794
|
+
return {};
|
|
1795
|
+
}
|
|
1796
|
+
const result = {};
|
|
1797
|
+
const details = usage.input_tokens_details;
|
|
1798
|
+
if ((details == null ? void 0 : details.image_tokens) != null) {
|
|
1799
|
+
const base = Math.floor(details.image_tokens / total);
|
|
1800
|
+
const remainder = details.image_tokens - base * (total - 1);
|
|
1801
|
+
result.imageTokens = index === total - 1 ? remainder : base;
|
|
1802
|
+
}
|
|
1803
|
+
if ((details == null ? void 0 : details.text_tokens) != null) {
|
|
1804
|
+
const base = Math.floor(details.text_tokens / total);
|
|
1805
|
+
const remainder = details.text_tokens - base * (total - 1);
|
|
1806
|
+
result.textTokens = index === total - 1 ? remainder : base;
|
|
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
|
+
}
|
|
1818
|
+
return result;
|
|
1819
|
+
}
|
|
1787
1820
|
|
|
1788
1821
|
// src/tool/code-interpreter.ts
|
|
1789
1822
|
import {
|
|
@@ -4656,7 +4689,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4656
4689
|
};
|
|
4657
4690
|
|
|
4658
4691
|
// src/version.ts
|
|
4659
|
-
var VERSION = true ? "2.0.
|
|
4692
|
+
var VERSION = true ? "2.0.92" : "0.0.0-test";
|
|
4660
4693
|
|
|
4661
4694
|
// src/openai-provider.ts
|
|
4662
4695
|
function createOpenAI(options = {}) {
|