@ai-sdk/openai 3.0.28 → 3.0.29
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 +34 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -7
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +33 -6
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +33 -6
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/image/openai-image-model.ts +46 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -1859,15 +1859,20 @@ var OpenAIImageModel = class {
|
|
|
1859
1859
|
},
|
|
1860
1860
|
providerMetadata: {
|
|
1861
1861
|
openai: {
|
|
1862
|
-
images: response2.data.map((item) => {
|
|
1863
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
1862
|
+
images: response2.data.map((item, index) => {
|
|
1863
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1864
1864
|
return {
|
|
1865
1865
|
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1866
1866
|
created: (_a2 = response2.created) != null ? _a2 : void 0,
|
|
1867
1867
|
size: (_b2 = response2.size) != null ? _b2 : void 0,
|
|
1868
1868
|
quality: (_c2 = response2.quality) != null ? _c2 : void 0,
|
|
1869
1869
|
background: (_d2 = response2.background) != null ? _d2 : void 0,
|
|
1870
|
-
outputFormat: (_e2 = response2.output_format) != null ? _e2 : void 0
|
|
1870
|
+
outputFormat: (_e2 = response2.output_format) != null ? _e2 : void 0,
|
|
1871
|
+
...distributeTokenDetails(
|
|
1872
|
+
(_f2 = response2.usage) == null ? void 0 : _f2.input_tokens_details,
|
|
1873
|
+
index,
|
|
1874
|
+
response2.data.length
|
|
1875
|
+
)
|
|
1871
1876
|
};
|
|
1872
1877
|
})
|
|
1873
1878
|
}
|
|
@@ -1910,15 +1915,20 @@ var OpenAIImageModel = class {
|
|
|
1910
1915
|
},
|
|
1911
1916
|
providerMetadata: {
|
|
1912
1917
|
openai: {
|
|
1913
|
-
images: response.data.map((item) => {
|
|
1914
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
1918
|
+
images: response.data.map((item, index) => {
|
|
1919
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1915
1920
|
return {
|
|
1916
1921
|
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1917
1922
|
created: (_a2 = response.created) != null ? _a2 : void 0,
|
|
1918
1923
|
size: (_b2 = response.size) != null ? _b2 : void 0,
|
|
1919
1924
|
quality: (_c2 = response.quality) != null ? _c2 : void 0,
|
|
1920
1925
|
background: (_d2 = response.background) != null ? _d2 : void 0,
|
|
1921
|
-
outputFormat: (_e2 = response.output_format) != null ? _e2 : void 0
|
|
1926
|
+
outputFormat: (_e2 = response.output_format) != null ? _e2 : void 0,
|
|
1927
|
+
...distributeTokenDetails(
|
|
1928
|
+
(_f2 = response.usage) == null ? void 0 : _f2.input_tokens_details,
|
|
1929
|
+
index,
|
|
1930
|
+
response.data.length
|
|
1931
|
+
)
|
|
1922
1932
|
};
|
|
1923
1933
|
})
|
|
1924
1934
|
}
|
|
@@ -1926,6 +1936,23 @@ var OpenAIImageModel = class {
|
|
|
1926
1936
|
};
|
|
1927
1937
|
}
|
|
1928
1938
|
};
|
|
1939
|
+
function distributeTokenDetails(details, index, total) {
|
|
1940
|
+
if (details == null) {
|
|
1941
|
+
return {};
|
|
1942
|
+
}
|
|
1943
|
+
const result = {};
|
|
1944
|
+
if (details.image_tokens != null) {
|
|
1945
|
+
const base = Math.floor(details.image_tokens / total);
|
|
1946
|
+
const remainder = details.image_tokens - base * (total - 1);
|
|
1947
|
+
result.imageTokens = index === total - 1 ? remainder : base;
|
|
1948
|
+
}
|
|
1949
|
+
if (details.text_tokens != null) {
|
|
1950
|
+
const base = Math.floor(details.text_tokens / total);
|
|
1951
|
+
const remainder = details.text_tokens - base * (total - 1);
|
|
1952
|
+
result.textTokens = index === total - 1 ? remainder : base;
|
|
1953
|
+
}
|
|
1954
|
+
return result;
|
|
1955
|
+
}
|
|
1929
1956
|
async function fileToBlob(file) {
|
|
1930
1957
|
if (!file) return void 0;
|
|
1931
1958
|
if (file.type === "url") {
|