ai 3.3.32 → 3.3.33
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 +6 -0
- package/dist/index.js +80 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -82
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/rsc/dist/rsc-server.mjs +80 -82
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ai",
|
3
|
-
"version": "3.3.
|
3
|
+
"version": "3.3.33",
|
4
4
|
"description": "Vercel AI SDK - The AI Toolkit for TypeScript and JavaScript",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"sideEffects": false,
|
@@ -101,8 +101,8 @@
|
|
101
101
|
"tsup": "^7.2.0",
|
102
102
|
"typescript": "5.5.4",
|
103
103
|
"zod": "3.23.8",
|
104
|
-
"
|
105
|
-
"
|
104
|
+
"@vercel/ai-tsconfig": "0.0.0",
|
105
|
+
"eslint-config-vercel-ai": "0.0.0"
|
106
106
|
},
|
107
107
|
"peerDependencies": {
|
108
108
|
"openai": "^4.42.0",
|
package/rsc/dist/rsc-server.mjs
CHANGED
@@ -480,100 +480,98 @@ function convertToLanguageModelMessage(message, downloadedImages) {
|
|
480
480
|
}
|
481
481
|
return {
|
482
482
|
role: "user",
|
483
|
-
content: message.content.map(
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
if (
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
};
|
511
|
-
}
|
483
|
+
content: message.content.map((part) => {
|
484
|
+
var _a8, _b, _c;
|
485
|
+
switch (part.type) {
|
486
|
+
case "text": {
|
487
|
+
return {
|
488
|
+
type: "text",
|
489
|
+
text: part.text,
|
490
|
+
providerMetadata: part.experimental_providerMetadata
|
491
|
+
};
|
492
|
+
}
|
493
|
+
case "image": {
|
494
|
+
if (part.image instanceof URL) {
|
495
|
+
if (downloadedImages == null) {
|
496
|
+
return {
|
497
|
+
type: "image",
|
498
|
+
image: part.image,
|
499
|
+
mimeType: part.mimeType,
|
500
|
+
providerMetadata: part.experimental_providerMetadata
|
501
|
+
};
|
502
|
+
} else {
|
503
|
+
const downloadedImage = downloadedImages[part.image.toString()];
|
504
|
+
return {
|
505
|
+
type: "image",
|
506
|
+
image: downloadedImage.data,
|
507
|
+
mimeType: (_a8 = part.mimeType) != null ? _a8 : downloadedImage.mimeType,
|
508
|
+
providerMetadata: part.experimental_providerMetadata
|
509
|
+
};
|
512
510
|
}
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
}
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
}
|
511
|
+
}
|
512
|
+
if (typeof part.image === "string") {
|
513
|
+
try {
|
514
|
+
const url = new URL(part.image);
|
515
|
+
switch (url.protocol) {
|
516
|
+
case "http:":
|
517
|
+
case "https:": {
|
518
|
+
if (downloadedImages == null) {
|
519
|
+
return {
|
520
|
+
type: "image",
|
521
|
+
image: url,
|
522
|
+
mimeType: part.mimeType,
|
523
|
+
providerMetadata: part.experimental_providerMetadata
|
524
|
+
};
|
525
|
+
} else {
|
526
|
+
const downloadedImage = downloadedImages[part.image];
|
527
|
+
return {
|
528
|
+
type: "image",
|
529
|
+
image: downloadedImage.data,
|
530
|
+
mimeType: (_b = part.mimeType) != null ? _b : downloadedImage.mimeType,
|
531
|
+
providerMetadata: part.experimental_providerMetadata
|
532
|
+
};
|
535
533
|
}
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
return {
|
544
|
-
type: "image",
|
545
|
-
image: convertDataContentToUint8Array(base64Content),
|
546
|
-
mimeType,
|
547
|
-
providerMetadata: part.experimental_providerMetadata
|
548
|
-
};
|
549
|
-
} catch (error) {
|
550
|
-
throw new Error(
|
551
|
-
`Error processing data URL: ${getErrorMessage(
|
552
|
-
message
|
553
|
-
)}`
|
554
|
-
);
|
534
|
+
}
|
535
|
+
case "data:": {
|
536
|
+
try {
|
537
|
+
const [header, base64Content] = part.image.split(",");
|
538
|
+
const mimeType = header.split(";")[0].split(":")[1];
|
539
|
+
if (mimeType == null || base64Content == null) {
|
540
|
+
throw new Error("Invalid data URL format");
|
555
541
|
}
|
556
|
-
|
557
|
-
|
542
|
+
return {
|
543
|
+
type: "image",
|
544
|
+
image: convertDataContentToUint8Array(base64Content),
|
545
|
+
mimeType,
|
546
|
+
providerMetadata: part.experimental_providerMetadata
|
547
|
+
};
|
548
|
+
} catch (error) {
|
558
549
|
throw new Error(
|
559
|
-
`
|
550
|
+
`Error processing data URL: ${getErrorMessage(
|
551
|
+
message
|
552
|
+
)}`
|
560
553
|
);
|
561
554
|
}
|
562
555
|
}
|
563
|
-
|
556
|
+
default: {
|
557
|
+
throw new Error(
|
558
|
+
`Unsupported URL protocol: ${url.protocol}`
|
559
|
+
);
|
560
|
+
}
|
564
561
|
}
|
562
|
+
} catch (_ignored) {
|
565
563
|
}
|
566
|
-
const imageUint8 = convertDataContentToUint8Array(part.image);
|
567
|
-
return {
|
568
|
-
type: "image",
|
569
|
-
image: imageUint8,
|
570
|
-
mimeType: (_c = part.mimeType) != null ? _c : detectImageMimeType(imageUint8),
|
571
|
-
providerMetadata: part.experimental_providerMetadata
|
572
|
-
};
|
573
564
|
}
|
565
|
+
const imageUint8 = convertDataContentToUint8Array(part.image);
|
566
|
+
return {
|
567
|
+
type: "image",
|
568
|
+
image: imageUint8,
|
569
|
+
mimeType: (_c = part.mimeType) != null ? _c : detectImageMimeType(imageUint8),
|
570
|
+
providerMetadata: part.experimental_providerMetadata
|
571
|
+
};
|
574
572
|
}
|
575
573
|
}
|
576
|
-
),
|
574
|
+
}).filter((part) => part.type !== "text" || part.text !== ""),
|
577
575
|
providerMetadata: message.experimental_providerMetadata
|
578
576
|
};
|
579
577
|
}
|