mulmocast 0.0.2 → 0.0.4
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/README.md +27 -9
- package/assets/font/NotoSansJP-Regular.ttf +0 -0
- package/assets/html/chart.html +1 -10
- package/assets/html/mermaid.html +1 -13
- package/assets/templates/business.json +16 -27
- package/assets/templates/coding.json +58 -21
- package/lib/actions/audio.d.ts +1 -1
- package/lib/actions/audio.js +43 -27
- package/lib/actions/images.js +20 -26
- package/lib/actions/index.d.ts +5 -0
- package/lib/actions/index.js +5 -0
- package/lib/actions/movie.d.ts +9 -1
- package/lib/actions/movie.js +97 -38
- package/lib/actions/pdf.d.ts +2 -0
- package/lib/actions/pdf.js +211 -0
- package/lib/actions/translate.js +22 -9
- package/lib/agents/combine_audio_files_agent.js +13 -22
- package/lib/cli/args.d.ts +3 -1
- package/lib/cli/args.js +49 -34
- package/lib/cli/cli.d.ts +15 -0
- package/lib/cli/cli.js +44 -47
- package/lib/cli/run.d.ts +1 -0
- package/lib/cli/run.js +2 -0
- package/lib/cli/tool-args.d.ts +2 -0
- package/lib/cli/tool-args.js +12 -2
- package/lib/cli/tool-cli.js +6 -4
- package/lib/methods/index.d.ts +1 -0
- package/lib/methods/index.js +1 -0
- package/lib/methods/mulmo_media_source.d.ts +4 -0
- package/lib/methods/mulmo_media_source.js +21 -0
- package/lib/methods/mulmo_script.d.ts +2 -6
- package/lib/methods/mulmo_script.js +12 -5
- package/lib/tools/create_mulmo_script_interactively.d.ts +1 -1
- package/lib/tools/create_mulmo_script_interactively.js +61 -20
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/schema.d.ts +3626 -3162
- package/lib/types/schema.js +75 -41
- package/lib/types/type.d.ts +28 -1
- package/lib/utils/const.d.ts +2 -0
- package/lib/utils/const.js +2 -0
- package/lib/utils/file.d.ts +4 -1
- package/lib/utils/file.js +15 -1
- package/lib/utils/filters.js +1 -1
- package/lib/utils/image_plugins/chart.d.ts +3 -0
- package/lib/utils/image_plugins/chart.js +18 -0
- package/lib/utils/image_plugins/image.d.ts +2 -0
- package/lib/utils/image_plugins/image.js +3 -0
- package/lib/utils/image_plugins/index.d.ts +7 -0
- package/lib/utils/image_plugins/index.js +7 -0
- package/lib/utils/image_plugins/markdown.d.ts +3 -0
- package/lib/utils/image_plugins/markdown.js +11 -0
- package/lib/utils/image_plugins/mermaid.d.ts +3 -0
- package/lib/utils/image_plugins/mermaid.js +21 -0
- package/lib/utils/image_plugins/movie.d.ts +2 -0
- package/lib/utils/image_plugins/movie.js +3 -0
- package/lib/utils/image_plugins/source.d.ts +4 -0
- package/lib/utils/image_plugins/source.js +15 -0
- package/lib/utils/image_plugins/text_slide.d.ts +3 -0
- package/lib/utils/image_plugins/text_slide.js +12 -0
- package/lib/utils/image_plugins/type_guards.d.ts +6 -0
- package/lib/utils/image_plugins/type_guards.js +21 -0
- package/lib/utils/markdown.js +4 -1
- package/lib/utils/pdf.d.ts +8 -0
- package/lib/utils/pdf.js +75 -0
- package/lib/utils/preprocess.d.ts +58 -128
- package/lib/utils/preprocess.js +37 -37
- package/lib/utils/utils.d.ts +12 -0
- package/lib/utils/utils.js +34 -0
- package/package.json +21 -12
- package/lib/tools/seed.d.ts +0 -3
- package/lib/tools/seed.js +0 -201
- package/lib/tools/seed_from_url.d.ts +0 -3
- package/lib/tools/seed_from_url.js +0 -178
- package/lib/tools/seed_from_url2.d.ts +0 -3
- package/lib/tools/seed_from_url2.js +0 -154
- package/lib/utils/image_preprocess.d.ts +0 -14
- package/lib/utils/image_preprocess.js +0 -52
- package/lib/utils/text_hash.d.ts +0 -1
- package/lib/utils/text_hash.js +0 -4
package/lib/tools/seed.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.createMulmoScriptWithInteractive = void 0;
|
|
37
|
-
require("dotenv/config");
|
|
38
|
-
const graphai_1 = require("graphai");
|
|
39
|
-
const input_agents_1 = require("@graphai/input_agents");
|
|
40
|
-
const openai_agent_1 = require("@graphai/openai_agent");
|
|
41
|
-
const vanilla = __importStar(require("@graphai/vanilla"));
|
|
42
|
-
const vanilla_node_agents_1 = require("@graphai/vanilla_node_agents");
|
|
43
|
-
const file_1 = require("../utils/file");
|
|
44
|
-
const browserless_agent_1 = require("@graphai/browserless_agent");
|
|
45
|
-
const agentHeader = "\x1b[34m● \x1b[0m\x1b[1mAgent\x1b[0m:\x1b[0m";
|
|
46
|
-
const graphDataForScraping = {
|
|
47
|
-
version: 0.5,
|
|
48
|
-
nodes: {
|
|
49
|
-
urls: {
|
|
50
|
-
value: [],
|
|
51
|
-
},
|
|
52
|
-
fetchResults: {
|
|
53
|
-
agent: "mapAgent",
|
|
54
|
-
inputs: {
|
|
55
|
-
rows: ":urls",
|
|
56
|
-
},
|
|
57
|
-
params: {
|
|
58
|
-
compositeResult: true,
|
|
59
|
-
},
|
|
60
|
-
graph: {
|
|
61
|
-
nodes: {
|
|
62
|
-
fetcher: {
|
|
63
|
-
agent: "browserlessAgent",
|
|
64
|
-
inputs: {
|
|
65
|
-
url: ":row",
|
|
66
|
-
text_content: true,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
copyAgent: {
|
|
70
|
-
agent: "copyAgent",
|
|
71
|
-
inputs: {
|
|
72
|
-
text: '{ url: "${:row}", text: "${:fetcher.text}" }',
|
|
73
|
-
},
|
|
74
|
-
params: {
|
|
75
|
-
namedKey: "text",
|
|
76
|
-
},
|
|
77
|
-
isResult: true,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
sourceText: {
|
|
83
|
-
agent: "arrayJoinAgent",
|
|
84
|
-
inputs: {
|
|
85
|
-
array: ":fetchResults.copyAgent",
|
|
86
|
-
},
|
|
87
|
-
params: {
|
|
88
|
-
separator: ",",
|
|
89
|
-
},
|
|
90
|
-
isResult: true,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
const graphData = {
|
|
95
|
-
version: 0.5,
|
|
96
|
-
loop: {
|
|
97
|
-
while: ":continue",
|
|
98
|
-
},
|
|
99
|
-
nodes: {
|
|
100
|
-
fileName: {
|
|
101
|
-
update: ":fileName",
|
|
102
|
-
},
|
|
103
|
-
outdir: {
|
|
104
|
-
update: ":outdir",
|
|
105
|
-
},
|
|
106
|
-
messages: {
|
|
107
|
-
value: [],
|
|
108
|
-
update: ":llm.messages",
|
|
109
|
-
},
|
|
110
|
-
userInput: {
|
|
111
|
-
agent: "textInputAgent",
|
|
112
|
-
params: {
|
|
113
|
-
message: "You:",
|
|
114
|
-
required: true,
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
llm: {
|
|
118
|
-
agent: "openAIAgent",
|
|
119
|
-
params: {
|
|
120
|
-
model: "gpt-4o",
|
|
121
|
-
},
|
|
122
|
-
inputs: {
|
|
123
|
-
messages: ":messages",
|
|
124
|
-
prompt: ":userInput.text",
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
json: {
|
|
128
|
-
agent: "copyAgent",
|
|
129
|
-
inputs: {
|
|
130
|
-
json: ":llm.text.codeBlock().jsonParse()",
|
|
131
|
-
text: ":llm.text.codeBlock()",
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
writeJSON: {
|
|
135
|
-
if: ":json.json",
|
|
136
|
-
agent: "fileWriteAgent",
|
|
137
|
-
inputs: {
|
|
138
|
-
file: "${:outdir}/${:fileName}-${@now}.json",
|
|
139
|
-
text: ":json.text",
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
writeLog: {
|
|
143
|
-
agent: "consoleAgent",
|
|
144
|
-
inputs: {
|
|
145
|
-
text: "\n\x1b[32m🎉 Script file generated successfully! Type /bye to exit.\x1b[0m\nwriting: ${:writeJSON.path}",
|
|
146
|
-
waiting: ":writeJSON",
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
shouldResponse: {
|
|
150
|
-
agent: "compareAgent",
|
|
151
|
-
inputs: {
|
|
152
|
-
array: [[":json.json", "==", undefined], "&&", [":userInput.text", "!=", "/bye"]],
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
agentResponse: {
|
|
156
|
-
if: ":shouldResponse.result",
|
|
157
|
-
agent: "consoleAgent",
|
|
158
|
-
inputs: {
|
|
159
|
-
text: "\n" + agentHeader + " ${:llm.text}\n",
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
checkInput: {
|
|
163
|
-
agent: "compareAgent",
|
|
164
|
-
inputs: { array: [":userInput.text", "!=", "/bye"] },
|
|
165
|
-
},
|
|
166
|
-
continue: {
|
|
167
|
-
value: true,
|
|
168
|
-
update: ":checkInput.result",
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
const interactiveClarificationPrompt = `If there are any unclear points, be sure to ask the user questions and clarify them before generating the script.`;
|
|
173
|
-
const scrapeWebContent = async (urls) => {
|
|
174
|
-
console.log(`${agentHeader} Scraping ${urls.length} URLs...\n`);
|
|
175
|
-
const graph = new graphai_1.GraphAI(graphDataForScraping, { ...vanilla, openAIAgent: openai_agent_1.openAIAgent, textInputAgent: input_agents_1.textInputAgent, fileWriteAgent: vanilla_node_agents_1.fileWriteAgent, browserlessAgent: browserless_agent_1.browserlessAgent });
|
|
176
|
-
graph.injectValue("urls", urls);
|
|
177
|
-
const result = (await graph.run());
|
|
178
|
-
if (!result?.sourceText?.text) {
|
|
179
|
-
return "";
|
|
180
|
-
}
|
|
181
|
-
const prefixPrompt = "Here is the web content that can be used as reference material for the script:";
|
|
182
|
-
return `\n\n${prefixPrompt}\n${result?.sourceText.text}`;
|
|
183
|
-
};
|
|
184
|
-
const createMulmoScriptWithInteractive = async ({ outDirPath, filename, templateName, urls }) => {
|
|
185
|
-
(0, file_1.mkdir)(outDirPath);
|
|
186
|
-
// if urls is not empty, scrape web content and reference it in the prompt
|
|
187
|
-
const webContentPrompt = urls.length > 0 ? await scrapeWebContent(urls) : "";
|
|
188
|
-
const graph = new graphai_1.GraphAI(graphData, { ...vanilla, openAIAgent: openai_agent_1.openAIAgent, textInputAgent: input_agents_1.textInputAgent, fileWriteAgent: vanilla_node_agents_1.fileWriteAgent });
|
|
189
|
-
const prompt = (0, file_1.readTemplatePrompt)(templateName);
|
|
190
|
-
graph.injectValue("messages", [
|
|
191
|
-
{
|
|
192
|
-
role: "system",
|
|
193
|
-
content: `${prompt}\n\n${interactiveClarificationPrompt}${webContentPrompt}`,
|
|
194
|
-
},
|
|
195
|
-
]);
|
|
196
|
-
graph.injectValue("outdir", outDirPath);
|
|
197
|
-
graph.injectValue("fileName", filename);
|
|
198
|
-
console.log(`${agentHeader} Hi! What topic would you like me to generate about?\n`);
|
|
199
|
-
await graph.run();
|
|
200
|
-
};
|
|
201
|
-
exports.createMulmoScriptWithInteractive = createMulmoScriptWithInteractive;
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.createMulmoScriptFromUrl = void 0;
|
|
40
|
-
require("dotenv/config");
|
|
41
|
-
const graphai_1 = require("graphai");
|
|
42
|
-
const openai_agent_1 = require("@graphai/openai_agent");
|
|
43
|
-
const vanilla = __importStar(require("@graphai/vanilla"));
|
|
44
|
-
const vanilla_node_agents_1 = require("@graphai/vanilla_node_agents");
|
|
45
|
-
const browserless_agent_1 = require("@graphai/browserless_agent");
|
|
46
|
-
const validate_mulmo_script_agent_1 = __importDefault(require("../agents/validate_mulmo_script_agent"));
|
|
47
|
-
const file_1 = require("../utils/file");
|
|
48
|
-
const schema_1 = require("../types/schema");
|
|
49
|
-
const graphData = {
|
|
50
|
-
version: 0.5,
|
|
51
|
-
// Execute sequentially because the free version of browserless API doesn't support concurrent execution.
|
|
52
|
-
concurrency: 1,
|
|
53
|
-
nodes: {
|
|
54
|
-
urls: {
|
|
55
|
-
value: [],
|
|
56
|
-
},
|
|
57
|
-
prompt: {
|
|
58
|
-
value: "",
|
|
59
|
-
},
|
|
60
|
-
outdir: {
|
|
61
|
-
value: "",
|
|
62
|
-
},
|
|
63
|
-
fileName: {
|
|
64
|
-
value: "",
|
|
65
|
-
},
|
|
66
|
-
// get the text content of the urls
|
|
67
|
-
fetchResults: {
|
|
68
|
-
agent: "mapAgent",
|
|
69
|
-
inputs: {
|
|
70
|
-
rows: ":urls",
|
|
71
|
-
},
|
|
72
|
-
params: {
|
|
73
|
-
compositeResult: true,
|
|
74
|
-
},
|
|
75
|
-
graph: {
|
|
76
|
-
nodes: {
|
|
77
|
-
fetcher: {
|
|
78
|
-
agent: "browserlessAgent",
|
|
79
|
-
inputs: {
|
|
80
|
-
url: ":row",
|
|
81
|
-
text_content: true,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
copyAgent: {
|
|
85
|
-
agent: "copyAgent",
|
|
86
|
-
inputs: {
|
|
87
|
-
text: '{ url: "${:row}", text: "${:fetcher.text}" }',
|
|
88
|
-
},
|
|
89
|
-
params: {
|
|
90
|
-
namedKey: "text",
|
|
91
|
-
},
|
|
92
|
-
isResult: true,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
// join the text content
|
|
98
|
-
sourceText: {
|
|
99
|
-
agent: "arrayJoinAgent",
|
|
100
|
-
inputs: {
|
|
101
|
-
array: ":fetchResults.copyAgent",
|
|
102
|
-
},
|
|
103
|
-
params: {
|
|
104
|
-
separator: ",",
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
// generate the mulmo script
|
|
108
|
-
mulmoScript: {
|
|
109
|
-
agent: "nestedAgent",
|
|
110
|
-
inputs: {
|
|
111
|
-
sourceText: ":sourceText",
|
|
112
|
-
prompt: ":prompt",
|
|
113
|
-
},
|
|
114
|
-
graph: {
|
|
115
|
-
loop: {
|
|
116
|
-
// If the script is not valid and the counter is less than 3, continue the loop
|
|
117
|
-
while: ":continue",
|
|
118
|
-
},
|
|
119
|
-
nodes: {
|
|
120
|
-
counter: {
|
|
121
|
-
value: 0,
|
|
122
|
-
update: ":counter.add(1)",
|
|
123
|
-
},
|
|
124
|
-
openAIAgent: {
|
|
125
|
-
agent: "openAIAgent",
|
|
126
|
-
inputs: {
|
|
127
|
-
model: "gpt-4o",
|
|
128
|
-
system: ":prompt",
|
|
129
|
-
prompt: "Please create a script using the information from the following URLs as reference: ${:sourceText.text}",
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
validateMulmoScriptAgent: {
|
|
133
|
-
agent: "validateMulmoScriptAgent",
|
|
134
|
-
inputs: {
|
|
135
|
-
text: ":openAIAgent.text.codeBlock()",
|
|
136
|
-
},
|
|
137
|
-
isResult: true,
|
|
138
|
-
},
|
|
139
|
-
continue: {
|
|
140
|
-
agent: ({ isValid, counter }) => {
|
|
141
|
-
return !isValid && counter < 3;
|
|
142
|
-
},
|
|
143
|
-
inputs: {
|
|
144
|
-
isValid: ":validateMulmoScriptAgent.isValid",
|
|
145
|
-
counter: ":counter",
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
writeJSON: {
|
|
152
|
-
if: ":mulmoScript.validateMulmoScriptAgent.isValid",
|
|
153
|
-
agent: "fileWriteAgent",
|
|
154
|
-
inputs: {
|
|
155
|
-
file: "${:outdir}/${:fileName}-${@now}.json",
|
|
156
|
-
text: ":mulmoScript.validateMulmoScriptAgent.data.toJSON()",
|
|
157
|
-
},
|
|
158
|
-
isResult: true,
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
const createMulmoScriptFromUrl = async ({ urls, templateName, outDirPath, filename }) => {
|
|
163
|
-
(0, file_1.mkdir)(outDirPath);
|
|
164
|
-
const parsedUrls = schema_1.urlsSchema.parse(urls);
|
|
165
|
-
const graph = new graphai_1.GraphAI(graphData, {
|
|
166
|
-
...vanilla,
|
|
167
|
-
openAIAgent: openai_agent_1.openAIAgent,
|
|
168
|
-
browserlessAgent: browserless_agent_1.browserlessAgent,
|
|
169
|
-
validateMulmoScriptAgent: validate_mulmo_script_agent_1.default,
|
|
170
|
-
fileWriteAgent: vanilla_node_agents_1.fileWriteAgent,
|
|
171
|
-
});
|
|
172
|
-
graph.injectValue("urls", parsedUrls);
|
|
173
|
-
graph.injectValue("prompt", (0, file_1.readTemplatePrompt)(templateName));
|
|
174
|
-
graph.injectValue("outdir", outDirPath);
|
|
175
|
-
graph.injectValue("fileName", filename);
|
|
176
|
-
await graph.run();
|
|
177
|
-
};
|
|
178
|
-
exports.createMulmoScriptFromUrl = createMulmoScriptFromUrl;
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { GraphAI } from "graphai";
|
|
3
|
-
import { openAIAgent } from "@graphai/openai_agent";
|
|
4
|
-
import * as vanilla from "@graphai/vanilla";
|
|
5
|
-
import { fileWriteAgent } from "@graphai/vanilla_node_agents";
|
|
6
|
-
import { browserlessAgent } from "@graphai/browserless_agent";
|
|
7
|
-
import validateMulmoScriptAgent from "../agents/validate_mulmo_script_agent";
|
|
8
|
-
import { readTemplatePrompt, mkdir, writingMessage } from "../utils/file";
|
|
9
|
-
import { browserlessCacheGenerator } from "../utils/filters";
|
|
10
|
-
import { urlsSchema } from "../types/schema";
|
|
11
|
-
import { cliLoadingPlugin } from "../utils/plugins";
|
|
12
|
-
const graphData = {
|
|
13
|
-
version: 0.5,
|
|
14
|
-
// Execute sequentially because the free version of browserless API doesn't support concurrent execution.
|
|
15
|
-
concurrency: 1,
|
|
16
|
-
nodes: {
|
|
17
|
-
urls: {
|
|
18
|
-
value: [],
|
|
19
|
-
},
|
|
20
|
-
prompt: {
|
|
21
|
-
value: "",
|
|
22
|
-
},
|
|
23
|
-
outdir: {
|
|
24
|
-
value: "",
|
|
25
|
-
},
|
|
26
|
-
fileName: {
|
|
27
|
-
value: "",
|
|
28
|
-
},
|
|
29
|
-
fetchGraph: {
|
|
30
|
-
value: {
|
|
31
|
-
nodes: {
|
|
32
|
-
fetcher: {
|
|
33
|
-
agent: "browserlessAgent",
|
|
34
|
-
inputs: {
|
|
35
|
-
url: ":row",
|
|
36
|
-
text_content: true,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
copyAgent: {
|
|
40
|
-
agent: "copyAgent",
|
|
41
|
-
inputs: {
|
|
42
|
-
text: '{ url: "${:row}", text: "${:fetcher.text}" }',
|
|
43
|
-
},
|
|
44
|
-
params: {
|
|
45
|
-
namedKey: "text",
|
|
46
|
-
},
|
|
47
|
-
isResult: true,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
// get the text content of the urls
|
|
53
|
-
fetchResults: {
|
|
54
|
-
agent: "mapAgent",
|
|
55
|
-
inputs: {
|
|
56
|
-
rows: ":urls",
|
|
57
|
-
},
|
|
58
|
-
params: {
|
|
59
|
-
compositeResult: true,
|
|
60
|
-
},
|
|
61
|
-
graph: ":fetchGraph",
|
|
62
|
-
},
|
|
63
|
-
// join the text content
|
|
64
|
-
sourceText: {
|
|
65
|
-
agent: "arrayJoinAgent",
|
|
66
|
-
inputs: {
|
|
67
|
-
array: ":fetchResults.copyAgent",
|
|
68
|
-
},
|
|
69
|
-
params: {
|
|
70
|
-
separator: ",",
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
// generate the mulmo script
|
|
74
|
-
mulmoScript: {
|
|
75
|
-
agent: "nestedAgent",
|
|
76
|
-
inputs: {
|
|
77
|
-
sourceText: ":sourceText",
|
|
78
|
-
prompt: ":prompt",
|
|
79
|
-
},
|
|
80
|
-
graph: {
|
|
81
|
-
loop: {
|
|
82
|
-
// If the script is not valid and the counter is less than 3, continue the loop
|
|
83
|
-
while: ":continue",
|
|
84
|
-
},
|
|
85
|
-
nodes: {
|
|
86
|
-
counter: {
|
|
87
|
-
value: 0,
|
|
88
|
-
update: ":counter.add(1)",
|
|
89
|
-
},
|
|
90
|
-
openAIAgent: {
|
|
91
|
-
agent: "openAIAgent",
|
|
92
|
-
inputs: {
|
|
93
|
-
model: "gpt-4o",
|
|
94
|
-
system: ":prompt",
|
|
95
|
-
prompt: "Please create a script using the information from the following URLs as reference: ${:sourceText.text}",
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
validateMulmoScriptAgent: {
|
|
99
|
-
agent: "validateMulmoScriptAgent",
|
|
100
|
-
inputs: {
|
|
101
|
-
text: ":openAIAgent.text.codeBlock()",
|
|
102
|
-
},
|
|
103
|
-
isResult: true,
|
|
104
|
-
},
|
|
105
|
-
continue: {
|
|
106
|
-
agent: ({ isValid, counter }) => {
|
|
107
|
-
return !isValid && counter < 3;
|
|
108
|
-
},
|
|
109
|
-
inputs: {
|
|
110
|
-
isValid: ":validateMulmoScriptAgent.isValid",
|
|
111
|
-
counter: ":counter",
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
writeJSON: {
|
|
118
|
-
if: ":mulmoScript.validateMulmoScriptAgent.isValid",
|
|
119
|
-
agent: "fileWriteAgent",
|
|
120
|
-
inputs: {
|
|
121
|
-
file: "${:outdir}/${:fileName}-${@now}.json",
|
|
122
|
-
text: ":mulmoScript.validateMulmoScriptAgent.data.toJSON()",
|
|
123
|
-
},
|
|
124
|
-
isResult: true,
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
export const createMulmoScriptFromUrl = async ({ urls, templateName, outDirPath, filename, cacheDirPath }) => {
|
|
129
|
-
mkdir(outDirPath);
|
|
130
|
-
mkdir(cacheDirPath);
|
|
131
|
-
const parsedUrls = urlsSchema.parse(urls);
|
|
132
|
-
const browserlessCache = browserlessCacheGenerator(cacheDirPath);
|
|
133
|
-
const agentFilters = [
|
|
134
|
-
{
|
|
135
|
-
name: "browserlessCache",
|
|
136
|
-
agent: browserlessCache,
|
|
137
|
-
nodeIds: ["fetcher"],
|
|
138
|
-
},
|
|
139
|
-
];
|
|
140
|
-
const graph = new GraphAI(graphData, {
|
|
141
|
-
...vanilla,
|
|
142
|
-
openAIAgent,
|
|
143
|
-
browserlessAgent,
|
|
144
|
-
validateMulmoScriptAgent,
|
|
145
|
-
fileWriteAgent,
|
|
146
|
-
}, { agentFilters });
|
|
147
|
-
graph.injectValue("urls", parsedUrls);
|
|
148
|
-
graph.injectValue("prompt", readTemplatePrompt(templateName));
|
|
149
|
-
graph.injectValue("outdir", outDirPath);
|
|
150
|
-
graph.injectValue("fileName", filename);
|
|
151
|
-
graph.registerCallback(cliLoadingPlugin({ nodeId: "mulmoScript", message: "Generating script..." }));
|
|
152
|
-
const result = await graph.run();
|
|
153
|
-
writingMessage(result?.writeJSON?.path ?? "");
|
|
154
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { MulmoStudioBeat, MulmoStudioContext, MulmoCanvasDimension } from "../types/index.js";
|
|
2
|
-
type ImageProcessorParams = {
|
|
3
|
-
beat: MulmoStudioBeat;
|
|
4
|
-
context: MulmoStudioContext;
|
|
5
|
-
imagePath: string;
|
|
6
|
-
textSlideStyle: string;
|
|
7
|
-
canvasSize: MulmoCanvasDimension;
|
|
8
|
-
};
|
|
9
|
-
export declare const processTextSlide: (params: ImageProcessorParams) => Promise<void>;
|
|
10
|
-
export declare const processMarkdown: (params: ImageProcessorParams) => Promise<void>;
|
|
11
|
-
export declare const processImage: (params: ImageProcessorParams) => string | undefined;
|
|
12
|
-
export declare const processChart: (params: ImageProcessorParams) => Promise<void>;
|
|
13
|
-
export declare const processMermaid: (params: ImageProcessorParams) => Promise<void>;
|
|
14
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { MulmoStudioContextMethods } from "../methods/index.js";
|
|
2
|
-
import { getHTMLFile } from "./file.js";
|
|
3
|
-
import { renderMarkdownToImage, renderHTMLToImage, interpolate } from "./markdown.js";
|
|
4
|
-
export const processTextSlide = async (params) => {
|
|
5
|
-
const { beat, imagePath, textSlideStyle, canvasSize } = params;
|
|
6
|
-
if (!beat.image || beat.image.type !== "textSlide")
|
|
7
|
-
return;
|
|
8
|
-
const slide = beat.image.slide;
|
|
9
|
-
const markdown = `# ${slide.title}\n` + slide.bullets.map((text) => `- ${text}`).join("\n");
|
|
10
|
-
await renderMarkdownToImage(markdown, textSlideStyle, imagePath, canvasSize.width, canvasSize.height);
|
|
11
|
-
};
|
|
12
|
-
export const processMarkdown = async (params) => {
|
|
13
|
-
const { beat, imagePath, textSlideStyle, canvasSize } = params;
|
|
14
|
-
if (!beat.image || beat.image.type !== "markdown")
|
|
15
|
-
return;
|
|
16
|
-
const markdown = Array.isArray(beat.image.markdown) ? beat.image.markdown.join("\n") : beat.image.markdown;
|
|
17
|
-
await renderMarkdownToImage(markdown, textSlideStyle, imagePath, canvasSize.width, canvasSize.height);
|
|
18
|
-
};
|
|
19
|
-
export const processImage = (params) => {
|
|
20
|
-
const { beat, context } = params;
|
|
21
|
-
if (!beat.image || beat.image.type !== "image")
|
|
22
|
-
return;
|
|
23
|
-
if (beat.image.source.kind === "url") {
|
|
24
|
-
return beat.image.source.url;
|
|
25
|
-
}
|
|
26
|
-
else if (beat.image.source.kind === "path") {
|
|
27
|
-
return MulmoStudioContextMethods.resolveAssetPath(context, beat.image.source.path);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
export const processChart = async (params) => {
|
|
31
|
-
const { beat, imagePath, canvasSize } = params;
|
|
32
|
-
if (!beat.image || beat.image.type !== "chart")
|
|
33
|
-
return;
|
|
34
|
-
const template = getHTMLFile("chart");
|
|
35
|
-
const htmlData = interpolate(template, {
|
|
36
|
-
title: beat.image.title,
|
|
37
|
-
width: Math.round(canvasSize.width * 0.625).toString(),
|
|
38
|
-
chart_data: JSON.stringify(beat.image.chartData),
|
|
39
|
-
});
|
|
40
|
-
await renderHTMLToImage(htmlData, imagePath, canvasSize.width, canvasSize.height);
|
|
41
|
-
};
|
|
42
|
-
export const processMermaid = async (params) => {
|
|
43
|
-
const { beat, imagePath, canvasSize } = params;
|
|
44
|
-
if (!beat.image || beat.image.type !== "mermaid")
|
|
45
|
-
return;
|
|
46
|
-
const template = getHTMLFile("mermaid");
|
|
47
|
-
const htmlData = interpolate(template, {
|
|
48
|
-
title: beat.image.title,
|
|
49
|
-
diagram_code: beat.image.code,
|
|
50
|
-
});
|
|
51
|
-
await renderHTMLToImage(htmlData, imagePath, canvasSize.width, canvasSize.height);
|
|
52
|
-
};
|
package/lib/utils/text_hash.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const text2hash: (input: string) => string;
|
package/lib/utils/text_hash.js
DELETED