@ai-sdk/openai 2.0.2 → 2.0.4
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 +27 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +19 -15
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +9 -5
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -116,7 +116,7 @@ function convertToOpenAIChatMessages({
|
|
|
116
116
|
}
|
|
117
117
|
return {
|
|
118
118
|
type: "file",
|
|
119
|
-
file: {
|
|
119
|
+
file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
|
|
120
120
|
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
121
121
|
file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
|
|
122
122
|
}
|
|
@@ -2072,6 +2072,7 @@ import {
|
|
|
2072
2072
|
} from "@ai-sdk/provider";
|
|
2073
2073
|
import { parseProviderOptions as parseProviderOptions6 } from "@ai-sdk/provider-utils";
|
|
2074
2074
|
import { z as z14 } from "zod/v4";
|
|
2075
|
+
import { convertToBase64 as convertToBase642 } from "@ai-sdk/provider-utils";
|
|
2075
2076
|
async function convertToOpenAIResponsesMessages({
|
|
2076
2077
|
prompt,
|
|
2077
2078
|
systemMessageMode
|
|
@@ -2121,8 +2122,9 @@ async function convertToOpenAIResponsesMessages({
|
|
|
2121
2122
|
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
2122
2123
|
return {
|
|
2123
2124
|
type: "input_image",
|
|
2124
|
-
|
|
2125
|
-
|
|
2125
|
+
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
|
|
2126
|
+
image_url: `data:${mediaType};base64,${part.data}`
|
|
2127
|
+
},
|
|
2126
2128
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
2127
2129
|
};
|
|
2128
2130
|
} else if (part.mediaType === "application/pdf") {
|
|
@@ -2133,8 +2135,10 @@ async function convertToOpenAIResponsesMessages({
|
|
|
2133
2135
|
}
|
|
2134
2136
|
return {
|
|
2135
2137
|
type: "input_file",
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
+
...typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
|
|
2139
|
+
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
2140
|
+
file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
|
|
2141
|
+
}
|
|
2138
2142
|
};
|
|
2139
2143
|
} else {
|
|
2140
2144
|
throw new UnsupportedFunctionalityError4({
|