mulmocast 1.1.2 → 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/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/data/promptTemplates.d.ts +294 -48
- package/lib/data/promptTemplates.js +411 -25
- package/lib/index.common.d.ts +0 -1
- package/lib/index.common.js +0 -1
- package/lib/tools/create_mulmo_script_from_url.js +1 -2
- package/lib/tools/create_mulmo_script_interactively.js +1 -2
- package/lib/tools/dump_prompt.js +1 -1
- package/lib/tools/story_to_script.js +1 -2
- package/lib/utils/file.d.ts +4 -1
- package/lib/utils/file.js +32 -5
- package/lib/utils/prompt.d.ts +2 -1
- package/lib/utils/prompt.js +14 -0
- package/package.json +2 -2
package/lib/index.common.d.ts
CHANGED
package/lib/index.common.js
CHANGED
|
@@ -9,8 +9,7 @@ import * as agents from "@graphai/vanilla";
|
|
|
9
9
|
import { fileWriteAgent } from "@graphai/vanilla_node_agents";
|
|
10
10
|
import { browserlessAgent } from "@graphai/browserless_agent";
|
|
11
11
|
import validateSchemaAgent from "../agents/validate_schema_agent.js";
|
|
12
|
-
import { mkdir, writingMessage } from "../utils/file.js";
|
|
13
|
-
import { readTemplatePrompt } from "../utils/templates.js";
|
|
12
|
+
import { readTemplatePrompt, mkdir, writingMessage } from "../utils/file.js";
|
|
14
13
|
import { browserlessCacheGenerator } from "../utils/filters.js";
|
|
15
14
|
import { mulmoScriptSchema, urlsSchema } from "../types/schema.js";
|
|
16
15
|
import { cliLoadingPlugin } from "../utils/plugins.js";
|
|
@@ -8,8 +8,7 @@ import { geminiAgent } from "@graphai/gemini_agent";
|
|
|
8
8
|
import { groqAgent } from "@graphai/groq_agent";
|
|
9
9
|
import * as agents from "@graphai/vanilla";
|
|
10
10
|
import { fileWriteAgent } from "@graphai/vanilla_node_agents";
|
|
11
|
-
import { mkdir } from "../utils/file.js";
|
|
12
|
-
import { readTemplatePrompt } from "../utils/templates.js";
|
|
11
|
+
import { readTemplatePrompt, mkdir } from "../utils/file.js";
|
|
13
12
|
import { browserlessCacheGenerator } from "../utils/filters.js";
|
|
14
13
|
import { mulmoScriptSchema } from "../types/index.js";
|
|
15
14
|
import { browserlessAgent } from "@graphai/browserless_agent";
|
package/lib/tools/dump_prompt.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphAILogger } from "graphai";
|
|
2
|
-
import { readTemplatePrompt } from "../utils/
|
|
2
|
+
import { readTemplatePrompt } from "../utils/file.js";
|
|
3
3
|
import clipboardy from "clipboardy";
|
|
4
4
|
export const dumpPromptFromTemplate = async ({ templateName }) => {
|
|
5
5
|
const prompt = readTemplatePrompt(templateName);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getPromptTemplateFilePath, readAndParseJson, writingMessage } from "../utils/file.js";
|
|
2
|
-
import { readScriptTemplateFile } from "../utils/templates.js";
|
|
1
|
+
import { getPromptTemplateFilePath, readAndParseJson, readScriptTemplateFile, writingMessage } from "../utils/file.js";
|
|
3
2
|
import { mulmoScriptSchema, mulmoPromptTemplateSchema } from "../types/schema.js";
|
|
4
3
|
import { GraphAI, GraphAILogger } from "graphai";
|
|
5
4
|
import { openAIAgent } from "@graphai/openai_agent";
|
package/lib/utils/file.d.ts
CHANGED
|
@@ -40,7 +40,10 @@ export declare const defaultBGMPath: () => string;
|
|
|
40
40
|
export declare const getHTMLFile: (filename: string) => string;
|
|
41
41
|
export declare const getBaseDirPath: (basedir?: string) => string;
|
|
42
42
|
export declare const getFullPath: (baseDirPath: string | undefined, file: string) => string;
|
|
43
|
-
export declare const
|
|
43
|
+
export declare const readScriptTemplateFile: (scriptTemplateFileName: string) => MulmoScript;
|
|
44
|
+
export declare const getScriptFromPromptTemplate: (promptTemplateFileName: string) => MulmoScript | undefined;
|
|
45
|
+
export declare const readTemplatePrompt: (promptTemplateFileName: string) => string;
|
|
46
|
+
export declare const getAvailablePromptTemplates: () => MulmoPromptTemplateFile[];
|
|
44
47
|
export declare const getAvailableScriptTemplates: () => MulmoScript[];
|
|
45
48
|
export declare const writingMessage: (filePath: string) => void;
|
|
46
49
|
export declare const readAndParseJson: <S extends ZodSchema<any>>(filePath: string, schema: S) => ReturnType<S["parse"]>;
|
package/lib/utils/file.js
CHANGED
|
@@ -5,6 +5,7 @@ import { fileURLToPath } from "url";
|
|
|
5
5
|
import { GraphAILogger } from "graphai";
|
|
6
6
|
import { MulmoStudioContextMethods } from "../methods/index.js";
|
|
7
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,7 +151,36 @@ export const getFullPath = (baseDirPath, file) => {
|
|
|
150
151
|
}
|
|
151
152
|
return path.resolve(file);
|
|
152
153
|
};
|
|
153
|
-
//
|
|
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");
|
|
158
|
+
// NOTE: We don't want to schema parse the script here to eliminate default values.
|
|
159
|
+
return JSON.parse(scriptTemplateData);
|
|
160
|
+
};
|
|
161
|
+
const readPromptTemplateFile = (promptTemplateFileName) => {
|
|
162
|
+
const promptTemplatePath = getPromptTemplateFilePath(promptTemplateFileName);
|
|
163
|
+
const promptTemplateData = fs.readFileSync(promptTemplatePath, "utf-8");
|
|
164
|
+
// NOTE: We don't want to schema parse the template here to eliminate default values.
|
|
165
|
+
return JSON.parse(promptTemplateData);
|
|
166
|
+
};
|
|
167
|
+
const mulmoScriptTemplate2Script = (scriptTemplate) => {
|
|
168
|
+
if (scriptTemplate.scriptName) {
|
|
169
|
+
const scriptTemplateData = readScriptTemplateFile(scriptTemplate.scriptName);
|
|
170
|
+
return { ...scriptTemplateData, ...(scriptTemplate.presentationStyle ?? {}) };
|
|
171
|
+
}
|
|
172
|
+
return undefined;
|
|
173
|
+
};
|
|
174
|
+
export const getScriptFromPromptTemplate = (promptTemplateFileName) => {
|
|
175
|
+
const promptTemplate = readPromptTemplateFile(promptTemplateFileName);
|
|
176
|
+
return mulmoScriptTemplate2Script(promptTemplate);
|
|
177
|
+
};
|
|
178
|
+
export const readTemplatePrompt = (promptTemplateFileName) => {
|
|
179
|
+
const promptTemplate = readPromptTemplateFile(promptTemplateFileName);
|
|
180
|
+
const script = mulmoScriptTemplate2Script(promptTemplate);
|
|
181
|
+
const prompt = getMulmoScriptTemplateSystemPrompt(promptTemplate, script);
|
|
182
|
+
return prompt;
|
|
183
|
+
};
|
|
154
184
|
const getPromptTemplates = (dirPath, schema) => {
|
|
155
185
|
const templatesDir = path.resolve(npmRoot, dirPath);
|
|
156
186
|
if (!fs.existsSync(templatesDir)) {
|
|
@@ -172,10 +202,7 @@ const getPromptTemplates = (dirPath, schema) => {
|
|
|
172
202
|
}
|
|
173
203
|
});
|
|
174
204
|
};
|
|
175
|
-
export const getAvailablePromptTemplates = (
|
|
176
|
-
if (skipValidation) {
|
|
177
|
-
return getPromptTemplates(promptTemplateDirName, null);
|
|
178
|
-
}
|
|
205
|
+
export const getAvailablePromptTemplates = () => {
|
|
179
206
|
return getPromptTemplates(promptTemplateDirName, mulmoPromptTemplateSchema);
|
|
180
207
|
};
|
|
181
208
|
export const getAvailableScriptTemplates = () => {
|
package/lib/utils/prompt.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { MulmoBeat, MulmoScript, MulmoStoryboard, MulmoCanvasDimension } from "../types/index.js";
|
|
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: MulmoPromptTemplate, script?: MulmoScript) => string;
|
|
5
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.";
|
|
6
7
|
export declare const prefixPrompt = "Here is the web content that can be used as reference material for the script:";
|
|
7
8
|
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,3 +1,5 @@
|
|
|
1
|
+
import { mulmoScriptSchema } from "../types/schema.js";
|
|
2
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
1
3
|
export const imagePrompt = (beat, style) => {
|
|
2
4
|
return (beat.imagePrompt || `generate image appropriate for the text. text: ${beat.text}`) + "\n" + (style || "");
|
|
3
5
|
};
|
|
@@ -8,6 +10,18 @@ export const graphDataScriptFromUrlPrompt = (sourceTextInput) => {
|
|
|
8
10
|
export const graphDataScriptGeneratePrompt = (scene) => {
|
|
9
11
|
return `Please generate a script from the following scenes: ${scene}`;
|
|
10
12
|
};
|
|
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
|
+
};
|
|
11
25
|
export const interactiveClarificationPrompt = `If there are any unclear points, be sure to ask the user questions and clarify them before generating the script.`;
|
|
12
26
|
export const prefixPrompt = "Here is the web content that can be used as reference material for the script:";
|
|
13
27
|
export const translateSystemPrompt = "Please translate the given text into the language specified in language (in locale format, like en, ja, fr, ch).";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mulmocast",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
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",
|
|
55
55
|
"fake_data": "npx tsx test/fake/sample.ts",
|
|
56
56
|
"mcp_server": "npx tsx ./src/mcp/server.ts"
|
|
57
57
|
},
|