@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/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
|
}
|
|
@@ -1098,7 +1098,7 @@ var openaiChatChunkSchema = z5.union([
|
|
|
1098
1098
|
openaiErrorDataSchema
|
|
1099
1099
|
]);
|
|
1100
1100
|
function isReasoningModel(modelId) {
|
|
1101
|
-
return modelId.startsWith("o");
|
|
1101
|
+
return modelId.startsWith("o") || modelId.startsWith("gpt-5");
|
|
1102
1102
|
}
|
|
1103
1103
|
function supportsFlexProcessing(modelId) {
|
|
1104
1104
|
return modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
@@ -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({
|
|
@@ -3238,7 +3242,7 @@ function isErrorChunk(chunk) {
|
|
|
3238
3242
|
return chunk.type === "error";
|
|
3239
3243
|
}
|
|
3240
3244
|
function getResponsesModelConfig(modelId) {
|
|
3241
|
-
if (modelId.startsWith("o") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
|
|
3245
|
+
if (modelId.startsWith("o") || modelId.startsWith("gpt-5") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
|
|
3242
3246
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
|
3243
3247
|
return {
|
|
3244
3248
|
isReasoningModel: true,
|