@ai-sdk/openai 2.0.3 → 2.0.5
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -7
- 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 +21 -17
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +11 -7
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -122,7 +122,7 @@ function convertToOpenAIChatMessages({
|
|
|
122
122
|
}
|
|
123
123
|
return {
|
|
124
124
|
type: "file",
|
|
125
|
-
file: {
|
|
125
|
+
file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
|
|
126
126
|
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
127
127
|
file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
|
|
128
128
|
}
|
|
@@ -1104,7 +1104,7 @@ var openaiChatChunkSchema = z5.union([
|
|
|
1104
1104
|
openaiErrorDataSchema
|
|
1105
1105
|
]);
|
|
1106
1106
|
function isReasoningModel(modelId) {
|
|
1107
|
-
return modelId.startsWith("o");
|
|
1107
|
+
return modelId.startsWith("o") || modelId.startsWith("gpt-5");
|
|
1108
1108
|
}
|
|
1109
1109
|
function supportsFlexProcessing(modelId) {
|
|
1110
1110
|
return modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
@@ -1972,6 +1972,7 @@ import {
|
|
|
1972
1972
|
} from "@ai-sdk/provider";
|
|
1973
1973
|
import { parseProviderOptions as parseProviderOptions5 } from "@ai-sdk/provider-utils";
|
|
1974
1974
|
import { z as z13 } from "zod/v4";
|
|
1975
|
+
import { convertToBase64 as convertToBase642 } from "@ai-sdk/provider-utils";
|
|
1975
1976
|
async function convertToOpenAIResponsesMessages({
|
|
1976
1977
|
prompt,
|
|
1977
1978
|
systemMessageMode
|
|
@@ -2021,8 +2022,9 @@ async function convertToOpenAIResponsesMessages({
|
|
|
2021
2022
|
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
2022
2023
|
return {
|
|
2023
2024
|
type: "input_image",
|
|
2024
|
-
|
|
2025
|
-
|
|
2025
|
+
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
|
|
2026
|
+
image_url: `data:${mediaType};base64,${part.data}`
|
|
2027
|
+
},
|
|
2026
2028
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
2027
2029
|
};
|
|
2028
2030
|
} else if (part.mediaType === "application/pdf") {
|
|
@@ -2033,8 +2035,10 @@ async function convertToOpenAIResponsesMessages({
|
|
|
2033
2035
|
}
|
|
2034
2036
|
return {
|
|
2035
2037
|
type: "input_file",
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
+
...typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
|
|
2039
|
+
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
2040
|
+
file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
|
|
2041
|
+
}
|
|
2038
2042
|
};
|
|
2039
2043
|
} else {
|
|
2040
2044
|
throw new UnsupportedFunctionalityError4({
|
|
@@ -3138,7 +3142,7 @@ function isErrorChunk(chunk) {
|
|
|
3138
3142
|
return chunk.type === "error";
|
|
3139
3143
|
}
|
|
3140
3144
|
function getResponsesModelConfig(modelId) {
|
|
3141
|
-
if (modelId.startsWith("o") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
|
|
3145
|
+
if (modelId.startsWith("o") || modelId.startsWith("gpt-5") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
|
|
3142
3146
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
|
3143
3147
|
return {
|
|
3144
3148
|
isReasoningModel: true,
|