mulmocast 2.6.10 → 2.6.11-experimental.0
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/agents/image_openai_agent.d.ts +1 -0
- package/lib/agents/image_openai_agent.js +15 -3
- package/lib/methods/mulmo_presentation_style.js +2 -3
- package/lib/types/provider2agent.d.ts +5 -0
- package/lib/types/provider2agent.js +6 -1
- package/lib/utils/ffmpeg_utils.d.ts +4 -2
- package/lib/utils/ffmpeg_utils.js +1 -1
- package/package.json +11 -12
- package/scripts/test/test_images.json +2 -2
- package/scripts/test/test_images_dalle_deprecated.json +27 -0
- package/scripts/test/test_movie.json +1 -1
- package/scripts/test/test_movie_dalle_deprecated.json +26 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AgentFunction, AgentFunctionInfo } from "graphai";
|
|
2
2
|
import type { AgentBufferResult, OpenAIImageAgentParams, OpenAIImageAgentInputs, OpenAIImageAgentConfig } from "../types/agent.js";
|
|
3
|
+
export declare const buildDeprecatedModelMessage: (model: string) => string | null;
|
|
3
4
|
export declare const imageOpenaiAgent: AgentFunction<OpenAIImageAgentParams, AgentBufferResult, OpenAIImageAgentInputs, OpenAIImageAgentConfig>;
|
|
4
5
|
declare const imageOpenaiAgentInfo: AgentFunctionInfo;
|
|
5
6
|
export default imageOpenaiAgentInfo;
|
|
@@ -3,8 +3,14 @@ import path from "path";
|
|
|
3
3
|
import { GraphAILogger } from "graphai";
|
|
4
4
|
import { toFile, AuthenticationError, RateLimitError, APIError } from "openai";
|
|
5
5
|
import { createOpenAIClient } from "../utils/openai_client.js";
|
|
6
|
-
import { provider2ImageAgent, gptImages } from "../types/provider2agent.js";
|
|
7
|
-
import { apiKeyMissingError, agentGenerationError, openAIAgentGenerationError, agentIncorrectAPIKeyError, agentAPIRateLimitError, agentInvalidResponseError, imageAction, imageFileTarget, } from "../utils/error_cause.js";
|
|
6
|
+
import { provider2ImageAgent, gptImages, deprecatedOpenAIImageModelHints } from "../types/provider2agent.js";
|
|
7
|
+
import { apiKeyMissingError, agentGenerationError, openAIAgentGenerationError, agentIncorrectAPIKeyError, agentAPIRateLimitError, agentInvalidResponseError, imageAction, imageFileTarget, unsupportedModelTarget, } from "../utils/error_cause.js";
|
|
8
|
+
const isDeprecatedOpenAIImageModel = (model) => model in deprecatedOpenAIImageModelHints;
|
|
9
|
+
export const buildDeprecatedModelMessage = (model) => {
|
|
10
|
+
if (!isDeprecatedOpenAIImageModel(model))
|
|
11
|
+
return null;
|
|
12
|
+
return `OpenAI image model "${model}" is no longer available. ${deprecatedOpenAIImageModelHints[model]}`;
|
|
13
|
+
};
|
|
8
14
|
// https://platform.openai.com/docs/guides/image-generation
|
|
9
15
|
export const imageOpenaiAgent = async ({ namedInputs, params, config, }) => {
|
|
10
16
|
const { prompt, referenceImages } = namedInputs;
|
|
@@ -16,6 +22,12 @@ export const imageOpenaiAgent = async ({ namedInputs, params, config, }) => {
|
|
|
16
22
|
});
|
|
17
23
|
}
|
|
18
24
|
const model = params.model ?? provider2ImageAgent["openai"].defaultModel;
|
|
25
|
+
const deprecatedMessage = buildDeprecatedModelMessage(model);
|
|
26
|
+
if (deprecatedMessage) {
|
|
27
|
+
throw new Error(deprecatedMessage, {
|
|
28
|
+
cause: agentGenerationError("imageOpenaiAgent", imageAction, unsupportedModelTarget),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
19
31
|
const openai = createOpenAIClient({ apiKey, baseURL, apiVersion });
|
|
20
32
|
const size = (() => {
|
|
21
33
|
if (gptImages.includes(model)) {
|
|
@@ -114,7 +126,7 @@ export const imageOpenaiAgent = async ({ namedInputs, params, config, }) => {
|
|
|
114
126
|
}
|
|
115
127
|
return { buffer: Buffer.from(image_base64, "base64") };
|
|
116
128
|
}
|
|
117
|
-
//
|
|
129
|
+
// URL response handling (legacy OpenAI image API response format)
|
|
118
130
|
const res = await fetch(url);
|
|
119
131
|
if (!res.ok) {
|
|
120
132
|
throw new Error(`Failed to fetch ${url}: ${res.status} ${res.statusText}`, {
|
|
@@ -84,7 +84,7 @@ export const MulmoPresentationStyleMethods = {
|
|
|
84
84
|
const imageParams = { ...presentationStyle.imageParams, ...beat?.imageParams };
|
|
85
85
|
const provider = MulmoPresentationStyleMethods.getText2ImageProvider(imageParams?.provider) ?? defaultProviders.text2image;
|
|
86
86
|
const agentInfo = provider2ImageAgent[provider];
|
|
87
|
-
// The default text2image model is gpt-image-1 from OpenAI
|
|
87
|
+
// The default text2image model is gpt-image-1 from OpenAI.
|
|
88
88
|
const defaultImageParams = {
|
|
89
89
|
provider,
|
|
90
90
|
model: agentInfo.defaultModel,
|
|
@@ -133,8 +133,7 @@ export const MulmoPresentationStyleMethods = {
|
|
|
133
133
|
const imageAgentInfo = MulmoPresentationStyleMethods.getImageAgentInfo(presentationStyle);
|
|
134
134
|
if (imageAgentInfo.imageParams.provider === "openai") {
|
|
135
135
|
// NOTE: Here are the rate limits of OpenAI's text2image API (1token = 32x32 patch).
|
|
136
|
-
//
|
|
137
|
-
// gpt-image-1:3,000,000 TPM、150 images per minute
|
|
136
|
+
// gpt-image-1: 3,000,000 TPM, 150 images per minute
|
|
138
137
|
if (imageAgentInfo.imageParams.model === provider2ImageAgent.openai.defaultModel) {
|
|
139
138
|
return 16;
|
|
140
139
|
}
|
|
@@ -42,6 +42,11 @@ export declare const provider2TTSAgent: {
|
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
44
|
export declare const gptImages: string[];
|
|
45
|
+
export declare const deprecatedOpenAIImageModelHints: {
|
|
46
|
+
readonly "dall-e-2": "Use 'gpt-image-1' or another supported model.";
|
|
47
|
+
readonly "dall-e-3": "Use 'gpt-image-1' or another supported model.";
|
|
48
|
+
};
|
|
49
|
+
export type DeprecatedOpenAIImageModel = keyof typeof deprecatedOpenAIImageModelHints;
|
|
45
50
|
export declare const provider2ImageAgent: {
|
|
46
51
|
openai: {
|
|
47
52
|
agentName: string;
|
|
@@ -45,11 +45,16 @@ export const provider2TTSAgent = {
|
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
47
|
export const gptImages = ["gpt-image-2", "gpt-image-1.5", "gpt-image-1", "gpt-image-1-mini"];
|
|
48
|
+
const supportedOpenAIImageReplacementHint = "Use 'gpt-image-1' or another supported model.";
|
|
49
|
+
export const deprecatedOpenAIImageModelHints = {
|
|
50
|
+
"dall-e-2": supportedOpenAIImageReplacementHint,
|
|
51
|
+
"dall-e-3": supportedOpenAIImageReplacementHint,
|
|
52
|
+
};
|
|
48
53
|
export const provider2ImageAgent = {
|
|
49
54
|
openai: {
|
|
50
55
|
agentName: "imageOpenaiAgent",
|
|
51
56
|
defaultModel: "gpt-image-1",
|
|
52
|
-
models: [
|
|
57
|
+
models: [...gptImages],
|
|
53
58
|
keyName: "OPENAI_API_KEY",
|
|
54
59
|
baseURLKeyName: "OPENAI_BASE_URL",
|
|
55
60
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import ffmpeg from "fluent-ffmpeg";
|
|
1
|
+
import ffmpeg from "@modernized/fluent-ffmpeg";
|
|
2
|
+
type FfmpegCommand = ReturnType<typeof ffmpeg>;
|
|
2
3
|
export type FfmpegContext = {
|
|
3
|
-
command:
|
|
4
|
+
command: FfmpegCommand;
|
|
4
5
|
inputCount: number;
|
|
5
6
|
filterComplex: string[];
|
|
6
7
|
};
|
|
@@ -29,3 +30,4 @@ export declare const extractImageFromMovie: (movieFile: string, imagePath: strin
|
|
|
29
30
|
export declare const trimMusic: (inputFile: string, startTime: number, duration: number) => Promise<Buffer>;
|
|
30
31
|
export declare const createSilentAudio: (filePath: string, durationSec: number) => Promise<void>;
|
|
31
32
|
export declare const pcmToMp3: (rawPcm: Buffer, sampleRate?: number) => Promise<Buffer>;
|
|
33
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mulmocast",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.11-experimental.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.node.js",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
},
|
|
89
89
|
"homepage": "https://github.com/receptron/mulmocast-cli#readme",
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@google-cloud/text-to-speech": "^6.4.
|
|
91
|
+
"@google-cloud/text-to-speech": "^6.4.1",
|
|
92
92
|
"@google/genai": "^1.50.1",
|
|
93
93
|
"@graphai/anthropic_agent": "^2.0.12",
|
|
94
94
|
"@graphai/browserless_agent": "^2.0.2",
|
|
@@ -102,41 +102,40 @@
|
|
|
102
102
|
"@inquirer/input": "^5.0.12",
|
|
103
103
|
"@inquirer/select": "^5.1.4",
|
|
104
104
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
105
|
+
"@modernized/fluent-ffmpeg": "^0.1.1",
|
|
105
106
|
"@mozilla/readability": "^0.6.0",
|
|
106
107
|
"@tavily/core": "^0.5.11",
|
|
107
108
|
"archiver": "^7.0.1",
|
|
108
109
|
"clipboardy": "^5.3.1",
|
|
109
110
|
"dotenv": "^17.4.2",
|
|
110
|
-
"fluent-ffmpeg": "^2.1.3",
|
|
111
111
|
"graphai": "^2.0.16",
|
|
112
|
-
"jsdom": "^29.1.
|
|
113
|
-
"marked": "^18.0.
|
|
112
|
+
"jsdom": "^29.1.1",
|
|
113
|
+
"marked": "^18.0.3",
|
|
114
114
|
"mulmocast-vision": "^1.0.9",
|
|
115
115
|
"ora": "^9.4.0",
|
|
116
|
-
"puppeteer": "^24.
|
|
116
|
+
"puppeteer": "^24.43.0",
|
|
117
117
|
"replicate": "^1.4.0",
|
|
118
|
-
"yaml": "^2.8.
|
|
118
|
+
"yaml": "^2.8.4",
|
|
119
119
|
"yargs": "^18.0.0",
|
|
120
|
-
"zod": "^4.3
|
|
120
|
+
"zod": "^4.4.3"
|
|
121
121
|
},
|
|
122
122
|
"devDependencies": {
|
|
123
123
|
"@eslint/js": "^10.0.1",
|
|
124
124
|
"@receptron/test_utils": "^2.0.3",
|
|
125
125
|
"@types/archiver": "^7.0.0",
|
|
126
|
-
"@types/fluent-ffmpeg": "^2.1.28",
|
|
127
126
|
"@types/jsdom": "^28.0.1",
|
|
128
127
|
"@types/yargs": "^17.0.35",
|
|
129
128
|
"cross-env": "^10.1.0",
|
|
130
|
-
"eslint": "^10.
|
|
129
|
+
"eslint": "^10.3.0",
|
|
131
130
|
"eslint-config-prettier": "^10.1.8",
|
|
132
131
|
"eslint-plugin-import": "^2.32.0",
|
|
133
132
|
"eslint-plugin-prettier": "^5.5.5",
|
|
134
133
|
"eslint-plugin-sonarjs": "^4.0.3",
|
|
135
|
-
"globals": "^17.
|
|
134
|
+
"globals": "^17.6.0",
|
|
136
135
|
"prettier": "^3.8.3",
|
|
137
136
|
"tsx": "^4.21.0",
|
|
138
137
|
"typescript": "6.0.3",
|
|
139
|
-
"typescript-eslint": "^8.59.
|
|
138
|
+
"typescript-eslint": "^8.59.2"
|
|
140
139
|
},
|
|
141
140
|
"engines": {
|
|
142
141
|
"node": ">=22.0.0"
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
"text": "Image with
|
|
24
|
+
"text": "Image with OpenAI gpt-image-1-mini",
|
|
25
25
|
"imagePrompt": "Blue sky, a flock of birds",
|
|
26
26
|
"imageParams": {
|
|
27
|
-
"model": "
|
|
27
|
+
"model": "gpt-image-1-mini",
|
|
28
28
|
"style": "anime-style",
|
|
29
29
|
"provider": "openai"
|
|
30
30
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$mulmocast": {
|
|
3
|
+
"version": "1.1"
|
|
4
|
+
},
|
|
5
|
+
"lang": "en",
|
|
6
|
+
"title": "Test Deprecated OpenAI Image Models",
|
|
7
|
+
"imageParams": {
|
|
8
|
+
"provider": "openai",
|
|
9
|
+
"style": "Photorealistic-style"
|
|
10
|
+
},
|
|
11
|
+
"beats": [
|
|
12
|
+
{
|
|
13
|
+
"text": "dall-e-2 is deprecated; mulmocast rejects this with a migration hint before calling OpenAI",
|
|
14
|
+
"imagePrompt": "Blue sky, a flock of birds",
|
|
15
|
+
"imageParams": {
|
|
16
|
+
"model": "dall-e-2"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"text": "dall-e-3 is deprecated; mulmocast rejects this with a migration hint before calling OpenAI",
|
|
21
|
+
"imagePrompt": "Blue sky, a flock of birds",
|
|
22
|
+
"imageParams": {
|
|
23
|
+
"model": "dall-e-3"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$mulmocast": {
|
|
3
|
+
"version": "1.1"
|
|
4
|
+
},
|
|
5
|
+
"lang": "en",
|
|
6
|
+
"movieParams": {
|
|
7
|
+
"provider": "google"
|
|
8
|
+
},
|
|
9
|
+
"canvasSize": {
|
|
10
|
+
"width": 720,
|
|
11
|
+
"height": 1280
|
|
12
|
+
},
|
|
13
|
+
"imageParams": {
|
|
14
|
+
"provider": "openai",
|
|
15
|
+
"model": "dall-e-3",
|
|
16
|
+
"style": "Photo realistic, cinematic style."
|
|
17
|
+
},
|
|
18
|
+
"beats": [
|
|
19
|
+
{
|
|
20
|
+
"text": "dall-e-3 on movie flow is deprecated; mulmocast rejects upfront with a migration hint",
|
|
21
|
+
"imagePrompt": "A rocket on the launch pad at dusk.",
|
|
22
|
+
"moviePrompt": "Rocket lifts off.",
|
|
23
|
+
"duration": 5
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|