mulmocast 1.1.1 → 1.1.2
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/akira_comic.json +1 -1
- package/assets/templates/ani.json +1 -1
- package/assets/templates/ani_ja.json +1 -1
- package/assets/templates/business.json +1 -1
- package/assets/templates/characters.json +1 -1
- package/assets/templates/children_book.json +1 -1
- package/assets/templates/coding.json +1 -1
- package/assets/templates/comic_strips.json +1 -1
- package/assets/templates/drslump_comic.json +1 -1
- package/assets/templates/ghibli_comic.json +1 -1
- package/assets/templates/ghibli_image_only.json +1 -1
- package/assets/templates/ghibli_shorts.json +1 -1
- package/assets/templates/ghost_comic.json +1 -1
- package/assets/templates/html.json +1 -1
- package/assets/templates/onepiece_comic.json +1 -1
- package/assets/templates/portrait_movie.json +1 -1
- package/assets/templates/realistic_movie.json +1 -1
- package/assets/templates/sensei_and_taro.json +1 -1
- package/assets/templates/shorts.json +1 -1
- package/assets/templates/text_and_image.json +1 -1
- package/assets/templates/text_only.json +1 -1
- package/assets/templates/trailer.json +1 -1
- package/lib/actions/image_agents.d.ts +3 -0
- package/lib/actions/image_agents.js +3 -1
- package/lib/actions/images.js +5 -5
- package/lib/agents/lipsync_replicate_agent.js +19 -4
- package/lib/agents/movie_replicate_agent.js +10 -1
- package/lib/cli/commands/tool/prompt/builder.js +2 -2
- package/lib/cli/commands/tool/scripting/builder.js +2 -2
- package/lib/cli/commands/tool/story_to_script/builder.js +2 -2
- package/lib/data/promptTemplates.d.ts +48 -294
- package/lib/data/promptTemplates.js +25 -411
- package/lib/data/scriptTemplates.d.ts +575 -151
- package/lib/data/scriptTemplates.js +956 -437
- package/lib/index.common.d.ts +1 -0
- package/lib/index.common.js +1 -0
- package/lib/methods/index.d.ts +0 -1
- package/lib/methods/index.js +0 -1
- package/lib/methods/mulmo_presentation_style.d.ts +2 -0
- package/lib/methods/mulmo_script_template.d.ts +2 -2
- package/lib/tools/create_mulmo_script_from_url.js +14 -2
- package/lib/tools/create_mulmo_script_interactively.js +2 -1
- package/lib/tools/dump_prompt.js +1 -1
- package/lib/tools/story_to_script.js +5 -4
- package/lib/types/schema.d.ts +92 -92
- package/lib/types/schema.js +2 -2
- package/lib/types/type.d.ts +3 -3
- package/lib/utils/context.d.ts +6 -6
- package/lib/utils/file.d.ts +4 -9
- package/lib/utils/file.js +26 -49
- package/lib/utils/inquirer.js +2 -2
- package/lib/utils/preprocess.d.ts +6 -6
- package/lib/utils/prompt.d.ts +1 -2
- package/lib/utils/prompt.js +0 -14
- package/lib/utils/provider2agent.d.ts +2 -0
- package/lib/utils/provider2agent.js +20 -1
- package/lib/utils/system_prompt.d.ts +1 -0
- package/lib/utils/system_prompt.js +1 -0
- package/lib/utils/templates.d.ts +3 -0
- package/lib/utils/templates.js +46 -0
- package/package.json +2 -2
package/lib/utils/file.js
CHANGED
|
@@ -3,8 +3,8 @@ import path from "path";
|
|
|
3
3
|
import { parse as yamlParse } from "yaml";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { GraphAILogger } from "graphai";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { MulmoStudioContextMethods } from "../methods/index.js";
|
|
7
|
+
import { mulmoPromptTemplateSchema } from "../types/schema.js";
|
|
8
8
|
const promptTemplateDirName = "./assets/templates";
|
|
9
9
|
const scriptTemplateDirName = "./scripts/templates";
|
|
10
10
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -150,61 +150,38 @@ export const getFullPath = (baseDirPath, file) => {
|
|
|
150
150
|
}
|
|
151
151
|
return path.resolve(file);
|
|
152
152
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const scriptData = fs.readFileSync(scriptPath, "utf-8");
|
|
156
|
-
// NOTE: We don't want to schema parse the script here to eliminate default values.
|
|
157
|
-
return JSON.parse(scriptData);
|
|
158
|
-
};
|
|
159
|
-
const readPromptTemplateFile = (promptTemplateName) => {
|
|
160
|
-
const promptTemplatePath = getPromptTemplateFilePath(promptTemplateName);
|
|
161
|
-
const promptTemplateData = fs.readFileSync(promptTemplatePath, "utf-8");
|
|
162
|
-
// NOTE: We don't want to schema parse the template here to eliminate default values.
|
|
163
|
-
const promptTemplate = JSON.parse(promptTemplateData);
|
|
164
|
-
return promptTemplate;
|
|
165
|
-
};
|
|
166
|
-
const mulmoScriptTemplate2Script = (scriptTemplate) => {
|
|
167
|
-
if (scriptTemplate.scriptName) {
|
|
168
|
-
const scriptData = readScriptTemplateFile(scriptTemplate.scriptName);
|
|
169
|
-
return { ...scriptData, ...(scriptTemplate.presentationStyle ?? {}) };
|
|
170
|
-
}
|
|
171
|
-
return undefined;
|
|
172
|
-
};
|
|
173
|
-
export const getScriptFromPromptTemplate = (promptTemplateName) => {
|
|
174
|
-
const promptTemplate = readPromptTemplateFile(promptTemplateName);
|
|
175
|
-
return mulmoScriptTemplate2Script(promptTemplate);
|
|
176
|
-
};
|
|
177
|
-
export const readTemplatePrompt = (promptTemplateName) => {
|
|
178
|
-
const promptTemplate = readPromptTemplateFile(promptTemplateName);
|
|
179
|
-
const script = mulmoScriptTemplate2Script(promptTemplate);
|
|
180
|
-
const prompt = MulmoScriptTemplateMethods.getSystemPrompt(promptTemplate, script);
|
|
181
|
-
return prompt;
|
|
182
|
-
};
|
|
183
|
-
// TODO: MulmoScriptTemplateFileは、実際はpromptTempate
|
|
184
|
-
// TODO: remove it after update app
|
|
185
|
-
export const getAvailableTemplates = () => {
|
|
186
|
-
return getAvailablePromptTemplates();
|
|
187
|
-
};
|
|
188
|
-
export const getAvailablePromptTemplates = () => {
|
|
189
|
-
return getPromptTemplates(promptTemplateDirName, mulmoScriptTemplateSchema);
|
|
190
|
-
};
|
|
191
|
-
export const getAvailableScriptTemplates = () => {
|
|
192
|
-
return getPromptTemplates(scriptTemplateDirName, mulmoPresentationStyleSchema);
|
|
193
|
-
};
|
|
194
|
-
export const getPromptTemplates = (dirPath, schema) => {
|
|
153
|
+
// templates
|
|
154
|
+
const getPromptTemplates = (dirPath, schema) => {
|
|
195
155
|
const templatesDir = path.resolve(npmRoot, dirPath);
|
|
196
156
|
if (!fs.existsSync(templatesDir)) {
|
|
197
157
|
return [];
|
|
198
158
|
}
|
|
199
159
|
const files = fs.readdirSync(templatesDir);
|
|
200
160
|
return files.map((file) => {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
161
|
+
try {
|
|
162
|
+
const promptTemplate = JSON.parse(fs.readFileSync(path.resolve(templatesDir, file), "utf-8"));
|
|
163
|
+
return {
|
|
164
|
+
...(schema ? schema.parse(promptTemplate) : promptTemplate),
|
|
165
|
+
filename: file.replace(/\.json$/, ""),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
GraphAILogger.info("file: " + file);
|
|
170
|
+
GraphAILogger.info(e);
|
|
171
|
+
return {};
|
|
172
|
+
}
|
|
206
173
|
});
|
|
207
174
|
};
|
|
175
|
+
export const getAvailablePromptTemplates = (skipValidation) => {
|
|
176
|
+
if (skipValidation) {
|
|
177
|
+
return getPromptTemplates(promptTemplateDirName, null);
|
|
178
|
+
}
|
|
179
|
+
return getPromptTemplates(promptTemplateDirName, mulmoPromptTemplateSchema);
|
|
180
|
+
};
|
|
181
|
+
export const getAvailableScriptTemplates = () => {
|
|
182
|
+
return getPromptTemplates(scriptTemplateDirName, null);
|
|
183
|
+
};
|
|
184
|
+
// end of template
|
|
208
185
|
export const writingMessage = (filePath) => {
|
|
209
186
|
GraphAILogger.debug(`writing: ${filePath}`);
|
|
210
187
|
};
|
package/lib/utils/inquirer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
|
-
import {
|
|
2
|
+
import { getAvailablePromptTemplates } from "./file.js";
|
|
3
3
|
export const selectTemplate = async () => {
|
|
4
|
-
const availableTemplates =
|
|
4
|
+
const availableTemplates = getAvailablePromptTemplates();
|
|
5
5
|
const answers = await inquirer.prompt([
|
|
6
6
|
{
|
|
7
7
|
type: "list",
|
|
@@ -205,12 +205,6 @@ export declare const createOrUpdateStudioData: (_mulmoScript: MulmoScript, curre
|
|
|
205
205
|
type: "voice_over";
|
|
206
206
|
startAt?: number | undefined;
|
|
207
207
|
} | undefined;
|
|
208
|
-
duration?: number | undefined;
|
|
209
|
-
speechOptions?: {
|
|
210
|
-
speed?: number | undefined;
|
|
211
|
-
instruction?: string | undefined;
|
|
212
|
-
} | undefined;
|
|
213
|
-
id?: string | undefined;
|
|
214
208
|
audio?: {
|
|
215
209
|
type: "audio";
|
|
216
210
|
source: {
|
|
@@ -230,6 +224,12 @@ export declare const createOrUpdateStudioData: (_mulmoScript: MulmoScript, curre
|
|
|
230
224
|
type: "midi";
|
|
231
225
|
source: string;
|
|
232
226
|
} | undefined;
|
|
227
|
+
duration?: number | undefined;
|
|
228
|
+
speechOptions?: {
|
|
229
|
+
speed?: number | undefined;
|
|
230
|
+
instruction?: string | undefined;
|
|
231
|
+
} | undefined;
|
|
232
|
+
id?: string | undefined;
|
|
233
233
|
imagePrompt?: string | undefined;
|
|
234
234
|
speaker?: string | undefined;
|
|
235
235
|
description?: string | undefined;
|
package/lib/utils/prompt.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { MulmoBeat, MulmoScript,
|
|
1
|
+
import { MulmoBeat, MulmoScript, MulmoStoryboard, MulmoCanvasDimension } from "../types/index.js";
|
|
2
2
|
export declare const imagePrompt: (beat: MulmoBeat, style?: string) => string;
|
|
3
3
|
export declare const graphDataScriptFromUrlPrompt: (sourceTextInput: string) => string;
|
|
4
4
|
export declare const graphDataScriptGeneratePrompt: (scene: string) => string;
|
|
5
|
-
export declare const getMulmoScriptTemplateSystemPrompt: (template: MulmoScriptTemplate, script?: MulmoScript) => string;
|
|
6
5
|
export declare const interactiveClarificationPrompt = "If there are any unclear points, be sure to ask the user questions and clarify them before generating the script.";
|
|
7
6
|
export declare const prefixPrompt = "Here is the web content that can be used as reference material for the script:";
|
|
8
7
|
export declare const translateSystemPrompt = "Please translate the given text into the language specified in language (in locale format, like en, ja, fr, ch).";
|
package/lib/utils/prompt.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { mulmoScriptSchema } from "../types/schema.js";
|
|
2
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
3
1
|
export const imagePrompt = (beat, style) => {
|
|
4
2
|
return (beat.imagePrompt || `generate image appropriate for the text. text: ${beat.text}`) + "\n" + (style || "");
|
|
5
3
|
};
|
|
@@ -10,18 +8,6 @@ export const graphDataScriptFromUrlPrompt = (sourceTextInput) => {
|
|
|
10
8
|
export const graphDataScriptGeneratePrompt = (scene) => {
|
|
11
9
|
return `Please generate a script from the following scenes: ${scene}`;
|
|
12
10
|
};
|
|
13
|
-
export const getMulmoScriptTemplateSystemPrompt = (template, script) => {
|
|
14
|
-
// script is provided, use it as a script template
|
|
15
|
-
if (script) {
|
|
16
|
-
return `${template.systemPrompt}\n\`\`\`JSON\n${JSON.stringify(script)}\n\`\`\``;
|
|
17
|
-
}
|
|
18
|
-
// script is not provided, use the default schema
|
|
19
|
-
const defaultSchema = zodToJsonSchema(mulmoScriptSchema, {
|
|
20
|
-
strictUnions: true,
|
|
21
|
-
});
|
|
22
|
-
const specificOutputPrompt = `The output should follow the JSON schema specified below. Please provide your response as valid JSON within \`\`\`json code blocks for clarity.`;
|
|
23
|
-
return `${template.systemPrompt}\n\n${specificOutputPrompt}\n\n\`\`\`JSON\n${JSON.stringify(defaultSchema)}\n\`\`\``;
|
|
24
|
-
};
|
|
25
11
|
export const interactiveClarificationPrompt = `If there are any unclear points, be sure to ask the user questions and clarify them before generating the script.`;
|
|
26
12
|
export const prefixPrompt = "Here is the web content that can be used as reference material for the script:";
|
|
27
13
|
export const translateSystemPrompt = "Please translate the given text into the language specified in language (in locale format, like en, ja, fr, ch).";
|
|
@@ -134,11 +134,30 @@ export const provider2LipSyncAgent = {
|
|
|
134
134
|
replicate: {
|
|
135
135
|
agentName: "lipSyncReplicateAgent",
|
|
136
136
|
defaultModel: "bytedance/latentsync",
|
|
137
|
-
models: ["bytedance/latentsync"],
|
|
137
|
+
models: ["bytedance/latentsync", "tmappdev/lipsync"],
|
|
138
138
|
modelParams: {
|
|
139
139
|
"bytedance/latentsync": {
|
|
140
140
|
identifier: "bytedance/latentsync:637ce1919f807ca20da3a448ddc2743535d2853649574cd52a933120e9b9e293",
|
|
141
|
+
video: "video",
|
|
142
|
+
audio: "audio",
|
|
141
143
|
},
|
|
144
|
+
"tmappdev/lipsync": {
|
|
145
|
+
identifier: "tmappdev/lipsync:c54ce2fe673ea59b857b91250b3d71a2cd304a78f2370687632805c8405fbf4c",
|
|
146
|
+
video: "video_input",
|
|
147
|
+
audio: "audio_input",
|
|
148
|
+
},
|
|
149
|
+
/* NOTE: This model does not work with large base64 urls.
|
|
150
|
+
"sync/lipsync-2": {
|
|
151
|
+
video: "video",
|
|
152
|
+
audio: "audio",
|
|
153
|
+
},
|
|
154
|
+
*/
|
|
155
|
+
/* NOTE: This model does not work well for some unknown reason.
|
|
156
|
+
"kwaivgi/kling-lip-sync": {
|
|
157
|
+
video: "video_url",
|
|
158
|
+
audio: "audio_file",
|
|
159
|
+
},
|
|
160
|
+
*/
|
|
142
161
|
},
|
|
143
162
|
},
|
|
144
163
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { mulmoScriptSchema } from "../types/schema.js";
|
|
2
|
+
import { promptTemplates, scriptTemplates } from "../data/index.js";
|
|
3
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
4
|
+
// script and prompt template
|
|
5
|
+
export const readScriptTemplateFile = (scriptTemplateFileName) => {
|
|
6
|
+
// NOTE: We don't want to schema parse the script here to eliminate default values.
|
|
7
|
+
const scriptTemplate = scriptTemplates.find((template) => template.filename === scriptTemplateFileName);
|
|
8
|
+
if (!scriptTemplate) {
|
|
9
|
+
throw new Error(`Script template not found: ${scriptTemplateFileName}`);
|
|
10
|
+
}
|
|
11
|
+
const { filename: __, ...retValue } = scriptTemplate;
|
|
12
|
+
return retValue;
|
|
13
|
+
};
|
|
14
|
+
const readPromptTemplateFile = (promptTemplateFileName) => {
|
|
15
|
+
// NOTE: We don't want to schema parse the template here to eliminate default values.
|
|
16
|
+
const promptTemplate = promptTemplates.find((template) => template.filename === promptTemplateFileName);
|
|
17
|
+
if (!promptTemplate) {
|
|
18
|
+
throw new Error(`Prompt template not found: ${promptTemplateFileName}`);
|
|
19
|
+
}
|
|
20
|
+
return promptTemplate;
|
|
21
|
+
};
|
|
22
|
+
const mulmoScriptTemplate2Script = (scriptTemplate) => {
|
|
23
|
+
if (scriptTemplate.scriptName) {
|
|
24
|
+
const scriptTemplateData = readScriptTemplateFile(scriptTemplate.scriptName);
|
|
25
|
+
return { ...scriptTemplateData, ...(scriptTemplate.presentationStyle ?? {}) };
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
};
|
|
29
|
+
export const readTemplatePrompt = (promptTemplateFileName) => {
|
|
30
|
+
const promptTemplate = readPromptTemplateFile(promptTemplateFileName);
|
|
31
|
+
const script = mulmoScriptTemplate2Script(promptTemplate);
|
|
32
|
+
const prompt = getMulmoScriptTemplateSystemPrompt(promptTemplate, script);
|
|
33
|
+
return prompt;
|
|
34
|
+
};
|
|
35
|
+
const getMulmoScriptTemplateSystemPrompt = (template, script) => {
|
|
36
|
+
// script is provided, use it as a script template
|
|
37
|
+
if (script) {
|
|
38
|
+
return `${template.systemPrompt}\n\`\`\`JSON\n${JSON.stringify(script)}\n\`\`\``;
|
|
39
|
+
}
|
|
40
|
+
// script is not provided, use the default schema
|
|
41
|
+
const defaultSchema = zodToJsonSchema(mulmoScriptSchema, {
|
|
42
|
+
strictUnions: true,
|
|
43
|
+
});
|
|
44
|
+
const specificOutputPrompt = `The output should follow the JSON schema specified below. Please provide your response as valid JSON within \`\`\`json code blocks for clarity.`;
|
|
45
|
+
return `${template.systemPrompt}\n\n${specificOutputPrompt}\n\n\`\`\`JSON\n${JSON.stringify(defaultSchema)}\n\`\`\``;
|
|
46
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mulmocast",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.node.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"latest": "yarn upgrade-interactive --latest",
|
|
52
52
|
"format": "prettier --write '{src,scripts,assets/templates,assets/styles,draft,ideason,scripts_mag2,proto,test,graphai,output,docs/scripts}/**/*.{ts,json,yaml}'",
|
|
53
53
|
"deep_research": "npx tsx ./src/tools/deep_research.ts",
|
|
54
|
-
"template": "npx tsx batch/template2tsobject.ts",
|
|
54
|
+
"template": "npx tsx batch/template2tsobject.ts && yarn run format",
|
|
55
55
|
"fake_data": "npx tsx test/fake/sample.ts",
|
|
56
56
|
"mcp_server": "npx tsx ./src/mcp/server.ts"
|
|
57
57
|
},
|