mulmocast 0.0.1 → 0.0.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.
Files changed (79) hide show
  1. package/README.md +108 -12
  2. package/assets/html/chart.html +47 -0
  3. package/assets/html/mermaid.html +63 -0
  4. package/assets/templates/business.json +60 -6
  5. package/assets/templates/children_book.json +1 -3
  6. package/assets/templates/coding.json +103 -0
  7. package/lib/actions/audio.d.ts +1 -1
  8. package/lib/actions/audio.js +52 -81
  9. package/lib/actions/images.d.ts +1 -1
  10. package/lib/actions/images.js +48 -80
  11. package/lib/actions/movie.d.ts +1 -1
  12. package/lib/actions/movie.js +76 -76
  13. package/lib/actions/translate.d.ts +1 -1
  14. package/lib/actions/translate.js +16 -52
  15. package/lib/agents/add_bgm_agent.d.ts +1 -1
  16. package/lib/agents/add_bgm_agent.js +10 -14
  17. package/lib/agents/combine_audio_files_agent.d.ts +1 -1
  18. package/lib/agents/combine_audio_files_agent.js +40 -30
  19. package/lib/agents/image_google_agent.d.ts +1 -1
  20. package/lib/agents/image_google_agent.js +8 -11
  21. package/lib/agents/image_openai_agent.js +7 -14
  22. package/lib/agents/index.d.ts +8 -8
  23. package/lib/agents/index.js +13 -30
  24. package/lib/agents/mulmo_prompts_agent.d.ts +1 -1
  25. package/lib/agents/mulmo_prompts_agent.js +7 -11
  26. package/lib/agents/prompts_data.js +1 -4
  27. package/lib/agents/tts_nijivoice_agent.d.ts +1 -1
  28. package/lib/agents/tts_nijivoice_agent.js +8 -12
  29. package/lib/agents/tts_openai_agent.js +9 -16
  30. package/lib/agents/validate_mulmo_script_agent.d.ts +1 -1
  31. package/lib/agents/validate_mulmo_script_agent.js +6 -10
  32. package/lib/cli/args.d.ts +2 -1
  33. package/lib/cli/args.js +16 -14
  34. package/lib/cli/cli.js +64 -49
  35. package/lib/cli/common.js +1 -5
  36. package/lib/cli/tool-args.d.ts +2 -1
  37. package/lib/cli/tool-args.js +19 -18
  38. package/lib/cli/tool-cli.js +32 -51
  39. package/lib/methods/index.d.ts +3 -3
  40. package/lib/methods/index.js +3 -19
  41. package/lib/methods/mulmo_script.d.ts +10 -5
  42. package/lib/methods/mulmo_script.js +17 -11
  43. package/lib/methods/mulmo_script_template.d.ts +1 -1
  44. package/lib/methods/mulmo_script_template.js +4 -10
  45. package/lib/methods/mulmo_studio_context.d.ts +1 -1
  46. package/lib/methods/mulmo_studio_context.js +3 -9
  47. package/lib/tools/create_mulmo_script_from_url.d.ts +3 -0
  48. package/lib/tools/create_mulmo_script_from_url.js +152 -0
  49. package/lib/tools/create_mulmo_script_interactively.d.ts +3 -0
  50. package/lib/tools/create_mulmo_script_interactively.js +217 -0
  51. package/lib/tools/dump_prompt.js +5 -8
  52. package/lib/tools/prompt.js +9 -11
  53. package/lib/tools/seed_from_url2.d.ts +3 -0
  54. package/lib/tools/seed_from_url2.js +154 -0
  55. package/lib/types/index.d.ts +1 -1
  56. package/lib/types/index.js +1 -17
  57. package/lib/types/schema.d.ts +433 -71
  58. package/lib/types/schema.js +126 -111
  59. package/lib/types/type.d.ts +7 -3
  60. package/lib/types/type.js +1 -2
  61. package/lib/utils/const.d.ts +2 -1
  62. package/lib/utils/const.js +4 -6
  63. package/lib/utils/file.d.ts +19 -4
  64. package/lib/utils/file.js +78 -71
  65. package/lib/utils/filters.d.ts +1 -0
  66. package/lib/utils/filters.js +47 -26
  67. package/lib/utils/image_preprocess.d.ts +14 -0
  68. package/lib/utils/image_preprocess.js +52 -0
  69. package/lib/utils/inquirer.d.ts +2 -0
  70. package/lib/utils/inquirer.js +33 -0
  71. package/lib/utils/markdown.d.ts +3 -1
  72. package/lib/utils/markdown.js +17 -19
  73. package/lib/utils/plugins.d.ts +5 -0
  74. package/lib/utils/plugins.js +11 -0
  75. package/lib/utils/preprocess.d.ts +24 -7
  76. package/lib/utils/preprocess.js +8 -14
  77. package/lib/utils/string.js +4 -10
  78. package/lib/utils/text_hash.js +2 -39
  79. package/package.json +12 -6
@@ -1,46 +1,11 @@
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.translate = void 0;
37
- require("dotenv/config");
38
- const graphai_1 = require("graphai");
39
- const agents = __importStar(require("@graphai/vanilla"));
40
- const openai_agent_1 = require("@graphai/openai_agent");
41
- const vanilla_node_agents_1 = require("@graphai/vanilla_node_agents");
42
- const string_1 = require("../utils/string");
43
- const file_1 = require("../utils/file");
1
+ import "dotenv/config";
2
+ import { GraphAI, assert } from "graphai";
3
+ import * as agents from "@graphai/vanilla";
4
+ import { openAIAgent } from "@graphai/openai_agent";
5
+ import { fileWriteAgent } from "@graphai/vanilla_node_agents";
6
+ import { recursiveSplitJa, replacementsJa, replacePairsJa } from "../utils/string.js";
7
+ import { getOutputStudioFilePath, mkdir, writingMessage } from "../utils/file.js";
8
+ const { default: __, ...vanillaAgents } = agents;
44
9
  const translateGraph = {
45
10
  version: 0.5,
46
11
  nodes: {
@@ -118,7 +83,7 @@ const translateGraph = {
118
83
  if (targetLang === "ja") {
119
84
  return {
120
85
  ...localizedText,
121
- texts: (0, string_1.recursiveSplitJa)(localizedText.text),
86
+ texts: recursiveSplitJa(localizedText.text),
122
87
  };
123
88
  }
124
89
  // not split
@@ -143,7 +108,7 @@ const translateGraph = {
143
108
  if (targetLang === "ja") {
144
109
  return {
145
110
  ...localizedText,
146
- ttsTexts: localizedText?.texts?.map((text) => (0, string_1.replacePairsJa)(text, string_1.replacementsJa)),
111
+ ttsTexts: localizedText?.texts?.map((text) => replacePairsJa(text, replacementsJa)),
147
112
  };
148
113
  }
149
114
  return {
@@ -215,22 +180,21 @@ const agentFilters = [
215
180
  ];
216
181
  const defaultLang = "en";
217
182
  const targetLangs = ["ja", "en"];
218
- const translate = async (context) => {
183
+ export const translate = async (context) => {
219
184
  const { studio, fileDirs } = context;
220
185
  const { outDirPath } = fileDirs;
221
- const outputStudioFilePath = (0, file_1.getOutputStudioFilePath)(outDirPath, studio.filename);
222
- (0, file_1.mkdir)(outDirPath);
223
- (0, graphai_1.assert)(!!process.env.OPENAI_API_KEY, "The OPENAI_API_KEY environment variable is missing or empty");
224
- const graph = new graphai_1.GraphAI(translateGraph, { ...agents, fileWriteAgent: vanilla_node_agents_1.fileWriteAgent, openAIAgent: openai_agent_1.openAIAgent }, { agentFilters });
186
+ const outputStudioFilePath = getOutputStudioFilePath(outDirPath, studio.filename);
187
+ mkdir(outDirPath);
188
+ assert(!!process.env.OPENAI_API_KEY, "The OPENAI_API_KEY environment variable is missing or empty");
189
+ const graph = new GraphAI(translateGraph, { ...vanillaAgents, fileWriteAgent, openAIAgent }, { agentFilters });
225
190
  graph.injectValue("studio", studio);
226
191
  graph.injectValue("defaultLang", defaultLang);
227
192
  graph.injectValue("targetLangs", targetLangs);
228
193
  graph.injectValue("outDirPath", outDirPath);
229
194
  graph.injectValue("outputStudioFilePath", outputStudioFilePath);
230
195
  await graph.run();
231
- (0, file_1.writingMessage)(outputStudioFilePath);
196
+ writingMessage(outputStudioFilePath);
232
197
  // const results = await graph.run();
233
198
  // const mulmoDataResult = results.mergeResult;
234
199
  // console.log(JSON.stringify(mulmoDataResult, null, 2));
235
200
  };
236
- exports.translate = translate;
@@ -1,3 +1,3 @@
1
- import { AgentFunctionInfo } from "graphai";
1
+ import type { AgentFunctionInfo } from "graphai";
2
2
  declare const addBGMAgentInfo: AgentFunctionInfo;
3
3
  export default addBGMAgentInfo;
@@ -1,24 +1,20 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fluent_ffmpeg_1 = __importDefault(require("fluent-ffmpeg"));
7
- const methods_1 = require("../methods");
1
+ import { GraphAILogger } from "graphai";
2
+ import ffmpeg from "fluent-ffmpeg";
3
+ import { MulmoScriptMethods } from "../methods/index.js";
8
4
  const addBGMAgent = async ({ namedInputs, params, }) => {
9
5
  const { voiceFile, outputFile, script } = namedInputs;
10
6
  const { musicFile } = params;
11
7
  const promise = new Promise((resolve, reject) => {
12
- fluent_ffmpeg_1.default.ffprobe(voiceFile, (err, metadata) => {
8
+ ffmpeg.ffprobe(voiceFile, (err, metadata) => {
13
9
  if (err) {
14
- console.error("Error getting metadata: " + err.message);
10
+ GraphAILogger.info("Error getting metadata: " + err.message);
15
11
  reject(err);
16
12
  }
17
13
  const speechDuration = metadata.format.duration;
18
- const padding = methods_1.MulmoScriptMethods.getPadding(script);
14
+ const padding = MulmoScriptMethods.getPadding(script);
19
15
  const totalDuration = (padding * 2) / 1000 + Math.round(speechDuration ?? 0);
20
- console.log("totalDucation:", speechDuration, totalDuration);
21
- const command = (0, fluent_ffmpeg_1.default)();
16
+ GraphAILogger.log("totalDucation:", speechDuration, totalDuration);
17
+ const command = ffmpeg();
22
18
  command
23
19
  .input(musicFile)
24
20
  .input(voiceFile)
@@ -35,7 +31,7 @@ const addBGMAgent = async ({ namedInputs, params, }) => {
35
31
  `[trimmed]afade=t=out:st=${totalDuration - padding / 1000}:d=${padding}`,
36
32
  ])
37
33
  .on("error", (err) => {
38
- console.error("Error: " + err.message);
34
+ GraphAILogger.info("Error: " + err.message);
39
35
  reject(err);
40
36
  })
41
37
  .on("end", () => {
@@ -58,4 +54,4 @@ const addBGMAgentInfo = {
58
54
  repository: "https://github.com/snakajima/ai-podcaster",
59
55
  license: "MIT",
60
56
  };
61
- exports.default = addBGMAgentInfo;
57
+ export default addBGMAgentInfo;
@@ -1,3 +1,3 @@
1
- import { AgentFunctionInfo } from "graphai";
1
+ import type { AgentFunctionInfo } from "graphai";
2
2
  declare const combineAudioFilesAgentInfo: AgentFunctionInfo;
3
3
  export default combineAudioFilesAgentInfo;
@@ -1,44 +1,54 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fluent_ffmpeg_1 = __importDefault(require("fluent-ffmpeg"));
7
- const file_1 = require("../utils/file");
8
- const methods_1 = require("../methods");
1
+ import { GraphAILogger } from "graphai";
2
+ import ffmpeg from "fluent-ffmpeg";
3
+ import { silentPath, silentLastPath, getAudioSegmentFilePath } from "../utils/file.js";
4
+ import { MulmoStudioContextMethods } from "../methods/index.js";
9
5
  const combineAudioFilesAgent = async ({ namedInputs }) => {
10
- const { context, combinedFileName, scratchpadDirPath } = namedInputs;
11
- const command = (0, fluent_ffmpeg_1.default)();
12
- context.studio.beats.forEach((mulmoBeat, index) => {
13
- const audioPath = mulmoBeat.audio?.type === "audio" &&
14
- ((mulmoBeat.audio?.source.kind === "path" && methods_1.MulmoStudioContextMethods.resolveAssetPath(context, mulmoBeat.audio.source.path)) ||
15
- (mulmoBeat.audio?.source.kind === "url" && mulmoBeat.audio.source.url));
16
- const filePath = audioPath || (0, file_1.getScratchpadFilePath)(scratchpadDirPath, mulmoBeat.audioFile ?? "");
6
+ const { context, combinedFileName, audioDirPath } = namedInputs;
7
+ const command = ffmpeg();
8
+ const getDuration = (filePath, isLast) => {
9
+ return new Promise((resolve, reject) => {
10
+ ffmpeg.ffprobe(filePath, (err, metadata) => {
11
+ if (err) {
12
+ GraphAILogger.info("Error while getting metadata:", err);
13
+ reject(err);
14
+ }
15
+ else {
16
+ resolve(metadata.format.duration + (isLast ? 0.8 : 0.3));
17
+ }
18
+ });
19
+ });
20
+ };
21
+ const resolveAudioFilePath = (context, mulmoBeat, audioDirPath) => {
22
+ if (mulmoBeat.audio?.type === "audio") {
23
+ const { source } = mulmoBeat.audio;
24
+ if (source.kind === "path") {
25
+ return MulmoStudioContextMethods.resolveAssetPath(context, source.path);
26
+ }
27
+ if (source.kind === "url") {
28
+ return source.url;
29
+ }
30
+ }
31
+ return getAudioSegmentFilePath(audioDirPath, context.studio.filename, mulmoBeat.audioFile ?? "");
32
+ };
33
+ await Promise.all(context.studio.beats.map(async (mulmoBeat, index) => {
34
+ const filePath = resolveAudioFilePath(context, mulmoBeat, audioDirPath);
17
35
  const isLast = index === context.studio.beats.length - 2;
18
36
  command.input(filePath);
19
- command.input(isLast ? file_1.silentLastPath : file_1.silentPath);
37
+ command.input(isLast ? silentLastPath : silentPath);
20
38
  // Measure and log the timestamp of each section
21
- fluent_ffmpeg_1.default.ffprobe(filePath, (err, metadata) => {
22
- if (err) {
23
- console.error("Error while getting metadata:", err);
24
- }
25
- else {
26
- context.studio.beats[index]["duration"] = metadata.format.duration + (isLast ? 0.8 : 0.3);
27
- }
28
- });
29
- });
30
- const promise = new Promise((resolve, reject) => {
39
+ context.studio.beats[index]["duration"] = await getDuration(filePath, isLast);
40
+ }));
41
+ await new Promise((resolve, reject) => {
31
42
  command
32
43
  .on("end", () => {
33
44
  resolve(0);
34
45
  })
35
46
  .on("error", (err) => {
36
- console.error("Error while combining MP3 files:", err);
47
+ GraphAILogger.info("Error while combining MP3 files:", err);
37
48
  reject(err);
38
49
  })
39
- .mergeToFile(combinedFileName, scratchpadDirPath);
50
+ .mergeToFile(combinedFileName, audioDirPath);
40
51
  });
41
- await promise;
42
52
  return {
43
53
  studio: context.studio,
44
54
  };
@@ -54,4 +64,4 @@ const combineAudioFilesAgentInfo = {
54
64
  repository: "https://github.com/snakajima/ai-podcaster",
55
65
  license: "MIT",
56
66
  };
57
- exports.default = combineAudioFilesAgentInfo;
67
+ export default combineAudioFilesAgentInfo;
@@ -1,4 +1,4 @@
1
- import { AgentFunction, AgentFunctionInfo } from "graphai";
1
+ import type { AgentFunction, AgentFunctionInfo } from "graphai";
2
2
  export type ImageGoogleConfig = {
3
3
  projectId?: string;
4
4
  token?: string;
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.imageGoogleAgent = void 0;
1
+ import { GraphAILogger } from "graphai";
4
2
  async function generateImage(projectId, model, token, prompt, aspectRatio) {
5
3
  const GOOGLE_IMAGEN_ENDPOINT = `https://us-central1-aiplatform.googleapis.com/v1/projects/${projectId}/locations/us-central1/publishers/google/models/${model}:predict`;
6
4
  try {
@@ -43,16 +41,16 @@ async function generateImage(projectId, model, token, prompt, aspectRatio) {
43
41
  }
44
42
  else {
45
43
  // console.log(response);
46
- console.log("No predictions returned from the API.", responseData, prompt);
44
+ GraphAILogger.info("No predictions returned from the API.", responseData, prompt);
47
45
  return undefined;
48
46
  }
49
47
  }
50
48
  catch (error) {
51
- console.error("Error generating image:", error);
49
+ GraphAILogger.info("Error generating image:", error);
52
50
  throw error;
53
51
  }
54
52
  }
55
- const imageGoogleAgent = async ({ namedInputs, params, config, }) => {
53
+ export const imageGoogleAgent = async ({ namedInputs, params, config, }) => {
56
54
  const { prompt } = namedInputs;
57
55
  const aspectRatio = params.aspectRatio ?? "16:9";
58
56
  const model = params.model ?? "imagen-3.0-fast-generate-001";
@@ -67,15 +65,14 @@ const imageGoogleAgent = async ({ namedInputs, params, config, }) => {
67
65
  throw new Error("ERROR: geneateImage returned undefined");
68
66
  }
69
67
  catch (error) {
70
- console.error("Failed to generate image:", error);
68
+ GraphAILogger.info("Failed to generate image:", error);
71
69
  throw error;
72
70
  }
73
71
  };
74
- exports.imageGoogleAgent = imageGoogleAgent;
75
72
  const imageGoogleAgentInfo = {
76
73
  name: "imageGoogleAgent",
77
- agent: exports.imageGoogleAgent,
78
- mock: exports.imageGoogleAgent,
74
+ agent: imageGoogleAgent,
75
+ mock: imageGoogleAgent,
79
76
  samples: [],
80
77
  description: "Google Image agent",
81
78
  category: ["image"],
@@ -85,4 +82,4 @@ const imageGoogleAgentInfo = {
85
82
  license: "MIT",
86
83
  environmentVariables: [],
87
84
  };
88
- exports.default = imageGoogleAgentInfo;
85
+ export default imageGoogleAgentInfo;
@@ -1,20 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.imageOpenaiAgent = void 0;
7
- const openai_1 = __importDefault(require("openai"));
1
+ import OpenAI from "openai";
8
2
  // https://platform.openai.com/docs/guides/image-generation
9
- const imageOpenaiAgent = async ({ namedInputs, params }) => {
3
+ export const imageOpenaiAgent = async ({ namedInputs, params }) => {
10
4
  const { prompt } = namedInputs;
11
5
  const { apiKey, model, size, moderation } = params;
12
- const openai = new openai_1.default({ apiKey });
6
+ const openai = new OpenAI({ apiKey });
13
7
  const imageOptions = {
14
8
  model: model ?? "dall-e-3",
15
9
  prompt,
16
10
  n: 1,
17
- size: size || "1792x1024",
11
+ size: size || model === "gpt-image-1" ? "1536x1024" : "1792x1024",
18
12
  };
19
13
  if (model === "gpt-image-1") {
20
14
  imageOptions.moderation = moderation || "auto";
@@ -42,11 +36,10 @@ const imageOpenaiAgent = async ({ namedInputs, params }) => {
42
36
  // 3. Convert the ArrayBuffer to a Node.js Buffer and return it along with url
43
37
  return { buffer: Buffer.from(arrayBuffer) };
44
38
  };
45
- exports.imageOpenaiAgent = imageOpenaiAgent;
46
39
  const imageOpenaiAgentInfo = {
47
40
  name: "imageOpenaiAgent",
48
- agent: exports.imageOpenaiAgent,
49
- mock: exports.imageOpenaiAgent,
41
+ agent: imageOpenaiAgent,
42
+ mock: imageOpenaiAgent,
50
43
  samples: [],
51
44
  description: "OpenAI Image agent",
52
45
  category: ["image"],
@@ -56,4 +49,4 @@ const imageOpenaiAgentInfo = {
56
49
  license: "MIT",
57
50
  environmentVariables: ["OPENAI_API_KEY"],
58
51
  };
59
- exports.default = imageOpenaiAgentInfo;
52
+ export default imageOpenaiAgentInfo;
@@ -1,11 +1,11 @@
1
- import addBGMAgent from "./add_bgm_agent";
2
- import combineAudioFilesAgent from "./combine_audio_files_agent";
3
- import imageGoogleAgent from "./image_google_agent";
4
- import imageOpenaiAgent from "./image_openai_agent";
5
- import mulmoPromptsAgent from "./mulmo_prompts_agent";
6
- import ttsNijivoiceAgent from "./tts_nijivoice_agent";
7
- import ttsOpenaiAgent from "./tts_openai_agent";
8
- import validateMulmoScriptAgent from "./validate_mulmo_script_agent";
1
+ import addBGMAgent from "./add_bgm_agent.js";
2
+ import combineAudioFilesAgent from "./combine_audio_files_agent.js";
3
+ import imageGoogleAgent from "./image_google_agent.js";
4
+ import imageOpenaiAgent from "./image_openai_agent.js";
5
+ import mulmoPromptsAgent from "./mulmo_prompts_agent.js";
6
+ import ttsNijivoiceAgent from "./tts_nijivoice_agent.js";
7
+ import ttsOpenaiAgent from "./tts_openai_agent.js";
8
+ import validateMulmoScriptAgent from "./validate_mulmo_script_agent.js";
9
9
  import { browserlessAgent } from "@graphai/browserless_agent";
10
10
  import { textInputAgent } from "@graphai/input_agents";
11
11
  import { openAIAgent } from "@graphai/openai_agent";
@@ -1,31 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateMulmoScriptAgent = exports.ttsOpenaiAgent = exports.ttsNijivoiceAgent = exports.mulmoPromptsAgent = exports.imageOpenaiAgent = exports.imageGoogleAgent = exports.combineAudioFilesAgent = exports.addBGMAgent = exports.textInputAgent = exports.browserlessAgent = exports.fileWriteAgent = exports.openAIAgent = void 0;
7
- const add_bgm_agent_1 = __importDefault(require("./add_bgm_agent"));
8
- exports.addBGMAgent = add_bgm_agent_1.default;
9
- const combine_audio_files_agent_1 = __importDefault(require("./combine_audio_files_agent"));
10
- exports.combineAudioFilesAgent = combine_audio_files_agent_1.default;
11
- const image_google_agent_1 = __importDefault(require("./image_google_agent"));
12
- exports.imageGoogleAgent = image_google_agent_1.default;
13
- const image_openai_agent_1 = __importDefault(require("./image_openai_agent"));
14
- exports.imageOpenaiAgent = image_openai_agent_1.default;
15
- const mulmo_prompts_agent_1 = __importDefault(require("./mulmo_prompts_agent"));
16
- exports.mulmoPromptsAgent = mulmo_prompts_agent_1.default;
17
- const tts_nijivoice_agent_1 = __importDefault(require("./tts_nijivoice_agent"));
18
- exports.ttsNijivoiceAgent = tts_nijivoice_agent_1.default;
19
- const tts_openai_agent_1 = __importDefault(require("./tts_openai_agent"));
20
- exports.ttsOpenaiAgent = tts_openai_agent_1.default;
21
- const validate_mulmo_script_agent_1 = __importDefault(require("./validate_mulmo_script_agent"));
22
- exports.validateMulmoScriptAgent = validate_mulmo_script_agent_1.default;
23
- const browserless_agent_1 = require("@graphai/browserless_agent");
24
- Object.defineProperty(exports, "browserlessAgent", { enumerable: true, get: function () { return browserless_agent_1.browserlessAgent; } });
25
- const input_agents_1 = require("@graphai/input_agents");
26
- Object.defineProperty(exports, "textInputAgent", { enumerable: true, get: function () { return input_agents_1.textInputAgent; } });
27
- const openai_agent_1 = require("@graphai/openai_agent");
28
- Object.defineProperty(exports, "openAIAgent", { enumerable: true, get: function () { return openai_agent_1.openAIAgent; } });
1
+ import addBGMAgent from "./add_bgm_agent.js";
2
+ import combineAudioFilesAgent from "./combine_audio_files_agent.js";
3
+ import imageGoogleAgent from "./image_google_agent.js";
4
+ import imageOpenaiAgent from "./image_openai_agent.js";
5
+ import mulmoPromptsAgent from "./mulmo_prompts_agent.js";
6
+ import ttsNijivoiceAgent from "./tts_nijivoice_agent.js";
7
+ import ttsOpenaiAgent from "./tts_openai_agent.js";
8
+ import validateMulmoScriptAgent from "./validate_mulmo_script_agent.js";
9
+ import { browserlessAgent } from "@graphai/browserless_agent";
10
+ import { textInputAgent } from "@graphai/input_agents";
11
+ import { openAIAgent } from "@graphai/openai_agent";
29
12
  // import * as vanilla from "@graphai/vanilla";
30
- const vanilla_node_agents_1 = require("@graphai/vanilla_node_agents");
31
- Object.defineProperty(exports, "fileWriteAgent", { enumerable: true, get: function () { return vanilla_node_agents_1.fileWriteAgent; } });
13
+ import { fileWriteAgent } from "@graphai/vanilla_node_agents";
14
+ export { openAIAgent, fileWriteAgent, browserlessAgent, textInputAgent, addBGMAgent, combineAudioFilesAgent, imageGoogleAgent, imageOpenaiAgent, mulmoPromptsAgent, ttsNijivoiceAgent, ttsOpenaiAgent, validateMulmoScriptAgent, };
@@ -1,5 +1,5 @@
1
1
  import { AgentFunction, AgentFunctionInfo } from "graphai";
2
- import { prompts } from "./prompts_data";
2
+ import { prompts } from "./prompts_data.js";
3
3
  export declare const mulmoPromptsAgent: AgentFunction<{
4
4
  promptKey: keyof typeof prompts;
5
5
  }>;
@@ -1,24 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mulmoPromptsAgent = void 0;
4
- const prompts_data_1 = require("./prompts_data");
5
- const mulmoPromptsAgent = async ({ params }) => {
1
+ import { prompts } from "./prompts_data.js";
2
+ export const mulmoPromptsAgent = async ({ params }) => {
6
3
  const { promptKey } = params;
7
4
  if (promptKey) {
8
- const prompt = prompts_data_1.prompts[promptKey];
5
+ const prompt = prompts[promptKey];
9
6
  if (prompt) {
10
7
  return {
11
8
  text: prompt,
12
9
  };
13
10
  }
14
11
  }
15
- return prompts_data_1.prompts;
12
+ return prompts;
16
13
  };
17
- exports.mulmoPromptsAgent = mulmoPromptsAgent;
18
14
  const mulmoPromptsAgentInfo = {
19
15
  name: "mulmoPromptsAgent",
20
- agent: exports.mulmoPromptsAgent,
21
- mock: exports.mulmoPromptsAgent,
16
+ agent: mulmoPromptsAgent,
17
+ mock: mulmoPromptsAgent,
22
18
  samples: [
23
19
  {
24
20
  inputs: {},
@@ -38,4 +34,4 @@ const mulmoPromptsAgentInfo = {
38
34
  // package: "@graphai/prompts",
39
35
  license: "MIT",
40
36
  };
41
- exports.default = mulmoPromptsAgentInfo;
37
+ export default mulmoPromptsAgentInfo;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prompts = void 0;
4
1
  // This file is auto-generated by src/tools/prompt.ts and Do not be edited manually.
5
- exports.prompts = {
2
+ export const prompts = {
6
3
  abstract: "We need to add a summary at the beginning of script, which summarizes this episode, which is very engaging. Please come up with a few sentences for the announcer to read, enter them into this script, and present it as an artifact.",
7
4
  image_prompt: 'We need to generate a series of images for this podcast. For each line of given json, generate an appropriate text prompt for text-2-image AI, considering the flow of whole discussion and add it as "imagePrompt" property to the script. We don\'t want to show student, teacher or classroom in the image. Do not eliminate any lines.\n\n[Examples]\nA modern tech conference stage with a speaker discussing AI advancements, futuristic lighting and a large digital screen displaying AI-related graphics.\nA close-up of an AI executive speaking at a press conference, with a backdrop displaying AI chip designs and a world map.\nA futuristic AI research lab with glowing blue data streams and a large AI model being visualized on a digital display.\nA high-tech meeting room with analysts discussing global AI trends, holographic charts displaying AI development.\nA balanced scale with AI progress on one side and economic factors on the other, symbolizing analysis and perspective.\nA newspaper headline about a breakthrough in AI technology, with digital code overlaying the article.\nA timeline showing the gradual evolution of AI models, with key milestones highlighted.\n',
8
5
  prompt: 'generate a podcast script based on this topic in the JSON format using the opening statement below. Monologue by the Host. Complete story.\nClearly mention the news source.\nNews source:\nArticle url: ...\n\n```json\n{\n "title": "(title of this episode)",\n "description": "(short description of this episode)",\n "reference": "(url to the article)",\n "tts": "openAI", // or "nijivoice", default is "openAI"\n "speakers": {\n "Host": {\n "voiceId": "shimmer",\n "displayName": {\n "en": "Host"\n }\n },\n },\n "beats": [\n {\n "speaker": "Host",\n "text": "Hello and welcome to another episode of \'life is artificial\', where we explore the cutting edge of technology, innovation, and what the future could look like.",\n },\n {\n "speaker": "Host",\n "text": "Today, ...",\n },\n ...\n ]\n}\n```\n\n',
@@ -1,4 +1,4 @@
1
- import { AgentFunction, AgentFunctionInfo } from "graphai";
1
+ import type { AgentFunction, AgentFunctionInfo } from "graphai";
2
2
  export declare const ttsNijivoiceAgent: AgentFunction;
3
3
  declare const ttsNijivoiceAgentInfo: AgentFunctionInfo;
4
4
  export default ttsNijivoiceAgentInfo;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ttsNijivoiceAgent = void 0;
4
- const graphai_1 = require("graphai");
1
+ import { GraphAILogger, assert } from "graphai";
5
2
  const nijovoiceApiKey = process.env.NIJIVOICE_API_KEY ?? "";
6
3
  const errorMessage = [
7
4
  "TTS NijiVoice: No API key. ",
@@ -9,10 +6,10 @@ const errorMessage = [
9
6
  "1. Obtain an API key from Niji Voice (https://platform.nijivoice.com/) and set it as the NIJIVOICE_API_KEY environment variable.",
10
7
  '2. Use OpenAI\'s TTS instead of Niji Voice by changing speechParams.provider from "nijivoice" to "openai".',
11
8
  ].join("\n");
12
- const ttsNijivoiceAgent = async ({ params, namedInputs }) => {
9
+ export const ttsNijivoiceAgent = async ({ params, namedInputs }) => {
13
10
  const { apiKey, suppressError, voice, speed, speed_global } = params;
14
11
  const { text } = namedInputs;
15
- (0, graphai_1.assert)(apiKey ?? nijovoiceApiKey, errorMessage);
12
+ assert(apiKey ?? nijovoiceApiKey, errorMessage);
16
13
  const url = `https://api.nijivoice.com/api/platform/v1/voice-actors/${voice}/generate-voice`;
17
14
  const options = {
18
15
  method: "POST",
@@ -40,7 +37,7 @@ const ttsNijivoiceAgent = async ({ params, namedInputs }) => {
40
37
  error: voiceJson,
41
38
  };
42
39
  }
43
- console.error(voiceJson);
40
+ GraphAILogger.info(voiceJson);
44
41
  throw new Error("TTS Nijivoice Error");
45
42
  }
46
43
  catch (e) {
@@ -49,15 +46,14 @@ const ttsNijivoiceAgent = async ({ params, namedInputs }) => {
49
46
  error: e,
50
47
  };
51
48
  }
52
- console.error(e);
49
+ GraphAILogger.info(e);
53
50
  throw new Error("TTS Nijivoice Error");
54
51
  }
55
52
  };
56
- exports.ttsNijivoiceAgent = ttsNijivoiceAgent;
57
53
  const ttsNijivoiceAgentInfo = {
58
54
  name: "ttsNijivoiceAgent",
59
- agent: exports.ttsNijivoiceAgent,
60
- mock: exports.ttsNijivoiceAgent,
55
+ agent: ttsNijivoiceAgent,
56
+ mock: ttsNijivoiceAgent,
61
57
  samples: [],
62
58
  description: "TTS nijivoice agent",
63
59
  category: ["tts"],
@@ -65,4 +61,4 @@ const ttsNijivoiceAgentInfo = {
65
61
  repository: "https://github.com/receptron/graphai/",
66
62
  license: "MIT",
67
63
  };
68
- exports.default = ttsNijivoiceAgentInfo;
64
+ export default ttsNijivoiceAgentInfo;
@@ -1,15 +1,9 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ttsOpenaiAgent = void 0;
7
- const graphai_1 = require("graphai");
8
- const openai_1 = __importDefault(require("openai"));
9
- const ttsOpenaiAgent = async ({ namedInputs, params }) => {
1
+ import { GraphAILogger } from "graphai";
2
+ import OpenAI from "openai";
3
+ export const ttsOpenaiAgent = async ({ namedInputs, params }) => {
10
4
  const { text } = namedInputs;
11
5
  const { apiKey, model, voice, suppressError, instructions } = params;
12
- const openai = new openai_1.default({ apiKey });
6
+ const openai = new OpenAI({ apiKey });
13
7
  try {
14
8
  const tts_options = {
15
9
  model: model ?? "gpt-4o-mini-tts", // "tts-1",
@@ -19,7 +13,7 @@ const ttsOpenaiAgent = async ({ namedInputs, params }) => {
19
13
  if (instructions) {
20
14
  tts_options["instructions"] = instructions;
21
15
  }
22
- graphai_1.GraphAILogger.log("ttsOptions", tts_options);
16
+ GraphAILogger.log("ttsOptions", tts_options);
23
17
  const response = await openai.audio.speech.create(tts_options);
24
18
  const buffer = Buffer.from(await response.arrayBuffer());
25
19
  return { buffer };
@@ -30,15 +24,14 @@ const ttsOpenaiAgent = async ({ namedInputs, params }) => {
30
24
  error: e,
31
25
  };
32
26
  }
33
- console.error(e);
27
+ GraphAILogger.info(e);
34
28
  throw new Error("TTS OpenAI Error");
35
29
  }
36
30
  };
37
- exports.ttsOpenaiAgent = ttsOpenaiAgent;
38
31
  const ttsOpenaiAgentInfo = {
39
32
  name: "ttsOpenaiAgent",
40
- agent: exports.ttsOpenaiAgent,
41
- mock: exports.ttsOpenaiAgent,
33
+ agent: ttsOpenaiAgent,
34
+ mock: ttsOpenaiAgent,
42
35
  samples: [],
43
36
  description: "OpenAI TTS agent",
44
37
  category: ["tts"],
@@ -47,4 +40,4 @@ const ttsOpenaiAgentInfo = {
47
40
  license: "MIT",
48
41
  environmentVariables: ["OPENAI_API_KEY"],
49
42
  };
50
- exports.default = ttsOpenaiAgentInfo;
43
+ export default ttsOpenaiAgentInfo;
@@ -1,5 +1,5 @@
1
1
  import type { AgentFunction, AgentFunctionInfo, DefaultConfigData } from "graphai";
2
- import { MulmoScript } from "../types";
2
+ import { MulmoScript } from "../types/index.js";
3
3
  interface ValidateMulmoScriptInputs {
4
4
  text: string;
5
5
  }