@ai-sdk/openai 2.0.91 → 2.0.93
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.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +40 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -26
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +39 -25
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +39 -25
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -1763,42 +1763,50 @@ var OpenAIImageModel = class {
|
|
|
1763
1763
|
},
|
|
1764
1764
|
providerMetadata: {
|
|
1765
1765
|
openai: {
|
|
1766
|
-
images: response.data.map((item, index) => {
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
)
|
|
1780
|
-
};
|
|
1781
|
-
})
|
|
1766
|
+
images: response.data.map((item, index) => ({
|
|
1767
|
+
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1768
|
+
...response.created != null ? { created: response.created } : {},
|
|
1769
|
+
...response.size != null ? { size: response.size } : {},
|
|
1770
|
+
...response.quality != null ? { quality: response.quality } : {},
|
|
1771
|
+
...response.background != null ? { background: response.background } : {},
|
|
1772
|
+
...response.output_format != null ? { outputFormat: response.output_format } : {},
|
|
1773
|
+
...distributeTokenDetails(
|
|
1774
|
+
response.usage,
|
|
1775
|
+
index,
|
|
1776
|
+
response.data.length
|
|
1777
|
+
)
|
|
1778
|
+
}))
|
|
1782
1779
|
}
|
|
1783
1780
|
}
|
|
1784
1781
|
};
|
|
1785
1782
|
}
|
|
1786
1783
|
};
|
|
1787
|
-
function distributeTokenDetails(
|
|
1788
|
-
if (
|
|
1784
|
+
function distributeTokenDetails(usage, index, total) {
|
|
1785
|
+
if (usage == null) {
|
|
1789
1786
|
return {};
|
|
1790
1787
|
}
|
|
1791
1788
|
const result = {};
|
|
1792
|
-
|
|
1789
|
+
const details = usage.input_tokens_details;
|
|
1790
|
+
if ((details == null ? void 0 : details.image_tokens) != null) {
|
|
1793
1791
|
const base = Math.floor(details.image_tokens / total);
|
|
1794
1792
|
const remainder = details.image_tokens - base * (total - 1);
|
|
1795
1793
|
result.imageTokens = index === total - 1 ? remainder : base;
|
|
1796
1794
|
}
|
|
1797
|
-
if (details.text_tokens != null) {
|
|
1795
|
+
if ((details == null ? void 0 : details.text_tokens) != null) {
|
|
1798
1796
|
const base = Math.floor(details.text_tokens / total);
|
|
1799
1797
|
const remainder = details.text_tokens - base * (total - 1);
|
|
1800
1798
|
result.textTokens = index === total - 1 ? remainder : base;
|
|
1801
1799
|
}
|
|
1800
|
+
if (usage.input_tokens != null) {
|
|
1801
|
+
const base = Math.floor(usage.input_tokens / total);
|
|
1802
|
+
const remainder = usage.input_tokens - base * (total - 1);
|
|
1803
|
+
result.inputTokens = index === total - 1 ? remainder : base;
|
|
1804
|
+
}
|
|
1805
|
+
if (usage.output_tokens != null) {
|
|
1806
|
+
const base = Math.floor(usage.output_tokens / total);
|
|
1807
|
+
const remainder = usage.output_tokens - base * (total - 1);
|
|
1808
|
+
result.outputTokens = index === total - 1 ? remainder : base;
|
|
1809
|
+
}
|
|
1802
1810
|
return result;
|
|
1803
1811
|
}
|
|
1804
1812
|
|
|
@@ -2688,7 +2696,7 @@ var openaiResponsesChunkSchema = lazyValidator11(
|
|
|
2688
2696
|
url: z14.string().nullish(),
|
|
2689
2697
|
pattern: z14.string().nullish()
|
|
2690
2698
|
})
|
|
2691
|
-
])
|
|
2699
|
+
]).nullish()
|
|
2692
2700
|
}),
|
|
2693
2701
|
z14.object({
|
|
2694
2702
|
type: z14.literal("file_search_call"),
|
|
@@ -2885,7 +2893,10 @@ var openaiResponsesResponseSchema = lazyValidator11(
|
|
|
2885
2893
|
sources: z14.array(
|
|
2886
2894
|
z14.discriminatedUnion("type", [
|
|
2887
2895
|
z14.object({ type: z14.literal("url"), url: z14.string() }),
|
|
2888
|
-
z14.object({
|
|
2896
|
+
z14.object({
|
|
2897
|
+
type: z14.literal("api"),
|
|
2898
|
+
name: z14.string()
|
|
2899
|
+
})
|
|
2889
2900
|
])
|
|
2890
2901
|
).nullish()
|
|
2891
2902
|
}),
|
|
@@ -2898,7 +2909,7 @@ var openaiResponsesResponseSchema = lazyValidator11(
|
|
|
2898
2909
|
url: z14.string().nullish(),
|
|
2899
2910
|
pattern: z14.string().nullish()
|
|
2900
2911
|
})
|
|
2901
|
-
])
|
|
2912
|
+
]).nullish()
|
|
2902
2913
|
}),
|
|
2903
2914
|
z14.object({
|
|
2904
2915
|
type: z14.literal("file_search_call"),
|
|
@@ -3277,7 +3288,7 @@ var webSearchOutputSchema = lazySchema4(
|
|
|
3277
3288
|
url: z18.string().nullish(),
|
|
3278
3289
|
pattern: z18.string().nullish()
|
|
3279
3290
|
})
|
|
3280
|
-
]),
|
|
3291
|
+
]).optional(),
|
|
3281
3292
|
sources: z18.array(
|
|
3282
3293
|
z18.discriminatedUnion("type", [
|
|
3283
3294
|
z18.object({ type: z18.literal("url"), url: z18.string() }),
|
|
@@ -3335,7 +3346,7 @@ var webSearchPreviewOutputSchema = lazySchema5(
|
|
|
3335
3346
|
url: z19.string().nullish(),
|
|
3336
3347
|
pattern: z19.string().nullish()
|
|
3337
3348
|
})
|
|
3338
|
-
])
|
|
3349
|
+
]).optional()
|
|
3339
3350
|
})
|
|
3340
3351
|
)
|
|
3341
3352
|
);
|
|
@@ -4582,6 +4593,9 @@ function isErrorChunk(chunk) {
|
|
|
4582
4593
|
}
|
|
4583
4594
|
function mapWebSearchOutput(action) {
|
|
4584
4595
|
var _a;
|
|
4596
|
+
if (action == null) {
|
|
4597
|
+
return {};
|
|
4598
|
+
}
|
|
4585
4599
|
switch (action.type) {
|
|
4586
4600
|
case "search":
|
|
4587
4601
|
return {
|