@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/index.mjs
CHANGED
|
@@ -1867,15 +1867,20 @@ var OpenAIImageModel = class {
|
|
|
1867
1867
|
},
|
|
1868
1868
|
providerMetadata: {
|
|
1869
1869
|
openai: {
|
|
1870
|
-
images: response2.data.map((item) => {
|
|
1871
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
1870
|
+
images: response2.data.map((item, index) => {
|
|
1871
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1872
1872
|
return {
|
|
1873
1873
|
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1874
1874
|
created: (_a2 = response2.created) != null ? _a2 : void 0,
|
|
1875
1875
|
size: (_b2 = response2.size) != null ? _b2 : void 0,
|
|
1876
1876
|
quality: (_c2 = response2.quality) != null ? _c2 : void 0,
|
|
1877
1877
|
background: (_d2 = response2.background) != null ? _d2 : void 0,
|
|
1878
|
-
outputFormat: (_e2 = response2.output_format) != null ? _e2 : void 0
|
|
1878
|
+
outputFormat: (_e2 = response2.output_format) != null ? _e2 : void 0,
|
|
1879
|
+
...distributeTokenDetails(
|
|
1880
|
+
(_f2 = response2.usage) == null ? void 0 : _f2.input_tokens_details,
|
|
1881
|
+
index,
|
|
1882
|
+
response2.data.length
|
|
1883
|
+
)
|
|
1879
1884
|
};
|
|
1880
1885
|
})
|
|
1881
1886
|
}
|
|
@@ -1918,15 +1923,20 @@ var OpenAIImageModel = class {
|
|
|
1918
1923
|
},
|
|
1919
1924
|
providerMetadata: {
|
|
1920
1925
|
openai: {
|
|
1921
|
-
images: response.data.map((item) => {
|
|
1922
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
1926
|
+
images: response.data.map((item, index) => {
|
|
1927
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1923
1928
|
return {
|
|
1924
1929
|
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1925
1930
|
created: (_a2 = response.created) != null ? _a2 : void 0,
|
|
1926
1931
|
size: (_b2 = response.size) != null ? _b2 : void 0,
|
|
1927
1932
|
quality: (_c2 = response.quality) != null ? _c2 : void 0,
|
|
1928
1933
|
background: (_d2 = response.background) != null ? _d2 : void 0,
|
|
1929
|
-
outputFormat: (_e2 = response.output_format) != null ? _e2 : void 0
|
|
1934
|
+
outputFormat: (_e2 = response.output_format) != null ? _e2 : void 0,
|
|
1935
|
+
...distributeTokenDetails(
|
|
1936
|
+
(_f2 = response.usage) == null ? void 0 : _f2.input_tokens_details,
|
|
1937
|
+
index,
|
|
1938
|
+
response.data.length
|
|
1939
|
+
)
|
|
1930
1940
|
};
|
|
1931
1941
|
})
|
|
1932
1942
|
}
|
|
@@ -1934,6 +1944,23 @@ var OpenAIImageModel = class {
|
|
|
1934
1944
|
};
|
|
1935
1945
|
}
|
|
1936
1946
|
};
|
|
1947
|
+
function distributeTokenDetails(details, index, total) {
|
|
1948
|
+
if (details == null) {
|
|
1949
|
+
return {};
|
|
1950
|
+
}
|
|
1951
|
+
const result = {};
|
|
1952
|
+
if (details.image_tokens != null) {
|
|
1953
|
+
const base = Math.floor(details.image_tokens / total);
|
|
1954
|
+
const remainder = details.image_tokens - base * (total - 1);
|
|
1955
|
+
result.imageTokens = index === total - 1 ? remainder : base;
|
|
1956
|
+
}
|
|
1957
|
+
if (details.text_tokens != null) {
|
|
1958
|
+
const base = Math.floor(details.text_tokens / total);
|
|
1959
|
+
const remainder = details.text_tokens - base * (total - 1);
|
|
1960
|
+
result.textTokens = index === total - 1 ? remainder : base;
|
|
1961
|
+
}
|
|
1962
|
+
return result;
|
|
1963
|
+
}
|
|
1937
1964
|
async function fileToBlob(file) {
|
|
1938
1965
|
if (!file) return void 0;
|
|
1939
1966
|
if (file.type === "url") {
|
|
@@ -5868,7 +5895,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5868
5895
|
};
|
|
5869
5896
|
|
|
5870
5897
|
// src/version.ts
|
|
5871
|
-
var VERSION = true ? "3.0.
|
|
5898
|
+
var VERSION = true ? "3.0.29" : "0.0.0-test";
|
|
5872
5899
|
|
|
5873
5900
|
// src/openai-provider.ts
|
|
5874
5901
|
function createOpenAI(options = {}) {
|