ai 6.0.221 → 6.0.222

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.222
4
+
5
+ ### Patch Changes
6
+
7
+ - e1af05f: feat (video): support video (not just image) reference inputs in `inputReferences` for reference-to-video generation
8
+ - Updated dependencies [2bfb16a]
9
+ - Updated dependencies [34b5acc]
10
+ - Updated dependencies [e1af05f]
11
+ - Updated dependencies [1ce0d1c]
12
+ - @ai-sdk/gateway@3.0.146
13
+ - @ai-sdk/provider@3.0.14
14
+ - @ai-sdk/provider-utils@4.0.38
15
+
3
16
  ## 6.0.221
4
17
 
5
18
  ### 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 image inputs for reference-to-video generation.
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 image inputs for reference-to-video generation.
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.221" : "0.0.0-test";
1285
+ var VERSION = true ? "6.0.222" : "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.map((frame) => ({
11931
- image: normalizeImageData(frame.image),
11932
- frameType: frame.frameType
11933
- }));
11934
- const normalizedInputReferences = inputReferences == null ? void 0 : inputReferences.map(
11935
- (reference) => normalizeImageData(reference)
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 normalizeImageData(dataContent) {
12091
- var _a22, _b;
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 : "image/png",
12104
- data: (0, import_provider_utils35.convertBase64ToUint8Array)(base64Content != null ? base64Content : "")
12109
+ mediaType: mediaType != null ? mediaType : detectFileMediaType(data, restrictToImages),
12110
+ data
12105
12111
  };
12106
12112
  }
12107
- const bytes2 = (0, import_provider_utils35.convertBase64ToUint8Array)(dataContent);
12113
+ const bytes = (0, import_provider_utils35.convertBase64ToUint8Array)(dataContent);
12108
12114
  return {
12109
12115
  type: "file",
12110
- mediaType: (_a22 = detectMediaType({
12111
- data: bytes2,
12112
- signatures: imageMediaTypeSignatures
12113
- })) != null ? _a22 : "image/png",
12114
- data: bytes2
12116
+ mediaType: detectFileMediaType(bytes, restrictToImages),
12117
+ data: bytes
12115
12118
  };
12116
12119
  }
12117
- const bytes = convertDataContentToUint8Array(dataContent);
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
- type: "file",
12120
- mediaType: (_b = detectMediaType({ data: bytes, signatures: imageMediaTypeSignatures })) != null ? _b : "image/png",
12121
- data: bytes
12144
+ ...normalized,
12145
+ ...reference.mediaType != null ? { mediaType: reference.mediaType } : {}
12122
12146
  };
12123
12147
  }
12124
12148
  async function invokeModelMaxVideosPerCall(model) {