@ai-sdk/openai 3.0.62 → 3.0.64
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 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +34 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -24
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +33 -23
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +33 -23
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +4 -0
- package/package.json +2 -2
- package/src/responses/convert-to-openai-responses-input.ts +31 -21
- package/src/responses/openai-responses-language-model.ts +2 -0
- package/src/responses/openai-responses-options.ts +9 -0
package/docs/03-openai.mdx
CHANGED
|
@@ -165,6 +165,10 @@ The following provider options are available:
|
|
|
165
165
|
|
|
166
166
|
Whether to store the generation. Defaults to `true`.
|
|
167
167
|
|
|
168
|
+
- **passThroughUnsupportedFiles** _boolean_
|
|
169
|
+
|
|
170
|
+
Whether to pass through non-image file types as generic input files. Defaults to `false`, which restricts inline file inputs to images and PDFs. Enable this when the target OpenAI Responses model supports additional file media types.
|
|
171
|
+
|
|
168
172
|
- **maxToolCalls** _integer_
|
|
169
173
|
The maximum number of total calls to built-in tools that can be processed in a response.
|
|
170
174
|
This maximum number applies across all built-in tool calls, not per individual tool.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.64",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@ai-sdk/provider": "3.0.10",
|
|
40
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
40
|
+
"@ai-sdk/provider-utils": "4.0.27"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "20.17.24",
|
|
@@ -52,6 +52,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
52
52
|
systemMessageMode,
|
|
53
53
|
providerOptionsName,
|
|
54
54
|
fileIdPrefixes,
|
|
55
|
+
passThroughUnsupportedFiles = false,
|
|
55
56
|
store,
|
|
56
57
|
hasConversation = false,
|
|
57
58
|
hasLocalShellTool = false,
|
|
@@ -64,6 +65,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
64
65
|
systemMessageMode: 'system' | 'developer' | 'remove';
|
|
65
66
|
providerOptionsName: string;
|
|
66
67
|
fileIdPrefixes?: readonly string[];
|
|
68
|
+
passThroughUnsupportedFiles?: boolean;
|
|
67
69
|
store: boolean;
|
|
68
70
|
hasConversation?: boolean; // when true, skip assistant messages that already have item IDs
|
|
69
71
|
hasLocalShellTool?: boolean;
|
|
@@ -116,12 +118,10 @@ export async function convertToOpenAIResponsesInput({
|
|
|
116
118
|
return { type: 'input_text', text: part.text };
|
|
117
119
|
}
|
|
118
120
|
case 'file': {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
part.mediaType === 'image/*'
|
|
122
|
-
? 'image/jpeg'
|
|
123
|
-
: part.mediaType;
|
|
121
|
+
const mediaType =
|
|
122
|
+
part.mediaType === 'image/*' ? 'image/jpeg' : part.mediaType;
|
|
124
123
|
|
|
124
|
+
if (mediaType.startsWith('image/')) {
|
|
125
125
|
return {
|
|
126
126
|
type: 'input_image',
|
|
127
127
|
...(part.data instanceof URL
|
|
@@ -135,28 +135,38 @@ export async function convertToOpenAIResponsesInput({
|
|
|
135
135
|
detail:
|
|
136
136
|
part.providerOptions?.[providerOptionsName]?.imageDetail,
|
|
137
137
|
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
type: 'input_file',
|
|
142
|
-
file_url: part.data.toString(),
|
|
143
|
-
};
|
|
144
|
-
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (part.data instanceof URL) {
|
|
145
141
|
return {
|
|
146
142
|
type: 'input_file',
|
|
147
|
-
|
|
148
|
-
isFileId(part.data, fileIdPrefixes)
|
|
149
|
-
? { file_id: part.data }
|
|
150
|
-
: {
|
|
151
|
-
filename: part.filename ?? `part-${index}.pdf`,
|
|
152
|
-
file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`,
|
|
153
|
-
}),
|
|
143
|
+
file_url: part.data.toString(),
|
|
154
144
|
};
|
|
155
|
-
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (
|
|
148
|
+
mediaType !== 'application/pdf' &&
|
|
149
|
+
!passThroughUnsupportedFiles
|
|
150
|
+
) {
|
|
156
151
|
throw new UnsupportedFunctionalityError({
|
|
157
|
-
functionality: `file part media type ${
|
|
152
|
+
functionality: `file part media type ${mediaType}`,
|
|
158
153
|
});
|
|
159
154
|
}
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
type: 'input_file',
|
|
158
|
+
...(typeof part.data === 'string' &&
|
|
159
|
+
isFileId(part.data, fileIdPrefixes)
|
|
160
|
+
? { file_id: part.data }
|
|
161
|
+
: {
|
|
162
|
+
filename:
|
|
163
|
+
part.filename ??
|
|
164
|
+
(mediaType === 'application/pdf'
|
|
165
|
+
? `part-${index}.pdf`
|
|
166
|
+
: `part-${index}`),
|
|
167
|
+
file_data: `data:${mediaType};base64,${convertToBase64(part.data)}`,
|
|
168
|
+
}),
|
|
169
|
+
};
|
|
160
170
|
}
|
|
161
171
|
}
|
|
162
172
|
}),
|
|
@@ -229,6 +229,8 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|
|
229
229
|
: modelCapabilities.systemMessageMode),
|
|
230
230
|
providerOptionsName,
|
|
231
231
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
232
|
+
passThroughUnsupportedFiles:
|
|
233
|
+
openaiOptions?.passThroughUnsupportedFiles ?? false,
|
|
232
234
|
store: openaiOptions?.store ?? true,
|
|
233
235
|
hasConversation: openaiOptions?.conversation != null,
|
|
234
236
|
hasLocalShellTool: hasOpenAITool('openai.local_shell'),
|
|
@@ -269,6 +269,15 @@ export const openaiLanguageModelResponsesOptionsSchema = lazySchema(() =>
|
|
|
269
269
|
*/
|
|
270
270
|
store: z.boolean().nullish(),
|
|
271
271
|
|
|
272
|
+
/**
|
|
273
|
+
* Whether to pass through non-image file types as generic input files.
|
|
274
|
+
*
|
|
275
|
+
* By default, inline file inputs are restricted to images and PDFs.
|
|
276
|
+
* Enable this when the target OpenAI Responses model supports additional
|
|
277
|
+
* file media types, such as text/csv.
|
|
278
|
+
*/
|
|
279
|
+
passThroughUnsupportedFiles: z.boolean().optional(),
|
|
280
|
+
|
|
272
281
|
/**
|
|
273
282
|
* Whether to use strict JSON schema validation.
|
|
274
283
|
* Defaults to `true`.
|