@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 3.0.87
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fa850e6: feat (video): add first-class `frameImages` and `inputReferences` call options for video generation
|
|
8
|
+
- Updated dependencies [fa850e6]
|
|
9
|
+
- @ai-sdk/provider@3.0.13
|
|
10
|
+
- @ai-sdk/provider-utils@4.0.34
|
|
11
|
+
|
|
12
|
+
## 3.0.86
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [b30e43a]
|
|
17
|
+
- @ai-sdk/provider-utils@4.0.33
|
|
18
|
+
|
|
3
19
|
## 3.0.85
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.87" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -2922,6 +2922,67 @@ var googleImageModelOptionsSchema = (0, import_provider_utils14.lazySchema)(
|
|
|
2922
2922
|
var import_provider4 = require("@ai-sdk/provider");
|
|
2923
2923
|
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
2924
2924
|
var import_v414 = require("zod/v4");
|
|
2925
|
+
function getFirstFrameImage(options) {
|
|
2926
|
+
var _a, _b;
|
|
2927
|
+
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "first_frame")) == null ? void 0 : _b.image;
|
|
2928
|
+
}
|
|
2929
|
+
function resolveStartImage(options) {
|
|
2930
|
+
var _a;
|
|
2931
|
+
return (_a = getFirstFrameImage(options)) != null ? _a : options.image;
|
|
2932
|
+
}
|
|
2933
|
+
function getLastFrameImage(options) {
|
|
2934
|
+
var _a, _b;
|
|
2935
|
+
return (_b = (_a = options.frameImages) == null ? void 0 : _a.find((frame) => frame.frameType === "last_frame")) == null ? void 0 : _b.image;
|
|
2936
|
+
}
|
|
2937
|
+
function getInputReferences(options) {
|
|
2938
|
+
if (options.frameImages != null && options.frameImages.length > 0) {
|
|
2939
|
+
return void 0;
|
|
2940
|
+
}
|
|
2941
|
+
return options.inputReferences != null && options.inputReferences.length > 0 ? options.inputReferences : void 0;
|
|
2942
|
+
}
|
|
2943
|
+
function convertFileToGoogleImage(file, warnings) {
|
|
2944
|
+
if (file.type === "url") {
|
|
2945
|
+
if (file.url.startsWith("gs://")) {
|
|
2946
|
+
return {
|
|
2947
|
+
gcsUri: file.url,
|
|
2948
|
+
mimeType: "image/png"
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
warnings.push({
|
|
2952
|
+
type: "unsupported",
|
|
2953
|
+
feature: "URL-based image input",
|
|
2954
|
+
details: "Google Generative AI video models require base64-encoded images or GCS URIs. URL will be ignored."
|
|
2955
|
+
});
|
|
2956
|
+
return void 0;
|
|
2957
|
+
}
|
|
2958
|
+
const base64Data = typeof file.data === "string" ? file.data : (0, import_provider_utils15.convertUint8ArrayToBase64)(file.data);
|
|
2959
|
+
return {
|
|
2960
|
+
inlineData: {
|
|
2961
|
+
mimeType: file.mediaType || "image/png",
|
|
2962
|
+
data: base64Data
|
|
2963
|
+
}
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2966
|
+
function convertProviderReferenceImage(refImg) {
|
|
2967
|
+
if (refImg.bytesBase64Encoded) {
|
|
2968
|
+
return {
|
|
2969
|
+
inlineData: {
|
|
2970
|
+
mimeType: "image/png",
|
|
2971
|
+
data: refImg.bytesBase64Encoded
|
|
2972
|
+
}
|
|
2973
|
+
};
|
|
2974
|
+
}
|
|
2975
|
+
if (refImg.gcsUri) {
|
|
2976
|
+
return {
|
|
2977
|
+
gcsUri: refImg.gcsUri
|
|
2978
|
+
};
|
|
2979
|
+
}
|
|
2980
|
+
return refImg;
|
|
2981
|
+
}
|
|
2982
|
+
function convertInputReferenceImage(file, warnings) {
|
|
2983
|
+
const image = convertFileToGoogleImage(file, warnings);
|
|
2984
|
+
return image != null ? { image, referenceType: "asset" } : void 0;
|
|
2985
|
+
}
|
|
2925
2986
|
var GoogleGenerativeAIVideoModel = class {
|
|
2926
2987
|
constructor(modelId, config) {
|
|
2927
2988
|
this.modelId = modelId;
|
|
@@ -2948,39 +3009,30 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
2948
3009
|
if (options.prompt != null) {
|
|
2949
3010
|
instance.prompt = options.prompt;
|
|
2950
3011
|
}
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
details: "Google Generative AI video models require base64-encoded images. URL will be ignored."
|
|
2957
|
-
});
|
|
2958
|
-
} else {
|
|
2959
|
-
const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils15.convertUint8ArrayToBase64)(options.image.data);
|
|
2960
|
-
instance.image = {
|
|
2961
|
-
inlineData: {
|
|
2962
|
-
mimeType: options.image.mediaType || "image/png",
|
|
2963
|
-
data: base64Data
|
|
2964
|
-
}
|
|
2965
|
-
};
|
|
3012
|
+
const startImage = resolveStartImage(options);
|
|
3013
|
+
if (startImage != null) {
|
|
3014
|
+
const image = convertFileToGoogleImage(startImage, warnings);
|
|
3015
|
+
if (image != null) {
|
|
3016
|
+
instance.image = image;
|
|
2966
3017
|
}
|
|
2967
3018
|
}
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
};
|
|
2981
|
-
}
|
|
2982
|
-
return refImg;
|
|
3019
|
+
const lastFrameImage = getLastFrameImage(options);
|
|
3020
|
+
if (lastFrameImage != null) {
|
|
3021
|
+
const lastFrame = convertFileToGoogleImage(lastFrameImage, warnings);
|
|
3022
|
+
if (lastFrame != null) {
|
|
3023
|
+
instance.lastFrame = lastFrame;
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
const inputReferences = getInputReferences(options);
|
|
3027
|
+
if (inputReferences != null) {
|
|
3028
|
+
instance.referenceImages = inputReferences.flatMap((reference) => {
|
|
3029
|
+
const converted = convertInputReferenceImage(reference, warnings);
|
|
3030
|
+
return converted != null ? [converted] : [];
|
|
2983
3031
|
});
|
|
3032
|
+
} else if ((googleOptions == null ? void 0 : googleOptions.referenceImages) != null) {
|
|
3033
|
+
instance.referenceImages = googleOptions.referenceImages.map(
|
|
3034
|
+
(refImg) => convertProviderReferenceImage(refImg)
|
|
3035
|
+
);
|
|
2984
3036
|
}
|
|
2985
3037
|
const parameters = {
|
|
2986
3038
|
sampleCount: options.n
|