ai 6.0.321 → 6.0.323
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 +20 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -16
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +124 -78
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +113 -65
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-ai-sdk-core/40-middleware.mdx +7 -2
- package/docs/06-advanced/04-caching.mdx +13 -4
- package/package.json +4 -4
- package/src/generate-text/generated-file.ts +7 -4
- package/src/prompt/data-content.ts +18 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.323
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [8b1acb6]
|
|
8
|
+
- Updated dependencies [cafcf53]
|
|
9
|
+
- @ai-sdk/gateway@3.0.229
|
|
10
|
+
|
|
11
|
+
## 6.0.322
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- d900e58: fix(ai): support cross-realm Uint8Array and ArrayBuffer in DefaultGeneratedFile
|
|
16
|
+
- d900e58: fix(ai): handle cross-realm Uint8Array and ArrayBuffer in prompt data validation and conversion
|
|
17
|
+
- Updated dependencies [d900e58]
|
|
18
|
+
- Updated dependencies [d900e58]
|
|
19
|
+
- Updated dependencies [d900e58]
|
|
20
|
+
- @ai-sdk/provider-utils@4.0.64
|
|
21
|
+
- @ai-sdk/gateway@3.0.228
|
|
22
|
+
|
|
3
23
|
## 6.0.321
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -644,7 +644,7 @@ declare class DefaultGeneratedFile implements GeneratedFile {
|
|
|
644
644
|
private uint8ArrayData;
|
|
645
645
|
readonly mediaType: string;
|
|
646
646
|
constructor({ data, mediaType, }: {
|
|
647
|
-
data: string | Uint8Array;
|
|
647
|
+
data: string | Uint8Array | ArrayBuffer;
|
|
648
648
|
mediaType: string;
|
|
649
649
|
});
|
|
650
650
|
get base64(): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -644,7 +644,7 @@ declare class DefaultGeneratedFile implements GeneratedFile {
|
|
|
644
644
|
private uint8ArrayData;
|
|
645
645
|
readonly mediaType: string;
|
|
646
646
|
constructor({ data, mediaType, }: {
|
|
647
|
-
data: string | Uint8Array;
|
|
647
|
+
data: string | Uint8Array | ArrayBuffer;
|
|
648
648
|
mediaType: string;
|
|
649
649
|
});
|
|
650
650
|
get base64(): string;
|
package/dist/index.js
CHANGED
|
@@ -1335,7 +1335,7 @@ function detectMediaType({
|
|
|
1335
1335
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1336
1336
|
|
|
1337
1337
|
// src/version.ts
|
|
1338
|
-
var VERSION = true ? "6.0.
|
|
1338
|
+
var VERSION = true ? "6.0.323" : "0.0.0-test";
|
|
1339
1339
|
|
|
1340
1340
|
// src/util/download/download.ts
|
|
1341
1341
|
var download = async ({
|
|
@@ -1448,8 +1448,8 @@ function splitDataUrl(dataUrl) {
|
|
|
1448
1448
|
// src/prompt/data-content.ts
|
|
1449
1449
|
var dataContentSchema = import_v4.z.union([
|
|
1450
1450
|
import_v4.z.string(),
|
|
1451
|
-
import_v4.z.
|
|
1452
|
-
import_v4.z.
|
|
1451
|
+
import_v4.z.custom(import_provider_utils4.isUint8Array, { message: "Must be a Uint8Array" }),
|
|
1452
|
+
import_v4.z.custom(import_provider_utils4.isArrayBuffer, { message: "Must be an ArrayBuffer" }),
|
|
1453
1453
|
import_v4.z.custom(
|
|
1454
1454
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
1455
1455
|
(value) => {
|
|
@@ -1461,10 +1461,13 @@ var dataContentSchema = import_v4.z.union([
|
|
|
1461
1461
|
]);
|
|
1462
1462
|
function convertToLanguageModelV3DataContent(content) {
|
|
1463
1463
|
let originalUrl;
|
|
1464
|
-
if (
|
|
1465
|
-
return {
|
|
1464
|
+
if ((0, import_provider_utils4.isUint8Array)(content)) {
|
|
1465
|
+
return {
|
|
1466
|
+
data: convertDataContentToUint8Array(content),
|
|
1467
|
+
mediaType: void 0
|
|
1468
|
+
};
|
|
1466
1469
|
}
|
|
1467
|
-
if (
|
|
1470
|
+
if ((0, import_provider_utils4.isArrayBuffer)(content)) {
|
|
1468
1471
|
return { data: new Uint8Array(content), mediaType: void 0 };
|
|
1469
1472
|
}
|
|
1470
1473
|
if (typeof content === "string") {
|
|
@@ -1497,14 +1500,15 @@ function convertDataContentToBase64String(content) {
|
|
|
1497
1500
|
if (typeof content === "string") {
|
|
1498
1501
|
return content;
|
|
1499
1502
|
}
|
|
1500
|
-
|
|
1501
|
-
return (0, import_provider_utils4.convertUint8ArrayToBase64)(new Uint8Array(content));
|
|
1502
|
-
}
|
|
1503
|
-
return (0, import_provider_utils4.convertUint8ArrayToBase64)(content);
|
|
1503
|
+
return (0, import_provider_utils4.convertUint8ArrayToBase64)(convertDataContentToUint8Array(content));
|
|
1504
1504
|
}
|
|
1505
1505
|
function convertDataContentToUint8Array(content) {
|
|
1506
|
-
if (
|
|
1507
|
-
|
|
1506
|
+
if ((0, import_provider_utils4.isUint8Array)(content)) {
|
|
1507
|
+
if (content instanceof Uint8Array) {
|
|
1508
|
+
return content;
|
|
1509
|
+
}
|
|
1510
|
+
const { buffer, byteOffset, byteLength } = content;
|
|
1511
|
+
return new Uint8Array(buffer, byteOffset, byteLength);
|
|
1508
1512
|
}
|
|
1509
1513
|
if (typeof content === "string") {
|
|
1510
1514
|
try {
|
|
@@ -1517,7 +1521,7 @@ function convertDataContentToUint8Array(content) {
|
|
|
1517
1521
|
});
|
|
1518
1522
|
}
|
|
1519
1523
|
}
|
|
1520
|
-
if (
|
|
1524
|
+
if ((0, import_provider_utils4.isArrayBuffer)(content)) {
|
|
1521
1525
|
return new Uint8Array(content);
|
|
1522
1526
|
}
|
|
1523
1527
|
throw new InvalidDataContentError({ content });
|
|
@@ -3206,9 +3210,8 @@ var DefaultGeneratedFile = class {
|
|
|
3206
3210
|
data,
|
|
3207
3211
|
mediaType
|
|
3208
3212
|
}) {
|
|
3209
|
-
|
|
3210
|
-
this.
|
|
3211
|
-
this.uint8ArrayData = isUint8Array ? data : void 0;
|
|
3213
|
+
this.base64Data = typeof data === "string" ? data : void 0;
|
|
3214
|
+
this.uint8ArrayData = typeof data === "string" ? void 0 : convertDataContentToUint8Array(data);
|
|
3212
3215
|
this.mediaType = mediaType;
|
|
3213
3216
|
}
|
|
3214
3217
|
// lazy conversion with caching to avoid unnecessary conversion overhead:
|