mulmocast 1.2.61 → 1.2.62

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.
@@ -444,12 +444,12 @@ export const images = async (context, args) => {
444
444
  MulmoStudioContextMethods.setSessionState(context, "image", false, false);
445
445
  if (error instanceof AuthenticationError) {
446
446
  throw new Error("Failed to generate image: 401 Incorrect API key provided with OpenAI", {
447
- cause: agentIncorrectAPIKeyError("openaiAgent", imageAction, imageFileTarget),
447
+ cause: agentIncorrectAPIKeyError("openAIAgent", imageAction, imageFileTarget),
448
448
  });
449
449
  }
450
450
  if (error instanceof RateLimitError) {
451
451
  throw new Error("You exceeded your current quota", {
452
- cause: agentAPIRateLimitError("openaiAgent", imageAction, imageFileTarget),
452
+ cause: agentAPIRateLimitError("openAIAgent", imageAction, imageFileTarget),
453
453
  });
454
454
  }
455
455
  throw error;
@@ -484,12 +484,12 @@ export const generateBeatImage = async (inputs) => {
484
484
  catch (error) {
485
485
  if (error instanceof AuthenticationError) {
486
486
  throw new Error("Failed to generate image: 401 Incorrect API key provided with OpenAI", {
487
- cause: agentIncorrectAPIKeyError("openaiAgent", imageAction, imageFileTarget),
487
+ cause: agentIncorrectAPIKeyError("openAIAgent", imageAction, imageFileTarget),
488
488
  });
489
489
  }
490
490
  if (error instanceof RateLimitError) {
491
491
  throw new Error("You exceeded your current quota", {
492
- cause: agentAPIRateLimitError("openaiAgent", imageAction, imageFileTarget),
492
+ cause: agentAPIRateLimitError("openAIAgent", imageAction, imageFileTarget),
493
493
  });
494
494
  }
495
495
  throw error;
@@ -1,7 +1,8 @@
1
1
  import { readFileSync } from "fs";
2
2
  import { GraphAILogger, sleep } from "graphai";
3
- import { apiKeyMissingError, agentGenerationError, agentInvalidResponseError, imageAction, movieFileTarget, hasCause } from "../utils/error_cause.js";
3
+ import { apiKeyMissingError, agentGenerationError, agentInvalidResponseError, imageAction, movieFileTarget, videoDurationTarget, hasCause, } from "../utils/error_cause.js";
4
4
  import { GoogleGenAI, PersonGeneration } from "@google/genai";
5
+ import { getModelDuration } from "../utils/provider2agent.js";
5
6
  export const getAspectRatio = (canvasSize) => {
6
7
  if (canvasSize.width > canvasSize.height) {
7
8
  return "16:9";
@@ -17,7 +18,7 @@ export const movieGenAIAgent = async ({ namedInputs, params, config, }) => {
17
18
  const { prompt, imagePath, movieFile } = namedInputs;
18
19
  const aspectRatio = getAspectRatio(params.canvasSize);
19
20
  const model = params.model ?? "veo-2.0-generate-001"; // "veo-3.0-generate-preview";
20
- const duration = params.duration ?? 8;
21
+ // const duration = params.duration ?? 8;
21
22
  const apiKey = config?.apiKey;
22
23
  if (!apiKey) {
23
24
  throw new Error("Google GenAI API key is required (GEMINI_API_KEY)", {
@@ -25,6 +26,13 @@ export const movieGenAIAgent = async ({ namedInputs, params, config, }) => {
25
26
  });
26
27
  }
27
28
  try {
29
+ const requestedDuration = params.duration ?? 8;
30
+ const duration = getModelDuration("google", model, requestedDuration);
31
+ if (duration === undefined) {
32
+ throw new Error(`Duration ${requestedDuration} is not supported for model ${model}.`, {
33
+ cause: agentGenerationError("movieGenAIAgent", imageAction, videoDurationTarget),
34
+ });
35
+ }
28
36
  const ai = new GoogleGenAI({ apiKey });
29
37
  const payload = {
30
38
  model,
@@ -1,8 +1,8 @@
1
1
  import { readFileSync } from "fs";
2
2
  import { GraphAILogger } from "graphai";
3
3
  import Replicate from "replicate";
4
- import { apiKeyMissingError, agentGenerationError, agentInvalidResponseError, imageAction, movieFileTarget } from "../utils/error_cause.js";
5
- import { provider2MovieAgent } from "../utils/provider2agent.js";
4
+ import { apiKeyMissingError, agentGenerationError, agentInvalidResponseError, imageAction, movieFileTarget, videoDurationTarget, unsupportedModelTarget, } from "../utils/error_cause.js";
5
+ import { provider2MovieAgent, getModelDuration } from "../utils/provider2agent.js";
6
6
  async function generateMovie(model, apiKey, prompt, imagePath, aspectRatio, duration) {
7
7
  const replicate = new Replicate({
8
8
  auth: apiKey,
@@ -30,7 +30,7 @@ async function generateMovie(model, apiKey, prompt, imagePath, aspectRatio, dura
30
30
  }
31
31
  else if (start_image === undefined) {
32
32
  throw new Error(`Model ${model} does not support image-to-video generation`, {
33
- cause: agentGenerationError("movieReplicateAgent", imageAction, movieFileTarget),
33
+ cause: agentGenerationError("movieReplicateAgent", imageAction, unsupportedModelTarget),
34
34
  });
35
35
  }
36
36
  else {
@@ -77,22 +77,13 @@ export const movieReplicateAgent = async ({ namedInputs, params, config, }) => {
77
77
  const model = params.model ?? provider2MovieAgent.replicate.defaultModel;
78
78
  if (!provider2MovieAgent.replicate.modelParams[model]) {
79
79
  throw new Error(`Model ${model} is not supported`, {
80
- cause: agentGenerationError("movieReplicateAgent", imageAction, movieFileTarget),
80
+ cause: agentGenerationError("movieReplicateAgent", imageAction, unsupportedModelTarget),
81
81
  });
82
82
  }
83
- const duration = (() => {
84
- const durations = provider2MovieAgent.replicate.modelParams[model].durations;
85
- if (params.duration) {
86
- const largerDurations = durations.filter((d) => d >= params.duration);
87
- return largerDurations.length > 0 ? largerDurations[0] : durations[durations.length - 1];
88
- }
89
- else {
90
- return durations[0];
91
- }
92
- })();
93
- if (!provider2MovieAgent.replicate.modelParams[model].durations.includes(duration)) {
83
+ const duration = getModelDuration("replicate", model, params.duration);
84
+ if (duration === undefined || !provider2MovieAgent.replicate.modelParams[model].durations.includes(duration)) {
94
85
  throw new Error(`Duration ${duration} is not supported for model ${model}. Supported durations: ${provider2MovieAgent.replicate.modelParams[model].durations.join(", ")}`, {
95
- cause: agentGenerationError("movieReplicateAgent", imageAction, movieFileTarget),
86
+ cause: agentGenerationError("movieReplicateAgent", imageAction, videoDurationTarget),
96
87
  });
97
88
  }
98
89
  const apiKey = config?.apiKey;
@@ -62,6 +62,8 @@ export declare const translateAction = "translate";
62
62
  export declare const audioFileTarget = "audioFile";
63
63
  export declare const imageFileTarget = "imageFile";
64
64
  export declare const movieFileTarget = "movieFile";
65
+ export declare const videoDurationTarget = "videoDuration";
66
+ export declare const unsupportedModelTarget = "unsupportedModel";
65
67
  export declare const multiLingualFileTarget = "multiLingualFile";
66
68
  export declare const videoSourceTarget = "videoSource";
67
69
  export declare const audioSourceTarget = "audioSource";
@@ -65,6 +65,8 @@ export const translateAction = "translate";
65
65
  export const audioFileTarget = "audioFile";
66
66
  export const imageFileTarget = "imageFile";
67
67
  export const movieFileTarget = "movieFile";
68
+ export const videoDurationTarget = "videoDuration";
69
+ export const unsupportedModelTarget = "unsupportedModel";
68
70
  export const multiLingualFileTarget = "multiLingualFile";
69
71
  export const videoSourceTarget = "videoSource";
70
72
  export const audioSourceTarget = "audioSource";
@@ -75,12 +75,21 @@ export declare const provider2MovieAgent: {
75
75
  defaultModel: string;
76
76
  models: string[];
77
77
  keyName: string;
78
+ modelParams: {
79
+ "veo-3.0-generate-preview": {
80
+ durations: number[];
81
+ };
82
+ "veo-2.0-generate-001": {
83
+ durations: number[];
84
+ };
85
+ };
78
86
  };
79
87
  mock: {
80
88
  agentName: string;
81
89
  defaultModel: string;
82
90
  models: string[];
83
91
  keyName: string;
92
+ modelParams: {};
84
93
  };
85
94
  };
86
95
  export declare const provider2SoundEffectAgent: {
@@ -156,3 +165,4 @@ export declare const defaultProviders: {
156
165
  export declare const llm: (keyof typeof provider2LLMAgent)[];
157
166
  export type LLM = keyof typeof provider2LLMAgent;
158
167
  export declare const htmlLLMProvider: string[];
168
+ export declare const getModelDuration: (provider: keyof typeof provider2MovieAgent, model: string, movieDuration?: number) => number | undefined;
@@ -161,12 +161,21 @@ export const provider2MovieAgent = {
161
161
  defaultModel: "veo-2.0-generate-001",
162
162
  models: ["veo-2.0-generate-001", "veo-3.0-generate-preview"],
163
163
  keyName: "GEMINI_API_KEY",
164
+ modelParams: {
165
+ "veo-3.0-generate-preview": {
166
+ durations: [4, 6, 8],
167
+ },
168
+ "veo-2.0-generate-001": {
169
+ durations: [5, 6, 7, 8],
170
+ },
171
+ },
164
172
  },
165
173
  mock: {
166
174
  agentName: "mediaMockAgent",
167
175
  defaultModel: "mock-model",
168
176
  models: ["mock-model"],
169
177
  keyName: "",
178
+ modelParams: {},
170
179
  },
171
180
  };
172
181
  export const provider2SoundEffectAgent = {
@@ -282,3 +291,12 @@ export const defaultProviders = {
282
291
  };
283
292
  export const llm = Object.keys(provider2LLMAgent);
284
293
  export const htmlLLMProvider = ["openai", "anthropic", "mock"];
294
+ export const getModelDuration = (provider, model, movieDuration) => {
295
+ const modelParams = provider2MovieAgent[provider]?.modelParams;
296
+ const { durations } = modelParams[model];
297
+ if (durations && movieDuration) {
298
+ const largerDurations = durations.filter((d) => d >= movieDuration);
299
+ return largerDurations.length > 0 ? largerDurations[0] : durations[durations.length - 1];
300
+ }
301
+ return durations?.[0];
302
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast",
3
- "version": "1.2.61",
3
+ "version": "1.2.62",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.node.js",