mulmocast 1.2.5 → 1.2.7

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.
Files changed (40) hide show
  1. package/assets/templates/sifi_story.json +29 -0
  2. package/lib/actions/image_agents.d.ts +4 -0
  3. package/lib/actions/image_agents.js +3 -3
  4. package/lib/actions/images.js +4 -2
  5. package/lib/actions/movie.js +1 -1
  6. package/lib/agents/image_openai_agent.js +1 -1
  7. package/lib/agents/lipsync_replicate_agent.js +9 -3
  8. package/lib/cli/commands/tool/index.js +2 -1
  9. package/lib/cli/commands/tool/whisper/builder.d.ts +4 -0
  10. package/lib/cli/commands/tool/whisper/builder.js +7 -0
  11. package/lib/cli/commands/tool/whisper/handler.d.ts +5 -0
  12. package/lib/cli/commands/tool/whisper/handler.js +100 -0
  13. package/lib/cli/commands/tool/whisper/index.d.ts +4 -0
  14. package/lib/cli/commands/tool/whisper/index.js +4 -0
  15. package/lib/data/promptTemplates.d.ts +76 -0
  16. package/lib/data/promptTemplates.js +55 -0
  17. package/lib/data/scriptTemplates.d.ts +20 -0
  18. package/lib/data/scriptTemplates.js +26 -0
  19. package/lib/data/templateDataSet.d.ts +1 -0
  20. package/lib/data/templateDataSet.js +4 -0
  21. package/lib/types/schema.d.ts +8 -0
  22. package/lib/types/schema.js +1 -0
  23. package/lib/utils/context.d.ts +2 -0
  24. package/lib/utils/context.js +1 -0
  25. package/lib/utils/file.d.ts +4 -1
  26. package/lib/utils/file.js +4 -4
  27. package/package.json +8 -7
  28. package/scripts/templates/story_with_characters.json +25 -0
  29. package/lib/index.d.ts +0 -8
  30. package/lib/index.js +0 -9
  31. package/lib/methods/mulmo_script_template.d.ts +0 -4
  32. package/lib/methods/mulmo_script_template.js +0 -6
  33. package/lib/utils/assets.d.ts +0 -18
  34. package/lib/utils/assets.js +0 -101
  35. package/lib/utils/preprocess.d.ts +0 -343
  36. package/lib/utils/preprocess.js +0 -58
  37. package/lib/utils/system_prompt.d.ts +0 -1
  38. package/lib/utils/system_prompt.js +0 -1
  39. package/lib/utils/templates.d.ts +0 -3
  40. package/lib/utils/templates.js +0 -46
@@ -1,58 +0,0 @@
1
- import { GraphAILogger } from "graphai";
2
- import { mulmoStudioSchema, mulmoCaptionParamsSchema } from "../types/index.js";
3
- import { MulmoPresentationStyleMethods, MulmoScriptMethods } from "../methods/index.js";
4
- const rebuildStudio = (currentStudio, mulmoScript, fileName) => {
5
- const isTest = process.env.NODE_ENV === "test";
6
- const parsed = isTest && currentStudio ? { data: mulmoStudioSchema.parse(currentStudio), success: true, error: null } : mulmoStudioSchema.safeParse(currentStudio);
7
- if (parsed.success) {
8
- return parsed.data;
9
- }
10
- if (currentStudio) {
11
- GraphAILogger.info("currentStudio is invalid", parsed.error);
12
- }
13
- // We need to parse it to fill default values
14
- return mulmoStudioSchema.parse({
15
- script: mulmoScript,
16
- filename: fileName,
17
- beats: [...Array(mulmoScript.beats.length)].map(() => ({})),
18
- });
19
- };
20
- const mulmoCredit = (speaker) => {
21
- return {
22
- speaker,
23
- text: "",
24
- image: {
25
- type: "image",
26
- source: {
27
- kind: "url",
28
- url: "https://github.com/receptron/mulmocast-cli/raw/refs/heads/main/assets/images/mulmocast_credit.png",
29
- },
30
- },
31
- audio: {
32
- type: "audio",
33
- source: {
34
- kind: "url",
35
- url: "https://github.com/receptron/mulmocast-cli/raw/refs/heads/main/assets/audio/silent300.mp3",
36
- },
37
- },
38
- };
39
- };
40
- export const createOrUpdateStudioData = (_mulmoScript, currentStudio, fileName, videoCaptionLang, presentationStyle) => {
41
- const mulmoScript = _mulmoScript.__test_invalid__ ? _mulmoScript : MulmoScriptMethods.validate(_mulmoScript); // validate and insert default value
42
- const studio = rebuildStudio(currentStudio, mulmoScript, fileName);
43
- // TODO: Move this code out of this function later
44
- // Addition cloing credit
45
- if (mulmoScript.$mulmocast.credit === "closing") {
46
- const defaultSpeaker = MulmoPresentationStyleMethods.getDefaultSpeaker(presentationStyle ?? studio.script);
47
- mulmoScript.beats.push(mulmoCredit(mulmoScript.beats[0].speaker ?? defaultSpeaker)); // First speaker
48
- }
49
- studio.script = MulmoScriptMethods.validate(mulmoScript); // update the script
50
- studio.beats = studio.script.beats.map((_, index) => studio.beats[index] ?? {});
51
- if (videoCaptionLang) {
52
- studio.script.captionParams = mulmoCaptionParamsSchema.parse({
53
- ...(studio.script.captionParams ?? {}),
54
- lang: videoCaptionLang,
55
- });
56
- }
57
- return studio;
58
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import type { MulmoScript } from "../types/type.js";
2
- export declare const readScriptTemplateFile: (scriptTemplateFileName: string) => MulmoScript;
3
- export declare const readTemplatePrompt: (promptTemplateFileName: string) => string;
@@ -1,46 +0,0 @@
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
- };