@ai-sdk/google 3.0.85 → 3.0.87
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 +16 -0
- package/dist/index.js +83 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/google-generative-ai-video-model.ts +120 -36
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "3.0.
|
|
10
|
+
var VERSION = true ? "3.0.87" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -2977,6 +2977,67 @@ import {
|
|
|
2977
2977
|
zodSchema as zodSchema12
|
|
2978
2978
|
} from "@ai-sdk/provider-utils";
|
|
2979
2979
|
import { z as z14 } from "zod/v4";
|
|
2980
|
+
function getFirstFrameImage(options) {
|
|
2981
|
+
var _a, _b;
|
|
2982
|
+
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
|
|
2983
|
+
}
|
|
2984
|
+
function resolveStartImage(options) {
|
|
2985
|
+
var _a;
|
|
2986
|
+
return (_a = getFirstFrameImage(options)) != null ? _a : options.image;
|
|
2987
|
+
}
|
|
2988
|
+
function getLastFrameImage(options) {
|
|
2989
|
+
var _a, _b;
|
|
2990
|
+
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "last_frame")) == null ? void 0 : _b.image;
|
|
2991
|
+
}
|
|
2992
|
+
function getInputReferences(options) {
|
|
2993
|
+
if (options.frameImages != null && options.frameImages.length > 0) {
|
|
2994
|
+
return void 0;
|
|
2995
|
+
}
|
|
2996
|
+
return options.inputReferences != null && options.inputReferences.length > 0 ? options.inputReferences : void 0;
|
|
2997
|
+
}
|
|
2998
|
+
function convertFileToGoogleImage(file, warnings) {
|
|
2999
|
+
if (file.type === "url") {
|
|
3000
|
+
if (file.url.startsWith("gs://")) {
|
|
3001
|
+
return {
|
|
3002
|
+
gcsUri: file.url,
|
|
3003
|
+
mimeType: "image/png"
|
|
3004
|
+
};
|
|
3005
|
+
}
|
|
3006
|
+
warnings.push({
|
|
3007
|
+
type: "unsupported",
|
|
3008
|
+
feature: "URL-based image input",
|
|
3009
|
+
details: "Google Generative AI video models require base64-encoded images or GCS URIs. URL will be ignored."
|
|
3010
|
+
});
|
|
3011
|
+
return void 0;
|
|
3012
|
+
}
|
|
3013
|
+
const base64Data = typeof file.data === "string" ? file.data : convertUint8ArrayToBase64(file.data);
|
|
3014
|
+
return {
|
|
3015
|
+
inlineData: {
|
|
3016
|
+
mimeType: file.mediaType || "image/png",
|
|
3017
|
+
data: base64Data
|
|
3018
|
+
}
|
|
3019
|
+
};
|
|
3020
|
+
}
|
|
3021
|
+
function convertProviderReferenceImage(refImg) {
|
|
3022
|
+
if (refImg.bytesBase64Encoded) {
|
|
3023
|
+
return {
|
|
3024
|
+
inlineData: {
|
|
3025
|
+
mimeType: "image/png",
|
|
3026
|
+
data: refImg.bytesBase64Encoded
|
|
3027
|
+
}
|
|
3028
|
+
};
|
|
3029
|
+
}
|
|
3030
|
+
if (refImg.gcsUri) {
|
|
3031
|
+
return {
|
|
3032
|
+
gcsUri: refImg.gcsUri
|
|
3033
|
+
};
|
|
3034
|
+
}
|
|
3035
|
+
return refImg;
|
|
3036
|
+
}
|
|
3037
|
+
function convertInputReferenceImage(file, warnings) {
|
|
3038
|
+
const image = convertFileToGoogleImage(file, warnings);
|
|
3039
|
+
return image != null ? { image, referenceType: "asset" } : void 0;
|
|
3040
|
+
}
|
|
2980
3041
|
var GoogleGenerativeAIVideoModel = class {
|
|
2981
3042
|
constructor(modelId, config) {
|
|
2982
3043
|
this.modelId = modelId;
|
|
@@ -3003,39 +3064,30 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3003
3064
|
if (options.prompt != null) {
|
|
3004
3065
|
instance.prompt = options.prompt;
|
|
3005
3066
|
}
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
details: "Google Generative AI video models require base64-encoded images. URL will be ignored."
|
|
3012
|
-
});
|
|
3013
|
-
} else {
|
|
3014
|
-
const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase64(options.image.data);
|
|
3015
|
-
instance.image = {
|
|
3016
|
-
inlineData: {
|
|
3017
|
-
mimeType: options.image.mediaType || "image/png",
|
|
3018
|
-
data: base64Data
|
|
3019
|
-
}
|
|
3020
|
-
};
|
|
3067
|
+
const startImage = resolveStartImage(options);
|
|
3068
|
+
if (startImage != null) {
|
|
3069
|
+
const image = convertFileToGoogleImage(startImage, warnings);
|
|
3070
|
+
if (image != null) {
|
|
3071
|
+
instance.image = image;
|
|
3021
3072
|
}
|
|
3022
3073
|
}
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
};
|
|
3036
|
-
}
|
|
3037
|
-
return refImg;
|
|
3074
|
+
const lastFrameImage = getLastFrameImage(options);
|
|
3075
|
+
if (lastFrameImage != null) {
|
|
3076
|
+
const lastFrame = convertFileToGoogleImage(lastFrameImage, warnings);
|
|
3077
|
+
if (lastFrame != null) {
|
|
3078
|
+
instance.lastFrame = lastFrame;
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
const inputReferences = getInputReferences(options);
|
|
3082
|
+
if (inputReferences != null) {
|
|
3083
|
+
instance.referenceImages = inputReferences.flatMap((reference) => {
|
|
3084
|
+
const converted = convertInputReferenceImage(reference, warnings);
|
|
3085
|
+
return converted != null ? [converted] : [];
|
|
3038
3086
|
});
|
|
3087
|
+
} else if ((googleOptions == null ? void 0 : googleOptions.referenceImages) != null) {
|
|
3088
|
+
instance.referenceImages = googleOptions.referenceImages.map(
|
|
3089
|
+
(refImg) => convertProviderReferenceImage(refImg)
|
|
3090
|
+
);
|
|
3039
3091
|
}
|
|
3040
3092
|
const parameters = {
|
|
3041
3093
|
sampleCount: options.n
|