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/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
@@ -945,100 +945,98 @@ function convertToLanguageModelMessage(message, downloadedImages) {
|
|
945
945
|
}
|
946
946
|
return {
|
947
947
|
role: "user",
|
948
|
-
content: message.content.map(
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
if (
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
};
|
976
|
-
}
|
948
|
+
content: message.content.map((part) => {
|
949
|
+
var _a11, _b, _c;
|
950
|
+
switch (part.type) {
|
951
|
+
case "text": {
|
952
|
+
return {
|
953
|
+
type: "text",
|
954
|
+
text: part.text,
|
955
|
+
providerMetadata: part.experimental_providerMetadata
|
956
|
+
};
|
957
|
+
}
|
958
|
+
case "image": {
|
959
|
+
if (part.image instanceof URL) {
|
960
|
+
if (downloadedImages == null) {
|
961
|
+
return {
|
962
|
+
type: "image",
|
963
|
+
image: part.image,
|
964
|
+
mimeType: part.mimeType,
|
965
|
+
providerMetadata: part.experimental_providerMetadata
|
966
|
+
};
|
967
|
+
} else {
|
968
|
+
const downloadedImage = downloadedImages[part.image.toString()];
|
969
|
+
return {
|
970
|
+
type: "image",
|
971
|
+
image: downloadedImage.data,
|
972
|
+
mimeType: (_a11 = part.mimeType) != null ? _a11 : downloadedImage.mimeType,
|
973
|
+
providerMetadata: part.experimental_providerMetadata
|
974
|
+
};
|
977
975
|
}
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
}
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
}
|
976
|
+
}
|
977
|
+
if (typeof part.image === "string") {
|
978
|
+
try {
|
979
|
+
const url = new URL(part.image);
|
980
|
+
switch (url.protocol) {
|
981
|
+
case "http:":
|
982
|
+
case "https:": {
|
983
|
+
if (downloadedImages == null) {
|
984
|
+
return {
|
985
|
+
type: "image",
|
986
|
+
image: url,
|
987
|
+
mimeType: part.mimeType,
|
988
|
+
providerMetadata: part.experimental_providerMetadata
|
989
|
+
};
|
990
|
+
} else {
|
991
|
+
const downloadedImage = downloadedImages[part.image];
|
992
|
+
return {
|
993
|
+
type: "image",
|
994
|
+
image: downloadedImage.data,
|
995
|
+
mimeType: (_b = part.mimeType) != null ? _b : downloadedImage.mimeType,
|
996
|
+
providerMetadata: part.experimental_providerMetadata
|
997
|
+
};
|
1000
998
|
}
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
return {
|
1009
|
-
type: "image",
|
1010
|
-
image: convertDataContentToUint8Array(base64Content),
|
1011
|
-
mimeType,
|
1012
|
-
providerMetadata: part.experimental_providerMetadata
|
1013
|
-
};
|
1014
|
-
} catch (error) {
|
1015
|
-
throw new Error(
|
1016
|
-
`Error processing data URL: ${(0, import_provider_utils3.getErrorMessage)(
|
1017
|
-
message
|
1018
|
-
)}`
|
1019
|
-
);
|
999
|
+
}
|
1000
|
+
case "data:": {
|
1001
|
+
try {
|
1002
|
+
const [header, base64Content] = part.image.split(",");
|
1003
|
+
const mimeType = header.split(";")[0].split(":")[1];
|
1004
|
+
if (mimeType == null || base64Content == null) {
|
1005
|
+
throw new Error("Invalid data URL format");
|
1020
1006
|
}
|
1021
|
-
|
1022
|
-
|
1007
|
+
return {
|
1008
|
+
type: "image",
|
1009
|
+
image: convertDataContentToUint8Array(base64Content),
|
1010
|
+
mimeType,
|
1011
|
+
providerMetadata: part.experimental_providerMetadata
|
1012
|
+
};
|
1013
|
+
} catch (error) {
|
1023
1014
|
throw new Error(
|
1024
|
-
`
|
1015
|
+
`Error processing data URL: ${(0, import_provider_utils3.getErrorMessage)(
|
1016
|
+
message
|
1017
|
+
)}`
|
1025
1018
|
);
|
1026
1019
|
}
|
1027
1020
|
}
|
1028
|
-
|
1021
|
+
default: {
|
1022
|
+
throw new Error(
|
1023
|
+
`Unsupported URL protocol: ${url.protocol}`
|
1024
|
+
);
|
1025
|
+
}
|
1029
1026
|
}
|
1027
|
+
} catch (_ignored) {
|
1030
1028
|
}
|
1031
|
-
const imageUint8 = convertDataContentToUint8Array(part.image);
|
1032
|
-
return {
|
1033
|
-
type: "image",
|
1034
|
-
image: imageUint8,
|
1035
|
-
mimeType: (_c = part.mimeType) != null ? _c : detectImageMimeType(imageUint8),
|
1036
|
-
providerMetadata: part.experimental_providerMetadata
|
1037
|
-
};
|
1038
1029
|
}
|
1030
|
+
const imageUint8 = convertDataContentToUint8Array(part.image);
|
1031
|
+
return {
|
1032
|
+
type: "image",
|
1033
|
+
image: imageUint8,
|
1034
|
+
mimeType: (_c = part.mimeType) != null ? _c : detectImageMimeType(imageUint8),
|
1035
|
+
providerMetadata: part.experimental_providerMetadata
|
1036
|
+
};
|
1039
1037
|
}
|
1040
1038
|
}
|
1041
|
-
),
|
1039
|
+
}).filter((part) => part.type !== "text" || part.text !== ""),
|
1042
1040
|
providerMetadata: message.experimental_providerMetadata
|
1043
1041
|
};
|
1044
1042
|
}
|