@ai-sdk/openai 4.0.69 → 4.0.71
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 +19 -0
- package/dist/index.js +29 -7
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +13 -5
- package/dist/internal/index.js +28 -6
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +2 -2
- package/package.json +2 -2
- package/src/image/openai-image-model.ts +4 -3
- package/src/responses/convert-to-openai-responses-input.ts +27 -2
- package/src/responses/openai-responses-api.ts +11 -2
package/docs/03-openai.mdx
CHANGED
|
@@ -3439,6 +3439,6 @@ output, or invalid answers fail the entire call. See [Evaluation](/docs/ai-sdk-c
|
|
|
3439
3439
|
|
|
3440
3440
|
Evaluation models can also be accessed through `customProvider` aliases or
|
|
3441
3441
|
`createProviderRegistry().evaluationModel('provider:model')`. Direct string IDs
|
|
3442
|
-
|
|
3443
|
-
method
|
|
3442
|
+
use Gateway by default, or an explicitly configured default provider with an
|
|
3443
|
+
`evaluationModel` method. See
|
|
3444
3444
|
[model aliases and registries](/docs/ai-sdk-core/evaluation#model-aliases-and-registries).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.71",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ai-sdk/provider": "4.0.17",
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.45"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@ai-sdk/test-server": "2.0.1",
|
|
@@ -126,10 +126,10 @@ export class OpenAIImageModel implements ImageModelV4 {
|
|
|
126
126
|
],
|
|
127
127
|
{ type: file.mediaType },
|
|
128
128
|
)
|
|
129
|
-
: downloadBlob(file.url),
|
|
129
|
+
: downloadBlob(file.url, { abortSignal }),
|
|
130
130
|
),
|
|
131
131
|
),
|
|
132
|
-
mask: mask != null ? await fileToBlob(mask) : undefined,
|
|
132
|
+
mask: mask != null ? await fileToBlob(mask, abortSignal) : undefined,
|
|
133
133
|
n,
|
|
134
134
|
size,
|
|
135
135
|
quality: openaiOptions.quality,
|
|
@@ -312,11 +312,12 @@ type OpenAIImageEditInput = {
|
|
|
312
312
|
|
|
313
313
|
async function fileToBlob(
|
|
314
314
|
file: ImageModelV4File | undefined,
|
|
315
|
+
abortSignal: AbortSignal | undefined,
|
|
315
316
|
): Promise<Blob | undefined> {
|
|
316
317
|
if (!file) return undefined;
|
|
317
318
|
|
|
318
319
|
if (file.type === 'url') {
|
|
319
|
-
return downloadBlob(file.url);
|
|
320
|
+
return downloadBlob(file.url, { abortSignal });
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
const data =
|
|
@@ -137,6 +137,32 @@ async function convertFunctionToolResultOutput({
|
|
|
137
137
|
const imageDetail =
|
|
138
138
|
item.providerOptions?.[providerOptionsName]?.imageDetail;
|
|
139
139
|
|
|
140
|
+
if (item.data.type === 'reference') {
|
|
141
|
+
const fileId = resolveProviderReference({
|
|
142
|
+
reference: item.data.reference,
|
|
143
|
+
provider: providerOptionsName,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
if (topLevel === 'image') {
|
|
147
|
+
return {
|
|
148
|
+
type: 'input_image' as const,
|
|
149
|
+
file_id: fileId,
|
|
150
|
+
detail: imageDetail,
|
|
151
|
+
...(promptCacheBreakpoint != null && {
|
|
152
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
153
|
+
}),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
type: 'input_file' as const,
|
|
159
|
+
file_id: fileId,
|
|
160
|
+
...(promptCacheBreakpoint != null && {
|
|
161
|
+
prompt_cache_breakpoint: promptCacheBreakpoint,
|
|
162
|
+
}),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
140
166
|
if (item.data.type === 'data') {
|
|
141
167
|
const fullMediaType = resolveFullMediaType({ part: item });
|
|
142
168
|
if (topLevel === 'image') {
|
|
@@ -611,8 +637,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
611
637
|
input.push({
|
|
612
638
|
...(explicitMessageItemType && { type: 'message' as const }),
|
|
613
639
|
role: 'assistant',
|
|
614
|
-
content:
|
|
615
|
-
id,
|
|
640
|
+
content: part.text,
|
|
616
641
|
...(phase != null && { phase }),
|
|
617
642
|
});
|
|
618
643
|
|
|
@@ -266,8 +266,7 @@ export type OpenAIResponsesUserMessage = {
|
|
|
266
266
|
export type OpenAIResponsesAssistantMessage = {
|
|
267
267
|
type?: 'message';
|
|
268
268
|
role: 'assistant';
|
|
269
|
-
content:
|
|
270
|
-
id?: string;
|
|
269
|
+
content: string;
|
|
271
270
|
phase?: 'commentary' | 'final_answer' | null;
|
|
272
271
|
};
|
|
273
272
|
|
|
@@ -298,6 +297,11 @@ export type OpenAIResponsesFunctionCallOutput = {
|
|
|
298
297
|
image_url: string;
|
|
299
298
|
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
300
299
|
}
|
|
300
|
+
| {
|
|
301
|
+
type: 'input_image';
|
|
302
|
+
file_id: string;
|
|
303
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
304
|
+
}
|
|
301
305
|
| {
|
|
302
306
|
type: 'input_file';
|
|
303
307
|
filename: string;
|
|
@@ -309,6 +313,11 @@ export type OpenAIResponsesFunctionCallOutput = {
|
|
|
309
313
|
file_url: string;
|
|
310
314
|
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
311
315
|
}
|
|
316
|
+
| {
|
|
317
|
+
type: 'input_file';
|
|
318
|
+
file_id: string;
|
|
319
|
+
prompt_cache_breakpoint?: { mode: 'explicit' };
|
|
320
|
+
}
|
|
312
321
|
>;
|
|
313
322
|
caller?: OpenAIResponsesToolCaller;
|
|
314
323
|
};
|