mulmocast 1.2.58 → 1.2.59
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/actions/images.js +12 -0
- package/lib/types/schema.js +1 -1
- package/package.json +1 -1
package/lib/actions/images.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import dotenv from "dotenv";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { GraphAI, GraphAILogger, TaskManager } from "graphai";
|
|
4
|
+
import { AuthenticationError, RateLimitError } from "openai/index.js";
|
|
4
5
|
import * as vanilla from "@graphai/vanilla";
|
|
5
6
|
import { openAIAgent } from "@graphai/openai_agent";
|
|
6
7
|
import { anthropicAgent } from "@graphai/anthropic_agent";
|
|
7
8
|
import { fileWriteAgent } from "@graphai/vanilla_node_agents";
|
|
8
9
|
import { imageGenAIAgent, imageOpenaiAgent, imageReplicateAgent, movieGenAIAgent, movieReplicateAgent, mediaMockAgent, soundEffectReplicateAgent, lipSyncReplicateAgent, } from "../agents/index.js";
|
|
9
10
|
import { MulmoPresentationStyleMethods, MulmoStudioContextMethods } from "../methods/index.js";
|
|
11
|
+
import { agentIncorrectAPIKeyError, agentAPIRateLimitError, imageAction, imageFileTarget } from "../utils/error_cause.js";
|
|
10
12
|
import { getOutputStudioFilePath, mkdir } from "../utils/file.js";
|
|
11
13
|
import { fileCacheAgentFilter } from "../utils/filters.js";
|
|
12
14
|
import { settings2GraphAIConfig } from "../utils/utils.js";
|
|
@@ -440,6 +442,16 @@ export const images = async (context, args) => {
|
|
|
440
442
|
}
|
|
441
443
|
catch (error) {
|
|
442
444
|
MulmoStudioContextMethods.setSessionState(context, "image", false, false);
|
|
445
|
+
if (error instanceof AuthenticationError) {
|
|
446
|
+
throw new Error("Failed to generate image: 401 Incorrect API key provided with OpenAI", {
|
|
447
|
+
cause: agentIncorrectAPIKeyError("openaiAgent", imageAction, imageFileTarget),
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
if (error instanceof RateLimitError) {
|
|
451
|
+
throw new Error("You exceeded your current quota", {
|
|
452
|
+
cause: agentAPIRateLimitError("openaiAgent", imageAction, imageFileTarget),
|
|
453
|
+
});
|
|
454
|
+
}
|
|
443
455
|
throw error;
|
|
444
456
|
}
|
|
445
457
|
};
|
package/lib/types/schema.js
CHANGED
|
@@ -174,7 +174,7 @@ const imageIdSchema = z.string();
|
|
|
174
174
|
export const mulmoImagePromptMediaSchema = z
|
|
175
175
|
.object({
|
|
176
176
|
type: z.literal("imagePrompt"),
|
|
177
|
-
prompt: z.string(),
|
|
177
|
+
prompt: z.string().min(1),
|
|
178
178
|
})
|
|
179
179
|
.strict();
|
|
180
180
|
export const mulmoImageParamsImagesValueSchema = z.union([mulmoImageMediaSchema, mulmoImagePromptMediaSchema]);
|