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/dist/index.mjs
CHANGED
|
@@ -1225,7 +1225,7 @@ import {
|
|
|
1225
1225
|
} from "@ai-sdk/provider-utils";
|
|
1226
1226
|
|
|
1227
1227
|
// src/version.ts
|
|
1228
|
-
var VERSION = true ? "6.0.
|
|
1228
|
+
var VERSION = true ? "6.0.323" : "0.0.0-test";
|
|
1229
1229
|
|
|
1230
1230
|
// src/util/download/download.ts
|
|
1231
1231
|
var download = async ({
|
|
@@ -1317,6 +1317,8 @@ function mergeObjects(base, overrides) {
|
|
|
1317
1317
|
// src/prompt/data-content.ts
|
|
1318
1318
|
import { AISDKError as AISDKError24 } from "@ai-sdk/provider";
|
|
1319
1319
|
import {
|
|
1320
|
+
isUint8Array,
|
|
1321
|
+
isArrayBuffer,
|
|
1320
1322
|
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
1321
1323
|
convertUint8ArrayToBase64
|
|
1322
1324
|
} from "@ai-sdk/provider-utils";
|
|
@@ -1341,8 +1343,8 @@ function splitDataUrl(dataUrl) {
|
|
|
1341
1343
|
// src/prompt/data-content.ts
|
|
1342
1344
|
var dataContentSchema = z.union([
|
|
1343
1345
|
z.string(),
|
|
1344
|
-
z.
|
|
1345
|
-
z.
|
|
1346
|
+
z.custom(isUint8Array, { message: "Must be a Uint8Array" }),
|
|
1347
|
+
z.custom(isArrayBuffer, { message: "Must be an ArrayBuffer" }),
|
|
1346
1348
|
z.custom(
|
|
1347
1349
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
1348
1350
|
(value) => {
|
|
@@ -1354,10 +1356,13 @@ var dataContentSchema = z.union([
|
|
|
1354
1356
|
]);
|
|
1355
1357
|
function convertToLanguageModelV3DataContent(content) {
|
|
1356
1358
|
let originalUrl;
|
|
1357
|
-
if (content
|
|
1358
|
-
return {
|
|
1359
|
+
if (isUint8Array(content)) {
|
|
1360
|
+
return {
|
|
1361
|
+
data: convertDataContentToUint8Array(content),
|
|
1362
|
+
mediaType: void 0
|
|
1363
|
+
};
|
|
1359
1364
|
}
|
|
1360
|
-
if (content
|
|
1365
|
+
if (isArrayBuffer(content)) {
|
|
1361
1366
|
return { data: new Uint8Array(content), mediaType: void 0 };
|
|
1362
1367
|
}
|
|
1363
1368
|
if (typeof content === "string") {
|
|
@@ -1390,14 +1395,15 @@ function convertDataContentToBase64String(content) {
|
|
|
1390
1395
|
if (typeof content === "string") {
|
|
1391
1396
|
return content;
|
|
1392
1397
|
}
|
|
1393
|
-
|
|
1394
|
-
return convertUint8ArrayToBase64(new Uint8Array(content));
|
|
1395
|
-
}
|
|
1396
|
-
return convertUint8ArrayToBase64(content);
|
|
1398
|
+
return convertUint8ArrayToBase64(convertDataContentToUint8Array(content));
|
|
1397
1399
|
}
|
|
1398
1400
|
function convertDataContentToUint8Array(content) {
|
|
1399
|
-
if (content
|
|
1400
|
-
|
|
1401
|
+
if (isUint8Array(content)) {
|
|
1402
|
+
if (content instanceof Uint8Array) {
|
|
1403
|
+
return content;
|
|
1404
|
+
}
|
|
1405
|
+
const { buffer, byteOffset, byteLength } = content;
|
|
1406
|
+
return new Uint8Array(buffer, byteOffset, byteLength);
|
|
1401
1407
|
}
|
|
1402
1408
|
if (typeof content === "string") {
|
|
1403
1409
|
try {
|
|
@@ -1410,7 +1416,7 @@ function convertDataContentToUint8Array(content) {
|
|
|
1410
1416
|
});
|
|
1411
1417
|
}
|
|
1412
1418
|
}
|
|
1413
|
-
if (content
|
|
1419
|
+
if (isArrayBuffer(content)) {
|
|
1414
1420
|
return new Uint8Array(content);
|
|
1415
1421
|
}
|
|
1416
1422
|
throw new InvalidDataContentError({ content });
|
|
@@ -3109,9 +3115,8 @@ var DefaultGeneratedFile = class {
|
|
|
3109
3115
|
data,
|
|
3110
3116
|
mediaType
|
|
3111
3117
|
}) {
|
|
3112
|
-
|
|
3113
|
-
this.
|
|
3114
|
-
this.uint8ArrayData = isUint8Array ? data : void 0;
|
|
3118
|
+
this.base64Data = typeof data === "string" ? data : void 0;
|
|
3119
|
+
this.uint8ArrayData = typeof data === "string" ? void 0 : convertDataContentToUint8Array(data);
|
|
3115
3120
|
this.mediaType = mediaType;
|
|
3116
3121
|
}
|
|
3117
3122
|
// lazy conversion with caching to avoid unnecessary conversion overhead:
|