mulmocast 1.1.1 → 1.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/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/scriptTemplates.d.ts +575 -151
- package/lib/data/scriptTemplates.js +956 -437
- 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 +12 -1
- package/lib/tools/story_to_script.js +3 -3
- 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 +7 -9
- package/lib/utils/file.js +38 -34
- package/lib/utils/inquirer.js +2 -2
- package/lib/utils/preprocess.d.ts +6 -6
- package/lib/utils/prompt.d.ts +2 -2
- 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 +1 -1
package/lib/utils/file.js
CHANGED
|
@@ -3,8 +3,9 @@ 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
|
+
import { getMulmoScriptTemplateSystemPrompt } from "./prompt.js";
|
|
8
9
|
const promptTemplateDirName = "./assets/templates";
|
|
9
10
|
const scriptTemplateDirName = "./scripts/templates";
|
|
10
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -150,61 +151,64 @@ export const getFullPath = (baseDirPath, file) => {
|
|
|
150
151
|
}
|
|
151
152
|
return path.resolve(file);
|
|
152
153
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
154
|
+
// script and prompt template
|
|
155
|
+
export const readScriptTemplateFile = (scriptTemplateFileName) => {
|
|
156
|
+
const scriptTemplatePath = path.resolve(npmRoot, scriptTemplateDirName, scriptTemplateFileName);
|
|
157
|
+
const scriptTemplateData = fs.readFileSync(scriptTemplatePath, "utf-8");
|
|
156
158
|
// NOTE: We don't want to schema parse the script here to eliminate default values.
|
|
157
|
-
return JSON.parse(
|
|
159
|
+
return JSON.parse(scriptTemplateData);
|
|
158
160
|
};
|
|
159
|
-
const readPromptTemplateFile = (
|
|
160
|
-
const promptTemplatePath = getPromptTemplateFilePath(
|
|
161
|
+
const readPromptTemplateFile = (promptTemplateFileName) => {
|
|
162
|
+
const promptTemplatePath = getPromptTemplateFilePath(promptTemplateFileName);
|
|
161
163
|
const promptTemplateData = fs.readFileSync(promptTemplatePath, "utf-8");
|
|
162
164
|
// NOTE: We don't want to schema parse the template here to eliminate default values.
|
|
163
|
-
|
|
164
|
-
return promptTemplate;
|
|
165
|
+
return JSON.parse(promptTemplateData);
|
|
165
166
|
};
|
|
166
167
|
const mulmoScriptTemplate2Script = (scriptTemplate) => {
|
|
167
168
|
if (scriptTemplate.scriptName) {
|
|
168
|
-
const
|
|
169
|
-
return { ...
|
|
169
|
+
const scriptTemplateData = readScriptTemplateFile(scriptTemplate.scriptName);
|
|
170
|
+
return { ...scriptTemplateData, ...(scriptTemplate.presentationStyle ?? {}) };
|
|
170
171
|
}
|
|
171
172
|
return undefined;
|
|
172
173
|
};
|
|
173
|
-
export const getScriptFromPromptTemplate = (
|
|
174
|
-
const promptTemplate = readPromptTemplateFile(
|
|
174
|
+
export const getScriptFromPromptTemplate = (promptTemplateFileName) => {
|
|
175
|
+
const promptTemplate = readPromptTemplateFile(promptTemplateFileName);
|
|
175
176
|
return mulmoScriptTemplate2Script(promptTemplate);
|
|
176
177
|
};
|
|
177
|
-
export const readTemplatePrompt = (
|
|
178
|
-
const promptTemplate = readPromptTemplateFile(
|
|
178
|
+
export const readTemplatePrompt = (promptTemplateFileName) => {
|
|
179
|
+
const promptTemplate = readPromptTemplateFile(promptTemplateFileName);
|
|
179
180
|
const script = mulmoScriptTemplate2Script(promptTemplate);
|
|
180
|
-
const prompt =
|
|
181
|
+
const prompt = getMulmoScriptTemplateSystemPrompt(promptTemplate, script);
|
|
181
182
|
return prompt;
|
|
182
183
|
};
|
|
183
|
-
|
|
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) => {
|
|
184
|
+
const getPromptTemplates = (dirPath, schema) => {
|
|
195
185
|
const templatesDir = path.resolve(npmRoot, dirPath);
|
|
196
186
|
if (!fs.existsSync(templatesDir)) {
|
|
197
187
|
return [];
|
|
198
188
|
}
|
|
199
189
|
const files = fs.readdirSync(templatesDir);
|
|
200
190
|
return files.map((file) => {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
191
|
+
try {
|
|
192
|
+
const promptTemplate = JSON.parse(fs.readFileSync(path.resolve(templatesDir, file), "utf-8"));
|
|
193
|
+
return {
|
|
194
|
+
...(schema ? schema.parse(promptTemplate) : promptTemplate),
|
|
195
|
+
filename: file.replace(/\.json$/, ""),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
GraphAILogger.info("file: " + file);
|
|
200
|
+
GraphAILogger.info(e);
|
|
201
|
+
return {};
|
|
202
|
+
}
|
|
206
203
|
});
|
|
207
204
|
};
|
|
205
|
+
export const getAvailablePromptTemplates = () => {
|
|
206
|
+
return getPromptTemplates(promptTemplateDirName, mulmoPromptTemplateSchema);
|
|
207
|
+
};
|
|
208
|
+
export const getAvailableScriptTemplates = () => {
|
|
209
|
+
return getPromptTemplates(scriptTemplateDirName, null);
|
|
210
|
+
};
|
|
211
|
+
// end of template
|
|
208
212
|
export const writingMessage = (filePath) => {
|
|
209
213
|
GraphAILogger.debug(`writing: ${filePath}`);
|
|
210
214
|
};
|
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,8 @@
|
|
|
1
|
-
import { MulmoBeat, MulmoScript,
|
|
1
|
+
import { MulmoBeat, MulmoScript, MulmoPromptTemplate, 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:
|
|
5
|
+
export declare const getMulmoScriptTemplateSystemPrompt: (template: MulmoPromptTemplate, script?: MulmoScript) => string;
|
|
6
6
|
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
7
|
export declare const prefixPrompt = "Here is the web content that can be used as reference material for the script:";
|
|
8
8
|
export declare 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
|
+
};
|