@ai-sdk/openai 3.0.27 → 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 +13 -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 +2 -2
- package/src/image/openai-image-model.ts +46 -2
package/dist/internal/index.js
CHANGED
|
@@ -1879,15 +1879,20 @@ var OpenAIImageModel = class {
|
|
|
1879
1879
|
},
|
|
1880
1880
|
providerMetadata: {
|
|
1881
1881
|
openai: {
|
|
1882
|
-
images: response2.data.map((item) => {
|
|
1883
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
1882
|
+
images: response2.data.map((item, index) => {
|
|
1883
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1884
1884
|
return {
|
|
1885
1885
|
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1886
1886
|
created: (_a2 = response2.created) != null ? _a2 : void 0,
|
|
1887
1887
|
size: (_b2 = response2.size) != null ? _b2 : void 0,
|
|
1888
1888
|
quality: (_c2 = response2.quality) != null ? _c2 : void 0,
|
|
1889
1889
|
background: (_d2 = response2.background) != null ? _d2 : void 0,
|
|
1890
|
-
outputFormat: (_e2 = response2.output_format) != null ? _e2 : void 0
|
|
1890
|
+
outputFormat: (_e2 = response2.output_format) != null ? _e2 : void 0,
|
|
1891
|
+
...distributeTokenDetails(
|
|
1892
|
+
(_f2 = response2.usage) == null ? void 0 : _f2.input_tokens_details,
|
|
1893
|
+
index,
|
|
1894
|
+
response2.data.length
|
|
1895
|
+
)
|
|
1891
1896
|
};
|
|
1892
1897
|
})
|
|
1893
1898
|
}
|
|
@@ -1930,15 +1935,20 @@ var OpenAIImageModel = class {
|
|
|
1930
1935
|
},
|
|
1931
1936
|
providerMetadata: {
|
|
1932
1937
|
openai: {
|
|
1933
|
-
images: response.data.map((item) => {
|
|
1934
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
1938
|
+
images: response.data.map((item, index) => {
|
|
1939
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1935
1940
|
return {
|
|
1936
1941
|
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1937
1942
|
created: (_a2 = response.created) != null ? _a2 : void 0,
|
|
1938
1943
|
size: (_b2 = response.size) != null ? _b2 : void 0,
|
|
1939
1944
|
quality: (_c2 = response.quality) != null ? _c2 : void 0,
|
|
1940
1945
|
background: (_d2 = response.background) != null ? _d2 : void 0,
|
|
1941
|
-
outputFormat: (_e2 = response.output_format) != null ? _e2 : void 0
|
|
1946
|
+
outputFormat: (_e2 = response.output_format) != null ? _e2 : void 0,
|
|
1947
|
+
...distributeTokenDetails(
|
|
1948
|
+
(_f2 = response.usage) == null ? void 0 : _f2.input_tokens_details,
|
|
1949
|
+
index,
|
|
1950
|
+
response.data.length
|
|
1951
|
+
)
|
|
1942
1952
|
};
|
|
1943
1953
|
})
|
|
1944
1954
|
}
|
|
@@ -1946,6 +1956,23 @@ var OpenAIImageModel = class {
|
|
|
1946
1956
|
};
|
|
1947
1957
|
}
|
|
1948
1958
|
};
|
|
1959
|
+
function distributeTokenDetails(details, index, total) {
|
|
1960
|
+
if (details == null) {
|
|
1961
|
+
return {};
|
|
1962
|
+
}
|
|
1963
|
+
const result = {};
|
|
1964
|
+
if (details.image_tokens != null) {
|
|
1965
|
+
const base = Math.floor(details.image_tokens / total);
|
|
1966
|
+
const remainder = details.image_tokens - base * (total - 1);
|
|
1967
|
+
result.imageTokens = index === total - 1 ? remainder : base;
|
|
1968
|
+
}
|
|
1969
|
+
if (details.text_tokens != null) {
|
|
1970
|
+
const base = Math.floor(details.text_tokens / total);
|
|
1971
|
+
const remainder = details.text_tokens - base * (total - 1);
|
|
1972
|
+
result.textTokens = index === total - 1 ? remainder : base;
|
|
1973
|
+
}
|
|
1974
|
+
return result;
|
|
1975
|
+
}
|
|
1949
1976
|
async function fileToBlob(file) {
|
|
1950
1977
|
if (!file) return void 0;
|
|
1951
1978
|
if (file.type === "url") {
|