mulmocast 0.0.9 → 0.0.11
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/README.md +20 -3
- package/assets/templates/akira_comic.json +2 -2
- package/assets/templates/drslump_comic.json +2 -2
- package/assets/templates/ghibli_comic.json +2 -2
- package/assets/templates/ghost_comic.json +2 -2
- package/assets/templates/onepiece_comic.json +2 -2
- package/assets/templates/portrait_movie.json +28 -0
- package/assets/templates/realistic_movie.json +28 -0
- package/assets/templates/shorts.json +18 -0
- package/lib/actions/audio.d.ts +2 -1
- package/lib/actions/audio.js +8 -3
- package/lib/actions/captions.js +2 -2
- package/lib/actions/images.d.ts +2 -1
- package/lib/actions/images.js +68 -32
- package/lib/actions/movie.js +10 -6
- package/lib/actions/translate.d.ts +2 -1
- package/lib/actions/translate.js +8 -3
- package/lib/agents/combine_audio_files_agent.js +4 -0
- package/lib/agents/image_google_agent.d.ts +4 -1
- package/lib/agents/image_google_agent.js +3 -2
- package/lib/agents/image_openai_agent.d.ts +5 -3
- package/lib/agents/image_openai_agent.js +29 -4
- package/lib/agents/movie_google_agent.d.ts +24 -0
- package/lib/agents/movie_google_agent.js +122 -0
- package/lib/cli/bin.js +12 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +5 -0
- package/lib/methods/mulmo_script.d.ts +0 -1
- package/lib/methods/mulmo_script.js +0 -5
- package/lib/methods/mulmo_studio.d.ts +1 -1
- package/lib/tools/create_mulmo_script_from_url.js +2 -2
- package/lib/tools/create_mulmo_script_interactively.js +2 -2
- package/lib/tools/story_to_script.js +2 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/schema.d.ts +155 -54
- package/lib/types/schema.js +14 -2
- package/lib/types/type.d.ts +3 -1
- package/lib/utils/file.d.ts +1 -0
- package/lib/utils/file.js +12 -8
- package/lib/utils/image_plugins/image.d.ts +1 -1
- package/lib/utils/image_plugins/movie.d.ts +1 -1
- package/lib/utils/preprocess.d.ts +9 -3
- package/lib/utils/utils.d.ts +1 -0
- package/lib/utils/utils.js +3 -0
- package/package.json +8 -8
- package/scripts/templates/movie_prompts_template.json +50 -0
- package/scripts/templates/shorts_template.json +52 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AgentFunction, AgentFunctionInfo } from "graphai";
|
|
2
|
+
export type MovieGoogleConfig = {
|
|
3
|
+
projectId?: string;
|
|
4
|
+
token?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const getAspectRatio: (canvasSize: {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}) => string;
|
|
10
|
+
export declare const movieGoogleAgent: AgentFunction<{
|
|
11
|
+
model: string;
|
|
12
|
+
canvasSize: {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
duration?: number;
|
|
17
|
+
}, {
|
|
18
|
+
buffer: Buffer;
|
|
19
|
+
}, {
|
|
20
|
+
prompt: string;
|
|
21
|
+
imagePath?: string;
|
|
22
|
+
}, MovieGoogleConfig>;
|
|
23
|
+
declare const movieGoogleAgentInfo: AgentFunctionInfo;
|
|
24
|
+
export default movieGoogleAgentInfo;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import { GraphAILogger, sleep } from "graphai";
|
|
3
|
+
async function generateMovie(projectId, model, token, prompt, imagePath, aspectRatio, duration) {
|
|
4
|
+
const GOOGLE_IMAGEN_ENDPOINT = `https://us-central1-aiplatform.googleapis.com/v1/projects/${projectId}/locations/us-central1/publishers/google/models/${model}`;
|
|
5
|
+
const payload = {
|
|
6
|
+
instances: [
|
|
7
|
+
{
|
|
8
|
+
prompt: prompt,
|
|
9
|
+
image: undefined,
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
parameters: {
|
|
13
|
+
sampleCount: 1,
|
|
14
|
+
aspectRatio: aspectRatio,
|
|
15
|
+
safetySetting: "block_only_high",
|
|
16
|
+
personGeneration: "allow_all",
|
|
17
|
+
durationSeconds: duration,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
if (imagePath) {
|
|
21
|
+
const buffer = readFileSync(imagePath);
|
|
22
|
+
const bytesBase64Encoded = buffer.toString("base64");
|
|
23
|
+
payload.instances[0].image = {
|
|
24
|
+
bytesBase64Encoded,
|
|
25
|
+
mimeType: "image/png",
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Make the API call using fetch
|
|
29
|
+
const response = await fetch(`${GOOGLE_IMAGEN_ENDPOINT}:predictLongRunning`, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Bearer ${token}`,
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(payload),
|
|
36
|
+
});
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
GraphAILogger.info("create project on google cloud console and setup the project. More details see readme.");
|
|
39
|
+
throw new Error(`Error: ${response.status} - ${response.statusText}`);
|
|
40
|
+
}
|
|
41
|
+
const initialResponse = await response.json();
|
|
42
|
+
const fetchBody = {
|
|
43
|
+
operationName: initialResponse.name,
|
|
44
|
+
};
|
|
45
|
+
const completeResponse = await (async () => {
|
|
46
|
+
while (true) {
|
|
47
|
+
GraphAILogger.info("...waiting for movie generation...");
|
|
48
|
+
await sleep(3000);
|
|
49
|
+
const response = await fetch(`${GOOGLE_IMAGEN_ENDPOINT}:fetchPredictOperation`, {
|
|
50
|
+
method: "POST",
|
|
51
|
+
headers: {
|
|
52
|
+
Authorization: `Bearer ${token}`,
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
},
|
|
55
|
+
body: JSON.stringify(fetchBody),
|
|
56
|
+
});
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
throw new Error(`Error: ${response.status} - ${response.statusText}`);
|
|
59
|
+
}
|
|
60
|
+
const responseData = await response.json();
|
|
61
|
+
if (responseData.done) {
|
|
62
|
+
if (responseData.error) {
|
|
63
|
+
GraphAILogger.info("Prompt: ", prompt);
|
|
64
|
+
throw new Error(`Error: ${responseData.error.message}`);
|
|
65
|
+
}
|
|
66
|
+
if (!responseData.response.videos) {
|
|
67
|
+
throw new Error(`No video: ${JSON.stringify(responseData, null, 2)}`);
|
|
68
|
+
}
|
|
69
|
+
return responseData.response;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
})();
|
|
73
|
+
const encodedMovie = completeResponse.videos[0].bytesBase64Encoded;
|
|
74
|
+
if (encodedMovie) {
|
|
75
|
+
return Buffer.from(encodedMovie, "base64");
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
export const getAspectRatio = (canvasSize) => {
|
|
80
|
+
if (canvasSize.width > canvasSize.height) {
|
|
81
|
+
return "16:9";
|
|
82
|
+
}
|
|
83
|
+
else if (canvasSize.width < canvasSize.height) {
|
|
84
|
+
return "9:16";
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return "1:1";
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
export const movieGoogleAgent = async ({ namedInputs, params, config }) => {
|
|
91
|
+
const { prompt, imagePath } = namedInputs;
|
|
92
|
+
const aspectRatio = getAspectRatio(params.canvasSize);
|
|
93
|
+
const model = params.model ?? "veo-2.0-generate-001"; // "veo-3.0-generate-preview";
|
|
94
|
+
const duration = params.duration ?? 8;
|
|
95
|
+
const projectId = config?.projectId;
|
|
96
|
+
const token = config?.token;
|
|
97
|
+
try {
|
|
98
|
+
const buffer = await generateMovie(projectId, model, token, prompt, imagePath, aspectRatio, duration);
|
|
99
|
+
if (buffer) {
|
|
100
|
+
return { buffer };
|
|
101
|
+
}
|
|
102
|
+
throw new Error("ERROR: geneateImage returned undefined");
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
GraphAILogger.info("Failed to generate movie:", error);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const movieGoogleAgentInfo = {
|
|
110
|
+
name: "movieGoogleAgent",
|
|
111
|
+
agent: movieGoogleAgent,
|
|
112
|
+
mock: movieGoogleAgent,
|
|
113
|
+
samples: [],
|
|
114
|
+
description: "Google Movie agent",
|
|
115
|
+
category: ["movie"],
|
|
116
|
+
author: "Receptron Team",
|
|
117
|
+
repository: "https://github.com/receptron/mulmocast-cli/",
|
|
118
|
+
// source: "https://github.com/receptron/mulmocast-cli/blob/main/src/agents/image_google_agent.ts",
|
|
119
|
+
license: "MIT",
|
|
120
|
+
environmentVariables: [],
|
|
121
|
+
};
|
|
122
|
+
export default movieGoogleAgentInfo;
|
package/lib/cli/bin.js
CHANGED
|
@@ -36,6 +36,18 @@ export const main = async () => {
|
|
|
36
36
|
.demandCommand()
|
|
37
37
|
.strict()
|
|
38
38
|
.help()
|
|
39
|
+
.showHelpOnFail(false)
|
|
40
|
+
.fail((msg, err, y) => {
|
|
41
|
+
// if yargs detect error, show help and exit
|
|
42
|
+
if (msg) {
|
|
43
|
+
y.showHelp();
|
|
44
|
+
GraphAILogger.info("\\n" + msg);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
if (err) {
|
|
48
|
+
throw err;
|
|
49
|
+
}
|
|
50
|
+
})
|
|
39
51
|
.alias("help", "h");
|
|
40
52
|
await cli.parseAsync();
|
|
41
53
|
};
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -2,7 +2,6 @@ import "dotenv/config";
|
|
|
2
2
|
import { MulmoCanvasDimension, MulmoScript, MulmoBeat, SpeechOptions, Text2SpeechProvider, Text2ImageAgentInfo, BeatMediaType } from "../types/index.js";
|
|
3
3
|
export declare const MulmoScriptMethods: {
|
|
4
4
|
getCanvasSize(script: MulmoScript): MulmoCanvasDimension;
|
|
5
|
-
getAspectRatio(script: MulmoScript): string;
|
|
6
5
|
getSpeechProvider(script: MulmoScript): Text2SpeechProvider;
|
|
7
6
|
getTextSlideStyle(script: MulmoScript, beat: MulmoBeat): string;
|
|
8
7
|
getSpeechOptions(script: MulmoScript, beat: MulmoBeat): SpeechOptions | undefined;
|
|
@@ -18,11 +18,6 @@ export const MulmoScriptMethods = {
|
|
|
18
18
|
getCanvasSize(script) {
|
|
19
19
|
return mulmoCanvasDimensionSchema.parse(script.canvasSize);
|
|
20
20
|
},
|
|
21
|
-
getAspectRatio(script) {
|
|
22
|
-
// Google's text2image specific parameter
|
|
23
|
-
const size = this.getCanvasSize(script);
|
|
24
|
-
return size.width > size.height ? "16:9" : "9:16";
|
|
25
|
-
},
|
|
26
21
|
getSpeechProvider(script) {
|
|
27
22
|
return text2SpeechProviderSchema.parse(script.speechParams?.provider);
|
|
28
23
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MulmoStudio } from "../types/index.js";
|
|
2
2
|
type SessionType = "audio" | "image" | "video" | "multiLingual" | "caption" | "pdf";
|
|
3
|
-
type BeatSessionType = "audio" | "image" | "multiLingual" | "caption";
|
|
3
|
+
type BeatSessionType = "audio" | "image" | "multiLingual" | "caption" | "movie";
|
|
4
4
|
export declare const MulmoStudioMethods: {
|
|
5
5
|
setSessionState(studio: MulmoStudio, sessionType: SessionType, value: boolean): void;
|
|
6
6
|
setBeatSessionState(studio: MulmoStudio, sessionType: BeatSessionType, index: number, value: boolean): void;
|
|
@@ -4,7 +4,7 @@ import { openAIAgent } from "@graphai/openai_agent";
|
|
|
4
4
|
import { anthropicAgent } from "@graphai/anthropic_agent";
|
|
5
5
|
import { geminiAgent } from "@graphai/gemini_agent";
|
|
6
6
|
import { groqAgent } from "@graphai/groq_agent";
|
|
7
|
-
import
|
|
7
|
+
import * as agents from "@graphai/vanilla";
|
|
8
8
|
import { fileWriteAgent } from "@graphai/vanilla_node_agents";
|
|
9
9
|
import { browserlessAgent } from "@graphai/browserless_agent";
|
|
10
10
|
import validateSchemaAgent from "../agents/validate_schema_agent.js";
|
|
@@ -14,7 +14,7 @@ import { mulmoScriptSchema, urlsSchema } from "../types/schema.js";
|
|
|
14
14
|
import { cliLoadingPlugin } from "../utils/plugins.js";
|
|
15
15
|
import { graphDataScriptFromUrlPrompt } from "../utils/prompt.js";
|
|
16
16
|
import { llmPair } from "../utils/utils.js";
|
|
17
|
-
|
|
17
|
+
const vanillaAgents = agents.default ?? agents;
|
|
18
18
|
const graphData = {
|
|
19
19
|
version: 0.5,
|
|
20
20
|
// Execute sequentially because the free version of browserless API doesn't support concurrent execution.
|
|
@@ -6,7 +6,7 @@ import { openAIAgent } from "@graphai/openai_agent";
|
|
|
6
6
|
import { anthropicAgent } from "@graphai/anthropic_agent";
|
|
7
7
|
import { geminiAgent } from "@graphai/gemini_agent";
|
|
8
8
|
import { groqAgent } from "@graphai/groq_agent";
|
|
9
|
-
import
|
|
9
|
+
import * as agents from "@graphai/vanilla";
|
|
10
10
|
import { fileWriteAgent } from "@graphai/vanilla_node_agents";
|
|
11
11
|
import { readTemplatePrompt, mkdir } from "../utils/file.js";
|
|
12
12
|
import { browserlessCacheGenerator } from "../utils/filters.js";
|
|
@@ -16,7 +16,7 @@ import validateSchemaAgent from "../agents/validate_schema_agent.js";
|
|
|
16
16
|
import { llmPair } from "../utils/utils.js";
|
|
17
17
|
import { interactiveClarificationPrompt, prefixPrompt } from "../utils/prompt.js";
|
|
18
18
|
// import { cliLoadingPlugin } from "../utils/plugins.js";
|
|
19
|
-
|
|
19
|
+
const vanillaAgents = agents.default ?? agents;
|
|
20
20
|
const agentHeader = "\x1b[34m● \x1b[0m\x1b[1mAgent\x1b[0m:\x1b[0m";
|
|
21
21
|
const graphDataForScraping = {
|
|
22
22
|
version: 0.5,
|
|
@@ -5,14 +5,14 @@ import { openAIAgent } from "@graphai/openai_agent";
|
|
|
5
5
|
import { anthropicAgent } from "@graphai/anthropic_agent";
|
|
6
6
|
import { geminiAgent } from "@graphai/gemini_agent";
|
|
7
7
|
import { groqAgent } from "@graphai/groq_agent";
|
|
8
|
-
import
|
|
8
|
+
import * as agents from "@graphai/vanilla";
|
|
9
9
|
import { graphDataScriptGeneratePrompt, sceneToBeatsPrompt, storyToScriptInfoPrompt, storyToScriptPrompt } from "../utils/prompt.js";
|
|
10
10
|
import { fileWriteAgent } from "@graphai/vanilla_node_agents";
|
|
11
11
|
import validateSchemaAgent from "../agents/validate_schema_agent.js";
|
|
12
12
|
import { llmPair } from "../utils/utils.js";
|
|
13
13
|
import { storyToScriptGenerateMode } from "../utils/const.js";
|
|
14
14
|
import { cliLoadingPlugin } from "../utils/plugins.js";
|
|
15
|
-
|
|
15
|
+
const vanillaAgents = agents.default ?? agents;
|
|
16
16
|
const createValidatedScriptGraphData = ({ systemPrompt, prompt, schema, llmAgent, llmModel, maxTokens, }) => {
|
|
17
17
|
return {
|
|
18
18
|
loop: {
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED