mulmocast 2.1.11 → 2.1.12

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.
@@ -1,6 +1,5 @@
1
1
  import type { AgentFunction, AgentFunctionInfo } from "graphai";
2
2
  import type { AgentBufferResult, ImageAgentInputs, ImageAgentParams, GenAIImageAgentConfig } from "../types/agent.js";
3
- export declare const ratio2BlankPath: (aspectRatio: string) => string;
4
3
  export declare const imageGenAIAgent: AgentFunction<ImageAgentParams, AgentBufferResult, ImageAgentInputs, GenAIImageAgentConfig>;
5
4
  declare const imageGenAIAgentInfo: AgentFunctionInfo;
6
5
  export default imageGenAIAgentInfo;
@@ -3,25 +3,11 @@ import { GraphAILogger } from "graphai";
3
3
  import { provider2ImageAgent } from "../utils/provider2agent.js";
4
4
  import { apiKeyMissingError, agentIncorrectAPIKeyError, agentGenerationError, agentInvalidResponseError, imageAction, imageFileTarget, hasCause, getGenAIErrorReason, resultify, } from "../utils/error_cause.js";
5
5
  import { getAspectRatio } from "../utils/utils.js";
6
- import { ASPECT_RATIOS } from "../utils/const.js";
6
+ import { ASPECT_RATIOS, PRO_ASPECT_RATIOS } from "../utils/const.js";
7
7
  import { GoogleGenAI, PersonGeneration } from "@google/genai";
8
- import { blankImagePath, blankSquareImagePath, blankVerticalImagePath } from "../utils/file.js";
9
- export const ratio2BlankPath = (aspectRatio) => {
10
- if (aspectRatio === "9:16") {
11
- return blankVerticalImagePath();
12
- }
13
- else if (aspectRatio === "1:1") {
14
- return blankSquareImagePath();
15
- }
16
- return blankImagePath();
17
- };
18
- const getGeminiContents = (prompt, referenceImages, aspectRatio) => {
8
+ const getGeminiContents = (prompt, referenceImages) => {
19
9
  const contents = [{ text: prompt }];
20
10
  const images = [...(referenceImages ?? [])];
21
- // NOTE: There is no way to explicitly specify the aspect ratio for Gemini. This is just a hint.
22
- if (aspectRatio) {
23
- images.push(ratio2BlankPath(aspectRatio));
24
- }
25
11
  images.forEach((imagePath) => {
26
12
  const imageData = fs.readFileSync(imagePath);
27
13
  const base64Image = imageData.toString("base64");
@@ -71,7 +57,6 @@ const errorProcess = (error) => {
71
57
  };
72
58
  export const imageGenAIAgent = async ({ namedInputs, params, config, }) => {
73
59
  const { prompt, referenceImages } = namedInputs;
74
- const aspectRatio = getAspectRatio(params.canvasSize, ASPECT_RATIOS);
75
60
  const model = params.model ?? provider2ImageAgent["google"].defaultModel;
76
61
  const apiKey = config?.apiKey;
77
62
  if (!apiKey) {
@@ -82,13 +67,7 @@ export const imageGenAIAgent = async ({ namedInputs, params, config, }) => {
82
67
  const ai = new GoogleGenAI({ apiKey });
83
68
  if (model === "gemini-2.5-flash-image" || model === "gemini-3-pro-image-preview") {
84
69
  const contentParams = (() => {
85
- if (model === "gemini-2.5-flash-image") {
86
- const contents = getGeminiContents(prompt, referenceImages, aspectRatio);
87
- return { model, contents };
88
- }
89
- // gemini-3-pro-image-preview
90
70
  const contents = getGeminiContents(prompt, referenceImages);
91
- const PRO_ASPECT_RATIOS = ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"];
92
71
  return {
93
72
  model,
94
73
  contents,
@@ -111,7 +90,7 @@ export const imageGenAIAgent = async ({ namedInputs, params, config, }) => {
111
90
  prompt,
112
91
  config: {
113
92
  numberOfImages: 1, // default is 4!
114
- aspectRatio,
93
+ aspectRatio: getAspectRatio(params.canvasSize, ASPECT_RATIOS),
115
94
  personGeneration: PersonGeneration.ALLOW_ALL,
116
95
  // safetyFilterLevel: SafetyFilterLevel.BLOCK_ONLY_HIGH,
117
96
  },
@@ -12,3 +12,4 @@ export declare const storyToScriptGenerateMode: {
12
12
  };
13
13
  export declare const bundleTargetLang: string[];
14
14
  export declare const ASPECT_RATIOS: string[];
15
+ export declare const PRO_ASPECT_RATIOS: string[];
@@ -12,3 +12,4 @@ export const storyToScriptGenerateMode = {
12
12
  };
13
13
  export const bundleTargetLang = ["ja", "en"];
14
14
  export const ASPECT_RATIOS = ["1:1", "9:16", "16:9"];
15
+ export const PRO_ASPECT_RATIOS = ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast",
3
- "version": "2.1.11",
3
+ "version": "2.1.12",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.node.js",