ai 6.0.221 → 6.0.223
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 +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +46 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -22
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +5 -0
- package/docs/03-ai-sdk-core/38-video-generation.mdx +35 -16
- package/docs/07-reference/01-ai-sdk-core/13-generate-video.mdx +3 -2
- package/package.json +4 -4
- package/src/generate-video/generate-video.ts +97 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.223
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [a452291]
|
|
8
|
+
- @ai-sdk/gateway@3.0.147
|
|
9
|
+
|
|
10
|
+
## 6.0.222
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- e1af05f: feat (video): support video (not just image) reference inputs in `inputReferences` for reference-to-video generation
|
|
15
|
+
- Updated dependencies [2bfb16a]
|
|
16
|
+
- Updated dependencies [34b5acc]
|
|
17
|
+
- Updated dependencies [e1af05f]
|
|
18
|
+
- Updated dependencies [1ce0d1c]
|
|
19
|
+
- @ai-sdk/gateway@3.0.146
|
|
20
|
+
- @ai-sdk/provider@3.0.14
|
|
21
|
+
- @ai-sdk/provider-utils@4.0.38
|
|
22
|
+
|
|
3
23
|
## 6.0.221
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -5930,9 +5930,22 @@ declare function experimental_generateVideo({ model: modelArg, prompt: promptArg
|
|
|
5930
5930
|
frameType: Experimental_VideoModelV3FrameType;
|
|
5931
5931
|
}>;
|
|
5932
5932
|
/**
|
|
5933
|
-
* Reference
|
|
5933
|
+
* Reference inputs for reference-to-video generation.
|
|
5934
|
+
*
|
|
5935
|
+
* Each entry may be a plain image/video ({@link DataContent}), or an object
|
|
5936
|
+
* form that carries an explicit `mediaType`.
|
|
5934
5937
|
*/
|
|
5935
|
-
inputReferences?: Array<DataContent
|
|
5938
|
+
inputReferences?: Array<DataContent | {
|
|
5939
|
+
/**
|
|
5940
|
+
* The reference image or video.
|
|
5941
|
+
*/
|
|
5942
|
+
data: DataContent;
|
|
5943
|
+
/**
|
|
5944
|
+
* The media type of the reference (e.g. 'image/png',
|
|
5945
|
+
* 'video/mp4').
|
|
5946
|
+
*/
|
|
5947
|
+
mediaType?: string;
|
|
5948
|
+
}>;
|
|
5936
5949
|
/**
|
|
5937
5950
|
* Whether the model should generate audio alongside the video.
|
|
5938
5951
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -5930,9 +5930,22 @@ declare function experimental_generateVideo({ model: modelArg, prompt: promptArg
|
|
|
5930
5930
|
frameType: Experimental_VideoModelV3FrameType;
|
|
5931
5931
|
}>;
|
|
5932
5932
|
/**
|
|
5933
|
-
* Reference
|
|
5933
|
+
* Reference inputs for reference-to-video generation.
|
|
5934
|
+
*
|
|
5935
|
+
* Each entry may be a plain image/video ({@link DataContent}), or an object
|
|
5936
|
+
* form that carries an explicit `mediaType`.
|
|
5934
5937
|
*/
|
|
5935
|
-
inputReferences?: Array<DataContent
|
|
5938
|
+
inputReferences?: Array<DataContent | {
|
|
5939
|
+
/**
|
|
5940
|
+
* The reference image or video.
|
|
5941
|
+
*/
|
|
5942
|
+
data: DataContent;
|
|
5943
|
+
/**
|
|
5944
|
+
* The media type of the reference (e.g. 'image/png',
|
|
5945
|
+
* 'video/mp4').
|
|
5946
|
+
*/
|
|
5947
|
+
mediaType?: string;
|
|
5948
|
+
}>;
|
|
5936
5949
|
/**
|
|
5937
5950
|
* Whether the model should generate audio alongside the video.
|
|
5938
5951
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1282,7 +1282,7 @@ function detectMediaType({
|
|
|
1282
1282
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1283
1283
|
|
|
1284
1284
|
// src/version.ts
|
|
1285
|
-
var VERSION = true ? "6.0.
|
|
1285
|
+
var VERSION = true ? "6.0.223" : "0.0.0-test";
|
|
1286
1286
|
|
|
1287
1287
|
// src/util/download/download.ts
|
|
1288
1288
|
var download = async ({
|
|
@@ -11927,13 +11927,14 @@ async function experimental_generateVideo({
|
|
|
11927
11927
|
abortSignal
|
|
11928
11928
|
});
|
|
11929
11929
|
const { prompt, image } = normalizePrompt2(promptArg);
|
|
11930
|
-
const normalizedFrameImages = frameImages == null ? void 0 : frameImages.
|
|
11931
|
-
|
|
11932
|
-
frameType: frame.frameType
|
|
11933
|
-
})
|
|
11934
|
-
const normalizedInputReferences = inputReferences == null ? void 0 : inputReferences.
|
|
11935
|
-
|
|
11936
|
-
|
|
11930
|
+
const normalizedFrameImages = frameImages == null ? void 0 : frameImages.flatMap((frame) => {
|
|
11931
|
+
const normalizedImage = normalizeImageData(frame.image);
|
|
11932
|
+
return normalizedImage != null ? [{ image: normalizedImage, frameType: frame.frameType }] : [];
|
|
11933
|
+
});
|
|
11934
|
+
const normalizedInputReferences = inputReferences == null ? void 0 : inputReferences.flatMap((reference) => {
|
|
11935
|
+
const normalized = normalizeReferenceData(reference);
|
|
11936
|
+
return normalized != null ? [normalized] : [];
|
|
11937
|
+
});
|
|
11937
11938
|
const effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? void 0 : normalizedInputReferences;
|
|
11938
11939
|
const warnings = [];
|
|
11939
11940
|
if (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) {
|
|
@@ -12087,8 +12088,12 @@ function normalizePrompt2(promptArg) {
|
|
|
12087
12088
|
image: promptArg.image != null ? normalizeImageData(promptArg.image) : void 0
|
|
12088
12089
|
};
|
|
12089
12090
|
}
|
|
12090
|
-
function
|
|
12091
|
-
var _a22
|
|
12091
|
+
function detectFileMediaType(data, restrictToImages) {
|
|
12092
|
+
var _a22;
|
|
12093
|
+
const detected = restrictToImages ? detectMediaType({ data, signatures: imageMediaTypeSignatures }) : (_a22 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a22 : detectMediaType({ data, signatures: videoMediaTypeSignatures });
|
|
12094
|
+
return detected != null ? detected : "image/png";
|
|
12095
|
+
}
|
|
12096
|
+
function normalizeImageData(dataContent, { restrictToImages = true } = {}) {
|
|
12092
12097
|
if (typeof dataContent === "string") {
|
|
12093
12098
|
if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
|
|
12094
12099
|
return {
|
|
@@ -12098,27 +12103,46 @@ function normalizeImageData(dataContent) {
|
|
|
12098
12103
|
}
|
|
12099
12104
|
if (dataContent.startsWith("data:")) {
|
|
12100
12105
|
const { mediaType, base64Content } = splitDataUrl(dataContent);
|
|
12106
|
+
const data = (0, import_provider_utils35.convertBase64ToUint8Array)(base64Content != null ? base64Content : "");
|
|
12101
12107
|
return {
|
|
12102
12108
|
type: "file",
|
|
12103
|
-
mediaType: mediaType != null ? mediaType :
|
|
12104
|
-
data
|
|
12109
|
+
mediaType: mediaType != null ? mediaType : detectFileMediaType(data, restrictToImages),
|
|
12110
|
+
data
|
|
12105
12111
|
};
|
|
12106
12112
|
}
|
|
12107
|
-
const
|
|
12113
|
+
const bytes = (0, import_provider_utils35.convertBase64ToUint8Array)(dataContent);
|
|
12108
12114
|
return {
|
|
12109
12115
|
type: "file",
|
|
12110
|
-
mediaType: (
|
|
12111
|
-
|
|
12112
|
-
signatures: imageMediaTypeSignatures
|
|
12113
|
-
})) != null ? _a22 : "image/png",
|
|
12114
|
-
data: bytes2
|
|
12116
|
+
mediaType: detectFileMediaType(bytes, restrictToImages),
|
|
12117
|
+
data: bytes
|
|
12115
12118
|
};
|
|
12116
12119
|
}
|
|
12117
|
-
|
|
12120
|
+
if (dataContent instanceof Uint8Array || dataContent instanceof ArrayBuffer) {
|
|
12121
|
+
const bytes = dataContent instanceof Uint8Array ? dataContent : new Uint8Array(dataContent);
|
|
12122
|
+
return {
|
|
12123
|
+
type: "file",
|
|
12124
|
+
mediaType: detectFileMediaType(bytes, restrictToImages),
|
|
12125
|
+
data: bytes
|
|
12126
|
+
};
|
|
12127
|
+
}
|
|
12128
|
+
return void 0;
|
|
12129
|
+
}
|
|
12130
|
+
function normalizeReferenceData(reference) {
|
|
12131
|
+
const isObjectForm = typeof reference === "object" && reference != null && !(reference instanceof Uint8Array) && !(reference instanceof ArrayBuffer) && "data" in reference;
|
|
12132
|
+
if (!isObjectForm) {
|
|
12133
|
+
return normalizeImageData(reference, {
|
|
12134
|
+
restrictToImages: false
|
|
12135
|
+
});
|
|
12136
|
+
}
|
|
12137
|
+
const normalized = normalizeImageData(reference.data, {
|
|
12138
|
+
restrictToImages: false
|
|
12139
|
+
});
|
|
12140
|
+
if (normalized == null) {
|
|
12141
|
+
return normalized;
|
|
12142
|
+
}
|
|
12118
12143
|
return {
|
|
12119
|
-
|
|
12120
|
-
mediaType
|
|
12121
|
-
data: bytes
|
|
12144
|
+
...normalized,
|
|
12145
|
+
...reference.mediaType != null ? { mediaType: reference.mediaType } : {}
|
|
12122
12146
|
};
|
|
12123
12147
|
}
|
|
12124
12148
|
async function invokeModelMaxVideosPerCall(model) {
|