ai 5.0.283 → 5.0.285
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 +21 -0
- 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 +112 -63
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +101 -50
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -758,7 +758,7 @@ import {
|
|
|
758
758
|
} from "@ai-sdk/provider-utils";
|
|
759
759
|
|
|
760
760
|
// src/version.ts
|
|
761
|
-
var VERSION = true ? "5.0.
|
|
761
|
+
var VERSION = true ? "5.0.285" : "0.0.0-test";
|
|
762
762
|
|
|
763
763
|
// src/util/download/download.ts
|
|
764
764
|
var download = async ({
|
|
@@ -814,6 +814,8 @@ var createDefaultDownloadFunction = (download2 = download) => (requestedDownload
|
|
|
814
814
|
// src/prompt/data-content.ts
|
|
815
815
|
import { AISDKError as AISDKError19 } from "@ai-sdk/provider";
|
|
816
816
|
import {
|
|
817
|
+
isUint8Array,
|
|
818
|
+
isArrayBuffer,
|
|
817
819
|
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
818
820
|
convertUint8ArrayToBase64
|
|
819
821
|
} from "@ai-sdk/provider-utils";
|
|
@@ -838,8 +840,8 @@ function splitDataUrl(dataUrl) {
|
|
|
838
840
|
// src/prompt/data-content.ts
|
|
839
841
|
var dataContentSchema = z.union([
|
|
840
842
|
z.string(),
|
|
841
|
-
z.
|
|
842
|
-
z.
|
|
843
|
+
z.custom(isUint8Array, { message: "Must be a Uint8Array" }),
|
|
844
|
+
z.custom(isArrayBuffer, { message: "Must be an ArrayBuffer" }),
|
|
843
845
|
z.custom(
|
|
844
846
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
845
847
|
(value) => {
|
|
@@ -850,10 +852,13 @@ var dataContentSchema = z.union([
|
|
|
850
852
|
)
|
|
851
853
|
]);
|
|
852
854
|
function convertToLanguageModelV2DataContent(content) {
|
|
853
|
-
if (content
|
|
854
|
-
return {
|
|
855
|
+
if (isUint8Array(content)) {
|
|
856
|
+
return {
|
|
857
|
+
data: convertDataContentToUint8Array(content),
|
|
858
|
+
mediaType: void 0
|
|
859
|
+
};
|
|
855
860
|
}
|
|
856
|
-
if (content
|
|
861
|
+
if (isArrayBuffer(content)) {
|
|
857
862
|
return { data: new Uint8Array(content), mediaType: void 0 };
|
|
858
863
|
}
|
|
859
864
|
if (typeof content === "string") {
|
|
@@ -880,14 +885,15 @@ function convertDataContentToBase64String(content) {
|
|
|
880
885
|
if (typeof content === "string") {
|
|
881
886
|
return content;
|
|
882
887
|
}
|
|
883
|
-
|
|
884
|
-
return convertUint8ArrayToBase64(new Uint8Array(content));
|
|
885
|
-
}
|
|
886
|
-
return convertUint8ArrayToBase64(content);
|
|
888
|
+
return convertUint8ArrayToBase64(convertDataContentToUint8Array(content));
|
|
887
889
|
}
|
|
888
890
|
function convertDataContentToUint8Array(content) {
|
|
889
|
-
if (content
|
|
890
|
-
|
|
891
|
+
if (isUint8Array(content)) {
|
|
892
|
+
if (content instanceof Uint8Array) {
|
|
893
|
+
return content;
|
|
894
|
+
}
|
|
895
|
+
const { buffer, byteOffset, byteLength } = content;
|
|
896
|
+
return new Uint8Array(buffer, byteOffset, byteLength);
|
|
891
897
|
}
|
|
892
898
|
if (typeof content === "string") {
|
|
893
899
|
try {
|
|
@@ -900,7 +906,7 @@ function convertDataContentToUint8Array(content) {
|
|
|
900
906
|
});
|
|
901
907
|
}
|
|
902
908
|
}
|
|
903
|
-
if (content
|
|
909
|
+
if (isArrayBuffer(content)) {
|
|
904
910
|
return new Uint8Array(content);
|
|
905
911
|
}
|
|
906
912
|
throw new InvalidDataContentError({ content });
|
|
@@ -1954,9 +1960,8 @@ var DefaultGeneratedFile = class {
|
|
|
1954
1960
|
data,
|
|
1955
1961
|
mediaType
|
|
1956
1962
|
}) {
|
|
1957
|
-
|
|
1958
|
-
this.
|
|
1959
|
-
this.uint8ArrayData = isUint8Array ? data : void 0;
|
|
1963
|
+
this.base64Data = typeof data === "string" ? data : void 0;
|
|
1964
|
+
this.uint8ArrayData = typeof data === "string" ? void 0 : convertDataContentToUint8Array(data);
|
|
1960
1965
|
this.mediaType = mediaType;
|
|
1961
1966
|
}
|
|
1962
1967
|
// lazy conversion with caching to avoid unnecessary conversion overhead:
|