@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/dist/internal/index.d.ts
CHANGED
|
@@ -491,11 +491,7 @@ type OpenAIResponsesUserMessage = {
|
|
|
491
491
|
type OpenAIResponsesAssistantMessage = {
|
|
492
492
|
type?: 'message';
|
|
493
493
|
role: 'assistant';
|
|
494
|
-
content:
|
|
495
|
-
type: 'output_text';
|
|
496
|
-
text: string;
|
|
497
|
-
}>;
|
|
498
|
-
id?: string;
|
|
494
|
+
content: string;
|
|
499
495
|
phase?: 'commentary' | 'final_answer' | null;
|
|
500
496
|
};
|
|
501
497
|
type OpenAIResponsesFunctionCall = {
|
|
@@ -523,6 +519,12 @@ type OpenAIResponsesFunctionCallOutput = {
|
|
|
523
519
|
prompt_cache_breakpoint?: {
|
|
524
520
|
mode: 'explicit';
|
|
525
521
|
};
|
|
522
|
+
} | {
|
|
523
|
+
type: 'input_image';
|
|
524
|
+
file_id: string;
|
|
525
|
+
prompt_cache_breakpoint?: {
|
|
526
|
+
mode: 'explicit';
|
|
527
|
+
};
|
|
526
528
|
} | {
|
|
527
529
|
type: 'input_file';
|
|
528
530
|
filename: string;
|
|
@@ -536,6 +538,12 @@ type OpenAIResponsesFunctionCallOutput = {
|
|
|
536
538
|
prompt_cache_breakpoint?: {
|
|
537
539
|
mode: 'explicit';
|
|
538
540
|
};
|
|
541
|
+
} | {
|
|
542
|
+
type: 'input_file';
|
|
543
|
+
file_id: string;
|
|
544
|
+
prompt_cache_breakpoint?: {
|
|
545
|
+
mode: 'explicit';
|
|
546
|
+
};
|
|
539
547
|
}>;
|
|
540
548
|
caller?: OpenAIResponsesToolCaller;
|
|
541
549
|
};
|
package/dist/internal/index.js
CHANGED
|
@@ -2392,10 +2392,10 @@ var OpenAIImageModel = class _OpenAIImageModel {
|
|
|
2392
2392
|
})
|
|
2393
2393
|
],
|
|
2394
2394
|
{ type: file.mediaType }
|
|
2395
|
-
) : downloadBlob(file.url)
|
|
2395
|
+
) : downloadBlob(file.url, { abortSignal })
|
|
2396
2396
|
)
|
|
2397
2397
|
),
|
|
2398
|
-
mask: mask != null ? await fileToBlob(mask) : void 0,
|
|
2398
|
+
mask: mask != null ? await fileToBlob(mask, abortSignal) : void 0,
|
|
2399
2399
|
n,
|
|
2400
2400
|
size,
|
|
2401
2401
|
quality: openaiOptions2.quality,
|
|
@@ -2532,10 +2532,10 @@ function distributeTokenDetails(details, index, total) {
|
|
|
2532
2532
|
}
|
|
2533
2533
|
return result;
|
|
2534
2534
|
}
|
|
2535
|
-
async function fileToBlob(file) {
|
|
2535
|
+
async function fileToBlob(file, abortSignal) {
|
|
2536
2536
|
if (!file) return void 0;
|
|
2537
2537
|
if (file.type === "url") {
|
|
2538
|
-
return downloadBlob(file.url);
|
|
2538
|
+
return downloadBlob(file.url, { abortSignal });
|
|
2539
2539
|
}
|
|
2540
2540
|
const data = file.data instanceof Uint8Array ? file.data : convertBase64ToUint8Array(file.data);
|
|
2541
2541
|
return new Blob([data], { type: file.mediaType });
|
|
@@ -3856,6 +3856,29 @@ async function convertFunctionToolResultOutput({
|
|
|
3856
3856
|
case "file": {
|
|
3857
3857
|
const topLevel = getTopLevelMediaType2(item.mediaType);
|
|
3858
3858
|
const imageDetail = (_b = (_a3 = item.providerOptions) == null ? void 0 : _a3[providerOptionsName]) == null ? void 0 : _b.imageDetail;
|
|
3859
|
+
if (item.data.type === "reference") {
|
|
3860
|
+
const fileId = resolveProviderReference2({
|
|
3861
|
+
reference: item.data.reference,
|
|
3862
|
+
provider: providerOptionsName
|
|
3863
|
+
});
|
|
3864
|
+
if (topLevel === "image") {
|
|
3865
|
+
return {
|
|
3866
|
+
type: "input_image",
|
|
3867
|
+
file_id: fileId,
|
|
3868
|
+
detail: imageDetail,
|
|
3869
|
+
...promptCacheBreakpoint2 != null && {
|
|
3870
|
+
prompt_cache_breakpoint: promptCacheBreakpoint2
|
|
3871
|
+
}
|
|
3872
|
+
};
|
|
3873
|
+
}
|
|
3874
|
+
return {
|
|
3875
|
+
type: "input_file",
|
|
3876
|
+
file_id: fileId,
|
|
3877
|
+
...promptCacheBreakpoint2 != null && {
|
|
3878
|
+
prompt_cache_breakpoint: promptCacheBreakpoint2
|
|
3879
|
+
}
|
|
3880
|
+
};
|
|
3881
|
+
}
|
|
3859
3882
|
if (item.data.type === "data") {
|
|
3860
3883
|
const fullMediaType = resolveFullMediaType2({ part: item });
|
|
3861
3884
|
if (topLevel === "image") {
|
|
@@ -4196,8 +4219,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4196
4219
|
input.push({
|
|
4197
4220
|
...explicitMessageItemType && { type: "message" },
|
|
4198
4221
|
role: "assistant",
|
|
4199
|
-
content:
|
|
4200
|
-
id,
|
|
4222
|
+
content: part.text,
|
|
4201
4223
|
...phase != null && { phase }
|
|
4202
4224
|
});
|
|
4203
4225
|
break;
|