ai 6.0.215 → 6.0.217

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/dist/index.mjs CHANGED
@@ -1171,7 +1171,7 @@ import {
1171
1171
  } from "@ai-sdk/provider-utils";
1172
1172
 
1173
1173
  // src/version.ts
1174
- var VERSION = true ? "6.0.215" : "0.0.0-test";
1174
+ var VERSION = true ? "6.0.217" : "0.0.0-test";
1175
1175
 
1176
1176
  // src/util/download/download.ts
1177
1177
  var download = async ({
@@ -11857,6 +11857,8 @@ async function experimental_generateVideo({
11857
11857
  duration,
11858
11858
  fps,
11859
11859
  seed,
11860
+ frameImages,
11861
+ inputReferences,
11860
11862
  generateAudio,
11861
11863
  providerOptions,
11862
11864
  maxRetries: maxRetriesArg,
@@ -11864,7 +11866,7 @@ async function experimental_generateVideo({
11864
11866
  headers,
11865
11867
  download: downloadFn = defaultDownload
11866
11868
  }) {
11867
- var _a22;
11869
+ var _a22, _b;
11868
11870
  const model = resolveVideoModel(modelArg);
11869
11871
  const headersWithUserAgent = withUserAgentSuffix8(
11870
11872
  headers != null ? headers : {},
@@ -11875,7 +11877,32 @@ async function experimental_generateVideo({
11875
11877
  abortSignal
11876
11878
  });
11877
11879
  const { prompt, image } = normalizePrompt2(promptArg);
11878
- const maxVideosPerCallWithDefault = (_a22 = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _a22 : 1;
11880
+ const normalizedFrameImages = frameImages == null ? void 0 : frameImages.map((frame) => ({
11881
+ image: normalizeImageData(frame.image),
11882
+ frameType: frame.frameType
11883
+ }));
11884
+ const normalizedInputReferences = inputReferences == null ? void 0 : inputReferences.map(
11885
+ (reference) => normalizeImageData(reference)
11886
+ );
11887
+ const effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? void 0 : normalizedInputReferences;
11888
+ const warnings = [];
11889
+ if (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) {
11890
+ warnings.push({
11891
+ type: "other",
11892
+ message: "inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined."
11893
+ });
11894
+ }
11895
+ const firstFrameImage = (_a22 = normalizedFrameImages == null ? void 0 : normalizedFrameImages.find(
11896
+ (frame) => frame.frameType === "first_frame"
11897
+ )) == null ? void 0 : _a22.image;
11898
+ if (image != null && firstFrameImage != null) {
11899
+ warnings.push({
11900
+ type: "other",
11901
+ message: "prompt.image was ignored because a first_frame frameImage was provided; the first_frame frameImage takes precedence as the start image."
11902
+ });
11903
+ }
11904
+ const resolvedImage = firstFrameImage != null ? firstFrameImage : image;
11905
+ const maxVideosPerCallWithDefault = (_b = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _b : 1;
11879
11906
  const callCount = Math.ceil(n / maxVideosPerCallWithDefault);
11880
11907
  const callVideoCounts = Array.from({ length: callCount }, (_, index) => {
11881
11908
  const remaining = n - index * maxVideosPerCallWithDefault;
@@ -11883,7 +11910,7 @@ async function experimental_generateVideo({
11883
11910
  });
11884
11911
  const results = await Promise.all(
11885
11912
  callVideoCounts.map(
11886
- async (callVideoCount) => retry(
11913
+ async (callVideoCount) => await retry(
11887
11914
  () => model.doGenerate({
11888
11915
  prompt,
11889
11916
  n: callVideoCount,
@@ -11892,8 +11919,10 @@ async function experimental_generateVideo({
11892
11919
  duration,
11893
11920
  fps,
11894
11921
  seed,
11922
+ image: resolvedImage,
11923
+ frameImages: normalizedFrameImages,
11924
+ inputReferences: effectiveInputReferences,
11895
11925
  generateAudio,
11896
- image,
11897
11926
  providerOptions: providerOptions != null ? providerOptions : {},
11898
11927
  headers: headersWithUserAgent,
11899
11928
  abortSignal
@@ -11902,7 +11931,6 @@ async function experimental_generateVideo({
11902
11931
  )
11903
11932
  );
11904
11933
  const videos = [];
11905
- const warnings = [];
11906
11934
  const responses = [];
11907
11935
  const providerMetadata = {};
11908
11936
  for (const result of results) {
@@ -11998,56 +12026,49 @@ async function experimental_generateVideo({
11998
12026
  };
11999
12027
  }
12000
12028
  function normalizePrompt2(promptArg) {
12001
- var _a22, _b;
12002
12029
  if (typeof promptArg === "string") {
12003
12030
  return {
12004
12031
  prompt: promptArg,
12005
12032
  image: void 0
12006
12033
  };
12007
12034
  }
12008
- let image;
12009
- if (promptArg.image != null) {
12010
- const dataContent = promptArg.image;
12011
- if (typeof dataContent === "string") {
12012
- if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
12013
- image = {
12014
- type: "url",
12015
- url: dataContent
12016
- };
12017
- } else if (dataContent.startsWith("data:")) {
12018
- const { mediaType, base64Content } = splitDataUrl(dataContent);
12019
- image = {
12020
- type: "file",
12021
- mediaType: mediaType != null ? mediaType : "image/png",
12022
- data: convertBase64ToUint8Array6(base64Content != null ? base64Content : "")
12023
- };
12024
- } else {
12025
- const bytes = convertBase64ToUint8Array6(dataContent);
12026
- const mediaType = (_a22 = detectMediaType({
12027
- data: bytes,
12028
- signatures: imageMediaTypeSignatures
12029
- })) != null ? _a22 : "image/png";
12030
- image = {
12031
- type: "file",
12032
- mediaType,
12033
- data: bytes
12034
- };
12035
- }
12036
- } else if (dataContent instanceof Uint8Array) {
12037
- const mediaType = (_b = detectMediaType({
12038
- data: dataContent,
12039
- signatures: imageMediaTypeSignatures
12040
- })) != null ? _b : "image/png";
12041
- image = {
12035
+ return {
12036
+ prompt: promptArg.text,
12037
+ image: promptArg.image != null ? normalizeImageData(promptArg.image) : void 0
12038
+ };
12039
+ }
12040
+ function normalizeImageData(dataContent) {
12041
+ var _a22, _b;
12042
+ if (typeof dataContent === "string") {
12043
+ if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
12044
+ return {
12045
+ type: "url",
12046
+ url: dataContent
12047
+ };
12048
+ }
12049
+ if (dataContent.startsWith("data:")) {
12050
+ const { mediaType, base64Content } = splitDataUrl(dataContent);
12051
+ return {
12042
12052
  type: "file",
12043
- mediaType,
12044
- data: dataContent
12053
+ mediaType: mediaType != null ? mediaType : "image/png",
12054
+ data: convertBase64ToUint8Array6(base64Content != null ? base64Content : "")
12045
12055
  };
12046
12056
  }
12057
+ const bytes2 = convertBase64ToUint8Array6(dataContent);
12058
+ return {
12059
+ type: "file",
12060
+ mediaType: (_a22 = detectMediaType({
12061
+ data: bytes2,
12062
+ signatures: imageMediaTypeSignatures
12063
+ })) != null ? _a22 : "image/png",
12064
+ data: bytes2
12065
+ };
12047
12066
  }
12067
+ const bytes = convertDataContentToUint8Array(dataContent);
12048
12068
  return {
12049
- prompt: promptArg.text,
12050
- image
12069
+ type: "file",
12070
+ mediaType: (_b = detectMediaType({ data: bytes, signatures: imageMediaTypeSignatures })) != null ? _b : "image/png",
12071
+ data: bytes
12051
12072
  };
12052
12073
  }
12053
12074
  async function invokeModelMaxVideosPerCall(model) {