mulmocast 0.1.1 → 0.1.3
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/assets/templates/characters.json +16 -0
- package/assets/templates/html.json +6 -0
- package/lib/actions/audio.js +8 -6
- package/lib/actions/image_agents.d.ts +121 -0
- package/lib/actions/image_agents.js +56 -0
- package/lib/actions/image_references.d.ts +9 -0
- package/lib/actions/image_references.js +79 -0
- package/lib/actions/images.d.ts +9 -105
- package/lib/actions/images.js +83 -182
- package/lib/actions/index.d.ts +2 -0
- package/lib/actions/index.js +2 -0
- package/lib/actions/movie.js +3 -1
- package/lib/actions/pdf.js +5 -2
- package/lib/agents/image_google_agent.d.ts +2 -15
- package/lib/agents/image_google_agent.js +3 -3
- package/lib/agents/image_openai_agent.d.ts +2 -17
- package/lib/agents/image_openai_agent.js +7 -7
- package/lib/agents/movie_google_agent.d.ts +2 -17
- package/lib/agents/movie_google_agent.js +7 -7
- package/lib/agents/movie_replicate_agent.d.ts +2 -16
- package/lib/agents/movie_replicate_agent.js +3 -3
- package/lib/agents/tts_google_agent.d.ts +9 -1
- package/lib/agents/tts_google_agent.js +2 -2
- package/lib/agents/tts_nijivoice_agent.js +1 -1
- package/lib/agents/tts_openai_agent.d.ts +13 -1
- package/lib/agents/tts_openai_agent.js +2 -2
- package/lib/cli/helpers.js +7 -7
- package/lib/methods/index.d.ts +1 -0
- package/lib/methods/index.js +1 -0
- package/lib/methods/mulmo_beat.d.ts +6 -0
- package/lib/methods/mulmo_beat.js +21 -0
- package/lib/methods/mulmo_presentation_style.d.ts +2 -0
- package/lib/methods/mulmo_presentation_style.js +24 -0
- package/lib/methods/mulmo_studio_context.js +3 -0
- package/lib/tools/story_to_script.js +2 -2
- package/lib/types/agent.d.ts +55 -0
- package/lib/types/agent.js +3 -0
- package/lib/types/schema.d.ts +322 -74
- package/lib/types/schema.js +10 -2
- package/lib/types/type.d.ts +3 -2
- package/lib/utils/context.d.ts +13 -2
- package/lib/utils/context.js +2 -0
- package/lib/utils/ffmpeg_utils.d.ts +1 -1
- package/lib/utils/ffmpeg_utils.js +1 -1
- package/lib/utils/file.js +4 -4
- package/lib/utils/filters.js +11 -7
- package/lib/utils/markdown.js +1 -1
- package/lib/utils/preprocess.d.ts +8 -2
- package/lib/utils/string.js +5 -5
- package/lib/utils/utils.d.ts +8 -1
- package/lib/utils/utils.js +51 -36
- package/package.json +10 -9
- package/scripts/templates/html.json +42 -0
- package/scripts/templates/image_refs.json +35 -0
|
@@ -6,8 +6,8 @@ async function generateMovie(model, apiKey, prompt, imagePath, aspectRatio, dura
|
|
|
6
6
|
auth: apiKey,
|
|
7
7
|
});
|
|
8
8
|
const input = {
|
|
9
|
-
prompt
|
|
10
|
-
duration
|
|
9
|
+
prompt,
|
|
10
|
+
duration,
|
|
11
11
|
image: undefined,
|
|
12
12
|
start_image: undefined,
|
|
13
13
|
aspect_ratio: aspectRatio, // only for bytedance/seedance-1-lite
|
|
@@ -58,7 +58,7 @@ export const getAspectRatio = (canvasSize) => {
|
|
|
58
58
|
return "1:1";
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
|
-
export const movieReplicateAgent = async ({ namedInputs, params, config }) => {
|
|
61
|
+
export const movieReplicateAgent = async ({ namedInputs, params, config, }) => {
|
|
62
62
|
const { prompt, imagePath } = namedInputs;
|
|
63
63
|
const aspectRatio = getAspectRatio(params.canvasSize);
|
|
64
64
|
const duration = params.duration ?? 5;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { AgentFunction, AgentFunctionInfo } from "graphai";
|
|
2
|
-
export declare const ttsGoogleAgent: AgentFunction
|
|
2
|
+
export declare const ttsGoogleAgent: AgentFunction<{
|
|
3
|
+
voice: string;
|
|
4
|
+
speed: number;
|
|
5
|
+
suppressError: boolean;
|
|
6
|
+
}, {
|
|
7
|
+
buffer?: Buffer | null;
|
|
8
|
+
}, {
|
|
9
|
+
text: string;
|
|
10
|
+
}>;
|
|
3
11
|
declare const ttsGoogleAgentInfo: AgentFunctionInfo;
|
|
4
12
|
export default ttsGoogleAgentInfo;
|
|
@@ -14,7 +14,7 @@ export const ttsGoogleAgent = async ({ namedInputs, params }) => {
|
|
|
14
14
|
}
|
|
15
15
|
// Construct the request
|
|
16
16
|
const request = {
|
|
17
|
-
input: { text
|
|
17
|
+
input: { text },
|
|
18
18
|
voice: voiceParams,
|
|
19
19
|
audioConfig: {
|
|
20
20
|
audioEncoding: "MP3",
|
|
@@ -46,6 +46,6 @@ const ttsGoogleAgentInfo = {
|
|
|
46
46
|
author: "Receptron Team",
|
|
47
47
|
repository: "https://github.com/receptron/mulmocast-cli/",
|
|
48
48
|
license: "MIT",
|
|
49
|
-
environmentVariables: ["
|
|
49
|
+
environmentVariables: ["GOOGLE_GENAI_API_KEY"],
|
|
50
50
|
};
|
|
51
51
|
export default ttsGoogleAgentInfo;
|
|
@@ -21,7 +21,7 @@ export const ttsNijivoiceAgent = async ({ params, namedInputs, config }) => {
|
|
|
21
21
|
},
|
|
22
22
|
body: JSON.stringify({
|
|
23
23
|
format: "mp3",
|
|
24
|
-
speed: speed
|
|
24
|
+
speed: String(speed ?? speed_global ?? "1.0"),
|
|
25
25
|
script: text,
|
|
26
26
|
}),
|
|
27
27
|
};
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { AgentFunction, AgentFunctionInfo } from "graphai";
|
|
2
|
-
export declare const ttsOpenaiAgent: AgentFunction
|
|
2
|
+
export declare const ttsOpenaiAgent: AgentFunction<{
|
|
3
|
+
model: string;
|
|
4
|
+
voice: string;
|
|
5
|
+
instructions: string;
|
|
6
|
+
suppressError: boolean;
|
|
7
|
+
}, {
|
|
8
|
+
buffer?: Buffer;
|
|
9
|
+
}, {
|
|
10
|
+
text: string;
|
|
11
|
+
}, {
|
|
12
|
+
baseURL?: string;
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
}>;
|
|
3
15
|
declare const ttsOpenaiAgentInfo: AgentFunctionInfo;
|
|
4
16
|
export default ttsOpenaiAgentInfo;
|
|
@@ -3,8 +3,8 @@ import OpenAI from "openai";
|
|
|
3
3
|
export const ttsOpenaiAgent = async ({ namedInputs, params, config }) => {
|
|
4
4
|
const { text } = namedInputs;
|
|
5
5
|
const { model, voice, suppressError, instructions } = params;
|
|
6
|
-
const { apiKey } = config ?? {};
|
|
7
|
-
const openai = new OpenAI({ apiKey });
|
|
6
|
+
const { apiKey, baseURL } = config ?? {};
|
|
7
|
+
const openai = new OpenAI({ apiKey, baseURL });
|
|
8
8
|
try {
|
|
9
9
|
const tts_options = {
|
|
10
10
|
model: model ?? "gpt-4o-mini-tts", // "tts-1",
|
package/lib/cli/helpers.js
CHANGED
|
@@ -34,16 +34,16 @@ export const getFileObject = (args) => {
|
|
|
34
34
|
const { fileOrUrl, fileName } = (() => {
|
|
35
35
|
if (file === "__clipboard") {
|
|
36
36
|
// We generate a new unique script file from clipboard text in the output directory
|
|
37
|
-
const
|
|
37
|
+
const generatedFileName = generateTimestampedFileName("script");
|
|
38
38
|
const clipboardText = clipboardy.readSync();
|
|
39
|
-
const
|
|
39
|
+
const resolvedFilePath = resolveDirPath(outDirPath, `${generatedFileName}.json`);
|
|
40
40
|
mkdir(outDirPath);
|
|
41
|
-
fs.writeFileSync(
|
|
42
|
-
return { fileOrUrl, fileName };
|
|
41
|
+
fs.writeFileSync(resolvedFilePath, clipboardText, "utf8");
|
|
42
|
+
return { fileOrUrl: resolvedFilePath, fileName: generatedFileName };
|
|
43
43
|
}
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
return { fileOrUrl, fileName };
|
|
44
|
+
const resolvedFileOrUrl = file ?? "";
|
|
45
|
+
const parsedFileName = path.parse(resolvedFileOrUrl).name;
|
|
46
|
+
return { fileOrUrl: resolvedFileOrUrl, fileName: parsedFileName };
|
|
47
47
|
})();
|
|
48
48
|
const isHttpPath = isHttp(fileOrUrl);
|
|
49
49
|
const mulmoFilePath = isHttpPath ? "" : getFullPath(baseDirPath, fileOrUrl);
|
package/lib/methods/index.d.ts
CHANGED
package/lib/methods/index.js
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MulmoBeat } from "../types/index.js";
|
|
2
|
+
export declare const MulmoBeatMethods: {
|
|
3
|
+
getHtmlPrompt(beat: MulmoBeat): string | undefined;
|
|
4
|
+
getPlugin(beat: MulmoBeat): typeof import("../utils/image_plugins/text_slide.js") | typeof import("../utils/image_plugins/markdown.js") | typeof import("../utils/image_plugins/chart.js") | typeof import("../utils/image_plugins/mermaid.js") | typeof import("../utils/image_plugins/html_tailwind.js") | typeof import("../utils/image_plugins/image.js") | typeof import("../utils/image_plugins/movie.js") | typeof import("../utils/image_plugins/beat.js") | typeof import("../utils/image_plugins/voice_over.js");
|
|
5
|
+
getImageReferenceForImageGenerator(beat: MulmoBeat, imageRefs: Record<string, string>): string[];
|
|
6
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { findImagePlugin } from "../utils/image_plugins/index.js";
|
|
2
|
+
export const MulmoBeatMethods = {
|
|
3
|
+
getHtmlPrompt(beat) {
|
|
4
|
+
if (beat?.htmlPrompt?.data) {
|
|
5
|
+
return beat.htmlPrompt.prompt + "\n\n data\n" + JSON.stringify(beat.htmlPrompt.data, null, 2);
|
|
6
|
+
}
|
|
7
|
+
return beat?.htmlPrompt?.prompt;
|
|
8
|
+
},
|
|
9
|
+
getPlugin(beat) {
|
|
10
|
+
const plugin = findImagePlugin(beat?.image?.type);
|
|
11
|
+
if (!plugin) {
|
|
12
|
+
throw new Error(`invalid beat image type: ${beat.image}`);
|
|
13
|
+
}
|
|
14
|
+
return plugin;
|
|
15
|
+
},
|
|
16
|
+
getImageReferenceForImageGenerator(beat, imageRefs) {
|
|
17
|
+
const imageNames = beat.imageNames ?? Object.keys(imageRefs); // use all images if imageNames is not specified
|
|
18
|
+
const sources = imageNames.map((name) => imageRefs[name]);
|
|
19
|
+
return sources.filter((source) => source !== undefined);
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -11,6 +11,8 @@ export declare const MulmoPresentationStyleMethods: {
|
|
|
11
11
|
getVoiceId(presentationStyle: MulmoPresentationStyle, beat: MulmoBeat): string;
|
|
12
12
|
getText2ImageProvider(provider: Text2ImageProvider | undefined): Text2ImageProvider;
|
|
13
13
|
getImageAgentInfo(presentationStyle: MulmoPresentationStyle, beat?: MulmoBeat): Text2ImageAgentInfo;
|
|
14
|
+
getMovieAgent(presentationStyle: MulmoPresentationStyle): string;
|
|
15
|
+
getConcurrency(presentationStyle: MulmoPresentationStyle): 4 | 16;
|
|
14
16
|
getHtmlImageAgentInfo(presentationStyle: MulmoPresentationStyle): Text2HtmlAgentInfo;
|
|
15
17
|
getImageType(_: MulmoPresentationStyle, beat: MulmoBeat): BeatMediaType;
|
|
16
18
|
};
|
|
@@ -74,6 +74,30 @@ export const MulmoPresentationStyleMethods = {
|
|
|
74
74
|
imageParams: { ...defaultImageParams, ...imageParams },
|
|
75
75
|
};
|
|
76
76
|
},
|
|
77
|
+
// Determine movie agent based on provider
|
|
78
|
+
getMovieAgent(presentationStyle) {
|
|
79
|
+
const movieProvider = presentationStyle.movieParams?.provider ?? "google";
|
|
80
|
+
switch (movieProvider) {
|
|
81
|
+
case "replicate":
|
|
82
|
+
return "movieReplicateAgent";
|
|
83
|
+
case "google":
|
|
84
|
+
default:
|
|
85
|
+
return "movieGoogleAgent";
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
getConcurrency(presentationStyle) {
|
|
89
|
+
if (presentationStyle.movieParams?.provider === "replicate") {
|
|
90
|
+
return 4;
|
|
91
|
+
}
|
|
92
|
+
const imageAgentInfo = MulmoPresentationStyleMethods.getImageAgentInfo(presentationStyle);
|
|
93
|
+
if (imageAgentInfo.imageParams.provider === "openai") {
|
|
94
|
+
// NOTE: Here are the rate limits of OpenAI's text2image API (1token = 32x32 patch).
|
|
95
|
+
// dall-e-3: 7,500 RPM、15 images per minute (4 images for max resolution)
|
|
96
|
+
// gpt-image-1:3,000,000 TPM、150 images per minute
|
|
97
|
+
return imageAgentInfo.imageParams.model === defaultOpenAIImageModel ? 4 : 16;
|
|
98
|
+
}
|
|
99
|
+
return 4;
|
|
100
|
+
},
|
|
77
101
|
getHtmlImageAgentInfo(presentationStyle) {
|
|
78
102
|
const provider = text2HtmlImageProviderSchema.parse(presentationStyle.htmlImageParams?.provider);
|
|
79
103
|
const defaultConfig = llmConfig[provider];
|
|
@@ -52,6 +52,9 @@ export const MulmoStudioContextMethods = {
|
|
|
52
52
|
},
|
|
53
53
|
setBeatSessionState(context, sessionType, index, value) {
|
|
54
54
|
if (value) {
|
|
55
|
+
if (!context.sessionState.inBeatSession[sessionType]) {
|
|
56
|
+
context.sessionState.inBeatSession[sessionType] = {};
|
|
57
|
+
}
|
|
55
58
|
context.sessionState.inBeatSession[sessionType][index] = true;
|
|
56
59
|
}
|
|
57
60
|
else {
|
|
@@ -28,7 +28,7 @@ const createValidatedScriptGraphData = ({ systemPrompt, prompt, schema, llmAgent
|
|
|
28
28
|
inputs: {
|
|
29
29
|
model: llmModel,
|
|
30
30
|
system: systemPrompt,
|
|
31
|
-
prompt
|
|
31
|
+
prompt,
|
|
32
32
|
max_tokens: maxTokens,
|
|
33
33
|
},
|
|
34
34
|
},
|
|
@@ -36,7 +36,7 @@ const createValidatedScriptGraphData = ({ systemPrompt, prompt, schema, llmAgent
|
|
|
36
36
|
agent: "validateSchemaAgent",
|
|
37
37
|
inputs: {
|
|
38
38
|
text: ":llm.text.codeBlock()",
|
|
39
|
-
schema
|
|
39
|
+
schema,
|
|
40
40
|
},
|
|
41
41
|
isResult: true,
|
|
42
42
|
},
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type OpenAIImageSize = "1792x1024" | "1024x1792" | "1024x1024" | "1536x1024" | "1024x1536";
|
|
2
|
+
export type OpenAIImageModeration = "low" | "auto";
|
|
3
|
+
export type OpenAIImageOptions = {
|
|
4
|
+
model: string;
|
|
5
|
+
prompt: string;
|
|
6
|
+
n: number;
|
|
7
|
+
size: OpenAIImageSize;
|
|
8
|
+
moderation?: OpenAIImageModeration;
|
|
9
|
+
};
|
|
10
|
+
export type AgentBufferResult = {
|
|
11
|
+
buffer: Buffer;
|
|
12
|
+
};
|
|
13
|
+
export type AgentPromptInputs = {
|
|
14
|
+
prompt: string;
|
|
15
|
+
};
|
|
16
|
+
export type ImageAgentInputs = AgentPromptInputs;
|
|
17
|
+
export type OpenAIImageAgentInputs = AgentPromptInputs & {
|
|
18
|
+
referenceImages: string[] | null | undefined;
|
|
19
|
+
};
|
|
20
|
+
export type ImageAgentParams = {
|
|
21
|
+
model: string;
|
|
22
|
+
canvasSize: {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type OpenAIImageAgentParams = ImageAgentParams & {
|
|
28
|
+
moderation: OpenAIImageModeration | null | undefined;
|
|
29
|
+
};
|
|
30
|
+
export type OpenAIImageAgentConfig = {
|
|
31
|
+
baseURL?: string;
|
|
32
|
+
apiKey?: string;
|
|
33
|
+
};
|
|
34
|
+
export type GoogleImageAgentConfig = {
|
|
35
|
+
projectId?: string;
|
|
36
|
+
token?: string;
|
|
37
|
+
};
|
|
38
|
+
export type MovieAgentInputs = AgentPromptInputs & {
|
|
39
|
+
imagePath?: string;
|
|
40
|
+
};
|
|
41
|
+
export type GoogleMovieAgentParams = ImageAgentParams & {
|
|
42
|
+
duration?: number;
|
|
43
|
+
};
|
|
44
|
+
export type ReplicateMovieAgentParams = {
|
|
45
|
+
model: `${string}/${string}` | undefined;
|
|
46
|
+
canvasSize: {
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
};
|
|
50
|
+
duration?: number;
|
|
51
|
+
};
|
|
52
|
+
export type GoogleMovieAgentConfig = GoogleImageAgentConfig;
|
|
53
|
+
export type ReplicateMovieAgentConfig = {
|
|
54
|
+
apiKey?: string;
|
|
55
|
+
};
|