@aigne/ideogram 1.74.0-beta.1 → 1.74.0-beta.11

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,14 +1,14 @@
1
- let _aigne_core = require("@aigne/core");
2
- let _aigne_core_utils_camelize = require("@aigne/core/utils/camelize");
3
- let _aigne_core_utils_fetch = require("@aigne/core/utils/fetch");
4
- let _aigne_core_utils_type_utils = require("@aigne/core/utils/type-utils");
1
+ let _aigne_model_base = require("@aigne/model-base");
2
+ let _aigne_model_base_utils_camelize = require("@aigne/model-base/utils/camelize");
3
+ let _aigne_model_base_utils_fetch = require("@aigne/model-base/utils/fetch");
4
+ let _aigne_model_base_utils_type_utils = require("@aigne/model-base/utils/type-utils");
5
5
  let ufo = require("ufo");
6
6
  let zod = require("zod");
7
7
 
8
8
  //#region src/ideogram-image-model.ts
9
9
  const IDEOGRAM_BASE_URL = "https://api.ideogram.ai";
10
10
  const IDEOGRAM_DEFAULT_IMAGE_MODEL = "ideogram-v3";
11
- const ideogramImageModelInputSchema = _aigne_core.imageModelInputSchema.extend({});
11
+ const ideogramImageModelInputSchema = _aigne_model_base.imageModelInputSchema.extend({});
12
12
  const ideogramImageModelOptionsSchema = zod.z.object({
13
13
  apiKey: zod.z.string().optional(),
14
14
  baseURL: zod.z.string().optional(),
@@ -16,7 +16,7 @@ const ideogramImageModelOptionsSchema = zod.z.object({
16
16
  modelOptions: zod.z.object({}).optional(),
17
17
  clientOptions: zod.z.object({}).optional()
18
18
  });
19
- var IdeogramImageModel = class extends _aigne_core.ImageModel {
19
+ var IdeogramImageModel = class extends _aigne_model_base.ImageModel {
20
20
  constructor(options) {
21
21
  super({
22
22
  ...options,
@@ -24,7 +24,7 @@ var IdeogramImageModel = class extends _aigne_core.ImageModel {
24
24
  description: options?.description ?? "Draw or edit image by Ideogram image models"
25
25
  });
26
26
  this.options = options;
27
- if (options) (0, _aigne_core_utils_type_utils.checkArguments)(this.name, ideogramImageModelOptionsSchema, options);
27
+ if (options) (0, _aigne_model_base_utils_type_utils.checkArguments)(this.name, ideogramImageModelOptionsSchema, options);
28
28
  }
29
29
  apiKeyEnvName = "IDEOGRAM_API_KEY";
30
30
  get credential() {
@@ -58,7 +58,7 @@ var IdeogramImageModel = class extends _aigne_core.ImageModel {
58
58
  "styleCodes",
59
59
  "styleType"
60
60
  ];
61
- const mergedInput = (0, _aigne_core_utils_camelize.snakelize)((0, _aigne_core_utils_type_utils.pick)({
61
+ const mergedInput = (0, _aigne_model_base_utils_camelize.snakelize)((0, _aigne_model_base_utils_type_utils.pick)({
62
62
  ...this.modelOptions,
63
63
  ...input.modelOptions,
64
64
  ...input
@@ -67,7 +67,7 @@ var IdeogramImageModel = class extends _aigne_core.ImageModel {
67
67
  if (mergedInput[key]) formData.append(key, mergedInput[key]);
68
68
  });
69
69
  if (input.n) formData.append("num_images", input.n.toString());
70
- const inputImages = (0, _aigne_core_utils_type_utils.flat)(input.image);
70
+ const inputImages = (0, _aigne_model_base_utils_type_utils.flat)(input.image);
71
71
  const image = inputImages.at(0);
72
72
  if (image) {
73
73
  if (inputImages.length > 1) throw new Error(`${this.name} only support one image for editing`);
@@ -77,7 +77,7 @@ var IdeogramImageModel = class extends _aigne_core.ImageModel {
77
77
  const { url, apiKey } = this.credential;
78
78
  if (!apiKey) throw new Error(`${this.name} requires an API key. Please provide it via \`options.apiKey\`, or set the \`${this.apiKeyEnvName}\` environment variable`);
79
79
  return {
80
- images: (await (await (0, _aigne_core_utils_fetch.fetch)((0, ufo.joinURL)(new URL(url).origin, "v1", model, image ? "remix" : "generate"), {
80
+ images: (await (await (0, _aigne_model_base_utils_fetch.fetch)((0, ufo.joinURL)(new URL(url).origin, "v1", model, image ? "remix" : "generate"), {
81
81
  method: "POST",
82
82
  headers: { "api-key": apiKey },
83
83
  body: formData,
@@ -1,4 +1,4 @@
1
- import { AgentInvokeOptions, ImageModel, ImageModelInput, ImageModelOptions, ImageModelOutput } from "@aigne/core";
1
+ import { ImageModel, ImageModelInput, ImageModelOptions, ImageModelOutput, ModelInvokeOptions } from "@aigne/model-base";
2
2
 
3
3
  //#region src/ideogram-image-model.d.ts
4
4
  interface IdeogramImageModelInput extends ImageModelInput {
@@ -32,11 +32,11 @@ declare class IdeogramImageModel extends ImageModel<IdeogramImageModelInput, Ide
32
32
  };
33
33
  get modelOptions(): Omit<Partial<IdeogramImageModelInput>, "model"> | undefined;
34
34
  /**
35
- * Process the input and generate a response
36
- * @param input The input to process
37
- * @returns The generated response
38
- */
39
- process(input: IdeogramImageModelInput, _options: AgentInvokeOptions): Promise<ImageModelOutput>;
35
+ * Process the input and generate a response
36
+ * @param input The input to process
37
+ * @returns The generated response
38
+ */
39
+ process(input: IdeogramImageModelInput, _options: ModelInvokeOptions): Promise<ImageModelOutput>;
40
40
  }
41
41
  //#endregion
42
42
  export { IdeogramImageModel, IdeogramImageModelInput, IdeogramImageModelOptions, IdeogramImageModelOutput };
@@ -1 +1 @@
1
- {"version":3,"file":"ideogram-image-model.d.cts","names":[],"sources":["../src/ideogram-image-model.ts"],"mappings":";;;UAiBiB,uBAAA,SAAgC,eAAA;EAAA,IAAA;EAAA,UAAA;EAAA,WAAA;EAAA,cAAA;EAAA,WAAA;EAAA,cAAA;EAAA,SAAA;EAAA,YAAA;EAAA,UAAA;EAAA,SAAA;AAAA;AAAA,UAahC,wBAAA,SAAiC,gBAAA;AAAA,UAEjC,yBAAA,SACP,iBAAA,CAAkB,uBAAA,EAAyB,wBAAA;EAAA,MAAA;EAAA,OAAA;EAAA,KAAA;EAAA,YAAA,GAIpC,IAAA,CAAK,OAAA,CAAQ,uBAAA;EAAA,aAAA,GACZ,MAAA;AAAA;AAAA,cAaL,kBAAA,SAA2B,UAAA,CACtC,uBAAA,EACA,wBAAA;EAAA,OAAA,GAEsC,yBAAA;EAAA,YAAA,OAAA,GAAA,yBAAA;EAAA,UAAA,aAAA;EAAA,IAAA,WAAA;IAAA,GAAA;IAAA,MAAA;IAAA,KAAA;EAAA;EAAA,IAAA,aAAA,GAmBtB,IAAA,CAAA,OAAA,CAAA,uBAAA;EAAA;;;;;EAAA,QAAA,KAAA,EAUP,uBAAA,EAAA,QAAA,EACG,kBAAA,GACT,OAAA,CAAQ,gBAAA;AAAA"}
1
+ {"version":3,"file":"ideogram-image-model.d.cts","names":[],"sources":["../src/ideogram-image-model.ts"],"mappings":";;;UAiBiB,uBAAA,SAAgC,eAAA;EAC/C,IAAA;EACA,UAAA;EACA,WAAA;EACA,cAAA;EACA,WAAA;EACA,cAAA;EACA,SAAA;EACA,YAAA;EACA,UAAA;EACA,SAAA;AAAA;AAAA,UAGe,wBAAA,SAAiC,gBAAA;AAAA,UAEjC,yBAAA,SACP,iBAAA,CAAkB,uBAAA,EAAyB,wBAAA;EACnD,MAAA;EACA,OAAA;EACA,KAAA;EACA,YAAA,GAAe,IAAA,CAAK,OAAA,CAAQ,uBAAA;EAC5B,aAAA,GAAgB,MAAA;AAAA;AAAA,cAaL,kBAAA,SAA2B,UAAA,CACtC,uBAAA,EACA,wBAAA;EAE4B,OAAA,GAAU,yBAAA;cAAV,OAAA,GAAU,yBAAA;EAAA,UAS5B,aAAA;EAAA,IAEG,UAAA,CAAA;;;;;MAQT,YAAA,CAAA,GAAY,IAAA,CAAA,OAAA,CAAA,uBAAA;EArCD;;;;;EA8CA,OAAA,CACb,KAAA,EAAO,uBAAA,EACP,QAAA,EAAU,kBAAA,GACT,OAAA,CAAQ,gBAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- import { AgentInvokeOptions, ImageModel, ImageModelInput, ImageModelOptions, ImageModelOutput } from "@aigne/core";
1
+ import { ImageModel, ImageModelInput, ImageModelOptions, ImageModelOutput, ModelInvokeOptions } from "@aigne/model-base";
2
2
 
3
3
  //#region src/ideogram-image-model.d.ts
4
4
  interface IdeogramImageModelInput extends ImageModelInput {
@@ -32,11 +32,11 @@ declare class IdeogramImageModel extends ImageModel<IdeogramImageModelInput, Ide
32
32
  };
33
33
  get modelOptions(): Omit<Partial<IdeogramImageModelInput>, "model"> | undefined;
34
34
  /**
35
- * Process the input and generate a response
36
- * @param input The input to process
37
- * @returns The generated response
38
- */
39
- process(input: IdeogramImageModelInput, _options: AgentInvokeOptions): Promise<ImageModelOutput>;
35
+ * Process the input and generate a response
36
+ * @param input The input to process
37
+ * @returns The generated response
38
+ */
39
+ process(input: IdeogramImageModelInput, _options: ModelInvokeOptions): Promise<ImageModelOutput>;
40
40
  }
41
41
  //#endregion
42
42
  export { IdeogramImageModel, IdeogramImageModelInput, IdeogramImageModelOptions, IdeogramImageModelOutput };
@@ -1 +1 @@
1
- {"version":3,"file":"ideogram-image-model.d.mts","names":[],"sources":["../src/ideogram-image-model.ts"],"mappings":";;;UAiBiB,uBAAA,SAAgC,eAAA;EAAA,IAAA;EAAA,UAAA;EAAA,WAAA;EAAA,cAAA;EAAA,WAAA;EAAA,cAAA;EAAA,SAAA;EAAA,YAAA;EAAA,UAAA;EAAA,SAAA;AAAA;AAAA,UAahC,wBAAA,SAAiC,gBAAA;AAAA,UAEjC,yBAAA,SACP,iBAAA,CAAkB,uBAAA,EAAyB,wBAAA;EAAA,MAAA;EAAA,OAAA;EAAA,KAAA;EAAA,YAAA,GAIpC,IAAA,CAAK,OAAA,CAAQ,uBAAA;EAAA,aAAA,GACZ,MAAA;AAAA;AAAA,cAaL,kBAAA,SAA2B,UAAA,CACtC,uBAAA,EACA,wBAAA;EAAA,OAAA,GAEsC,yBAAA;EAAA,YAAA,OAAA,GAAA,yBAAA;EAAA,UAAA,aAAA;EAAA,IAAA,WAAA;IAAA,GAAA;IAAA,MAAA;IAAA,KAAA;EAAA;EAAA,IAAA,aAAA,GAmBtB,IAAA,CAAA,OAAA,CAAA,uBAAA;EAAA;;;;;EAAA,QAAA,KAAA,EAUP,uBAAA,EAAA,QAAA,EACG,kBAAA,GACT,OAAA,CAAQ,gBAAA;AAAA"}
1
+ {"version":3,"file":"ideogram-image-model.d.mts","names":[],"sources":["../src/ideogram-image-model.ts"],"mappings":";;;UAiBiB,uBAAA,SAAgC,eAAA;EAC/C,IAAA;EACA,UAAA;EACA,WAAA;EACA,cAAA;EACA,WAAA;EACA,cAAA;EACA,SAAA;EACA,YAAA;EACA,UAAA;EACA,SAAA;AAAA;AAAA,UAGe,wBAAA,SAAiC,gBAAA;AAAA,UAEjC,yBAAA,SACP,iBAAA,CAAkB,uBAAA,EAAyB,wBAAA;EACnD,MAAA;EACA,OAAA;EACA,KAAA;EACA,YAAA,GAAe,IAAA,CAAK,OAAA,CAAQ,uBAAA;EAC5B,aAAA,GAAgB,MAAA;AAAA;AAAA,cAaL,kBAAA,SAA2B,UAAA,CACtC,uBAAA,EACA,wBAAA;EAE4B,OAAA,GAAU,yBAAA;cAAV,OAAA,GAAU,yBAAA;EAAA,UAS5B,aAAA;EAAA,IAEG,UAAA,CAAA;;;;;MAQT,YAAA,CAAA,GAAY,IAAA,CAAA,OAAA,CAAA,uBAAA;EArCD;;;;;EA8CA,OAAA,CACb,KAAA,EAAO,uBAAA,EACP,QAAA,EAAU,kBAAA,GACT,OAAA,CAAQ,gBAAA;AAAA"}
@@ -1,7 +1,7 @@
1
- import { ImageModel, imageModelInputSchema } from "@aigne/core";
2
- import { snakelize } from "@aigne/core/utils/camelize";
3
- import { fetch } from "@aigne/core/utils/fetch";
4
- import { checkArguments, flat, pick } from "@aigne/core/utils/type-utils";
1
+ import { ImageModel, imageModelInputSchema } from "@aigne/model-base";
2
+ import { snakelize } from "@aigne/model-base/utils/camelize";
3
+ import { fetch } from "@aigne/model-base/utils/fetch";
4
+ import { checkArguments, flat, pick } from "@aigne/model-base/utils/type-utils";
5
5
  import { joinURL } from "ufo";
6
6
  import { z } from "zod";
7
7
 
@@ -1 +1 @@
1
- {"version":3,"file":"ideogram-image-model.mjs","names":[],"sources":["../src/ideogram-image-model.ts"],"sourcesContent":["import {\n type AgentInvokeOptions,\n ImageModel,\n type ImageModelInput,\n type ImageModelOptions,\n type ImageModelOutput,\n imageModelInputSchema,\n} from \"@aigne/core\";\nimport { snakelize } from \"@aigne/core/utils/camelize\";\nimport { fetch } from \"@aigne/core/utils/fetch\";\nimport { checkArguments, flat, pick } from \"@aigne/core/utils/type-utils\";\nimport { joinURL } from \"ufo\";\nimport { z } from \"zod\";\n\nconst IDEOGRAM_BASE_URL = \"https://api.ideogram.ai\";\nconst IDEOGRAM_DEFAULT_IMAGE_MODEL = \"ideogram-v3\";\n\nexport interface IdeogramImageModelInput extends ImageModelInput {\n seed?: number;\n resolution?: string;\n aspectRatio?: string;\n renderingSpeed?: string;\n magicPrompt?: string;\n negativePrompt?: string;\n numImages?: number;\n colorPalette?: any;\n styleCodes?: string[];\n styleType?: string;\n}\n\nexport interface IdeogramImageModelOutput extends ImageModelOutput {}\n\nexport interface IdeogramImageModelOptions\n extends ImageModelOptions<IdeogramImageModelInput, IdeogramImageModelOutput> {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n modelOptions?: Omit<Partial<IdeogramImageModelInput>, \"model\">;\n clientOptions?: Record<string, any>;\n}\n\nconst ideogramImageModelInputSchema = imageModelInputSchema.extend({});\n\nconst ideogramImageModelOptionsSchema = z.object({\n apiKey: z.string().optional(),\n baseURL: z.string().optional(),\n model: z.string().optional(),\n modelOptions: z.object({}).optional(),\n clientOptions: z.object({}).optional(),\n});\n\nexport class IdeogramImageModel extends ImageModel<\n IdeogramImageModelInput,\n IdeogramImageModelOutput\n> {\n constructor(public override options?: IdeogramImageModelOptions) {\n super({\n ...options,\n inputSchema: ideogramImageModelInputSchema,\n description: options?.description ?? \"Draw or edit image by Ideogram image models\",\n });\n if (options) checkArguments(this.name, ideogramImageModelOptionsSchema, options);\n }\n\n protected apiKeyEnvName = \"IDEOGRAM_API_KEY\";\n\n override get credential() {\n return {\n url: this.options?.baseURL || process.env.IDEOGRAM_BASE_URL || IDEOGRAM_BASE_URL,\n apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],\n model: this.options?.model || IDEOGRAM_DEFAULT_IMAGE_MODEL,\n };\n }\n\n get modelOptions() {\n return this.options?.modelOptions;\n }\n\n /**\n * Process the input and generate a response\n * @param input The input to process\n * @returns The generated response\n */\n override async process(\n input: IdeogramImageModelInput,\n _options: AgentInvokeOptions,\n ): Promise<ImageModelOutput> {\n const model = input.model || this.credential.model;\n const formData = new FormData();\n\n if (model !== \"ideogram-v3\") {\n throw new Error(`${this.name} only support ideogram-v3`);\n }\n\n const inputKeys = [\n \"prompt\",\n \"seed\",\n \"resolution\",\n \"aspectRatio\",\n \"renderingSpeed\",\n \"magicPrompt\",\n \"negativePrompt\",\n \"colorPalette\",\n \"styleCodes\",\n \"styleType\",\n ];\n\n const mergedInput = snakelize(\n pick({ ...this.modelOptions, ...input.modelOptions, ...input }, inputKeys),\n );\n\n Object.keys(mergedInput).forEach((key) => {\n if (mergedInput[key]) {\n formData.append(key, mergedInput[key] as string);\n }\n });\n\n if (input.n) {\n formData.append(\"num_images\", input.n.toString());\n }\n\n const inputImages = flat(input.image);\n const image = inputImages.at(0);\n if (image) {\n if (inputImages.length > 1) {\n throw new Error(`${this.name} only support one image for editing`);\n }\n const { data } = await this.transformFileType(\"file\", image);\n formData.append(\"image\", new Blob([Buffer.from(data, \"base64\")]));\n }\n\n const { url, apiKey } = this.credential;\n if (!apiKey)\n throw new Error(\n `${this.name} requires an API key. Please provide it via \\`options.apiKey\\`, or set the \\`${this.apiKeyEnvName}\\` environment variable`,\n );\n\n const apiURL = joinURL(new URL(url).origin, \"v1\", model, image ? \"remix\" : \"generate\");\n\n const response = await fetch(apiURL, {\n method: \"POST\",\n headers: { \"api-key\": apiKey },\n body: formData,\n timeout: this.options?.clientOptions?.timeout ?? 60 * 1000,\n });\n\n const data: { data: { url: string }[] } = await response.json();\n\n return {\n images: data.data.map((item) => ({ type: \"url\", url: item.url, mimeType: \"image/png\" })),\n usage: {\n inputTokens: 0,\n outputTokens: 0,\n },\n model,\n };\n }\n}\n"],"mappings":";;;;;;;;AAcA,MAAM,oBAAoB;AAC1B,MAAM,+BAA+B;AA0BrC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AM,EAAE,UAAU,CAAC;EAGnD,MAAM,cAAc,KAAK,MAAM,MAAM;EACrC,MAAM,QAAQ,YAAY,GAAG,EAAE;AAC/B,MAAI,OAAO;AACT,OAAI,YAAY,SAAS,EACvB,OAAM,IAAI,MAAM,GAAG,KAAK,KAAK,qCAAqC;GAEpE,MAAM,EAAE,SAAS,MAAM,KAAK,kBAAkB,QAAQ,MAAM;AAC5D,YAAS,OAAO,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,CAAC;;EAGnE,MAAM,EAAE,KAAK,WAAW,KAAK;AAC7B,MAAI,CAAC,OACH,OAAM,IAAI,MACR,GAAG,KAAK,KAAK,+EAA+E,KAAK,cAAc,yBAChH;AAaH,SAAO;GACL,SAHwC,OAPzB,MAAM,MAFR,QAAQ,IAAI,IAAI,IAAI,CAAC,QAAQ,MAAM,OAAO,QAAQ,UAAU,WAAW,EAEjD;IACnC,QAAQ;IACR,SAAS,EAAE,WAAW,QAAQ;IAC9B,MAAM;IACN,SAAS,KAAK,SAAS,eAAe,WAAW,KAAK;IACvD,CAAC,EAEuD,MAAM,EAGhD,KAAK,KAAK,UAAU;IAAE,MAAM;IAAO,KAAK,KAAK;IAAK,UAAU;IAAa,EAAE;GACxF,OAAO;IACL,aAAa;IACb,cAAc;IACf;GACD;GACD"}
1
+ {"version":3,"file":"ideogram-image-model.mjs","names":[],"sources":["../src/ideogram-image-model.ts"],"sourcesContent":["import {\n ImageModel,\n type ImageModelInput,\n type ImageModelOptions,\n type ImageModelOutput,\n imageModelInputSchema,\n type ModelInvokeOptions,\n} from \"@aigne/model-base\";\nimport { snakelize } from \"@aigne/model-base/utils/camelize\";\nimport { fetch } from \"@aigne/model-base/utils/fetch\";\nimport { checkArguments, flat, pick } from \"@aigne/model-base/utils/type-utils\";\nimport { joinURL } from \"ufo\";\nimport { z } from \"zod\";\n\nconst IDEOGRAM_BASE_URL = \"https://api.ideogram.ai\";\nconst IDEOGRAM_DEFAULT_IMAGE_MODEL = \"ideogram-v3\";\n\nexport interface IdeogramImageModelInput extends ImageModelInput {\n seed?: number;\n resolution?: string;\n aspectRatio?: string;\n renderingSpeed?: string;\n magicPrompt?: string;\n negativePrompt?: string;\n numImages?: number;\n colorPalette?: any;\n styleCodes?: string[];\n styleType?: string;\n}\n\nexport interface IdeogramImageModelOutput extends ImageModelOutput {}\n\nexport interface IdeogramImageModelOptions\n extends ImageModelOptions<IdeogramImageModelInput, IdeogramImageModelOutput> {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n modelOptions?: Omit<Partial<IdeogramImageModelInput>, \"model\">;\n clientOptions?: Record<string, any>;\n}\n\nconst ideogramImageModelInputSchema = imageModelInputSchema.extend({});\n\nconst ideogramImageModelOptionsSchema = z.object({\n apiKey: z.string().optional(),\n baseURL: z.string().optional(),\n model: z.string().optional(),\n modelOptions: z.object({}).optional(),\n clientOptions: z.object({}).optional(),\n});\n\nexport class IdeogramImageModel extends ImageModel<\n IdeogramImageModelInput,\n IdeogramImageModelOutput\n> {\n constructor(public override options?: IdeogramImageModelOptions) {\n super({\n ...options,\n inputSchema: ideogramImageModelInputSchema,\n description: options?.description ?? \"Draw or edit image by Ideogram image models\",\n });\n if (options) checkArguments(this.name, ideogramImageModelOptionsSchema, options);\n }\n\n protected apiKeyEnvName = \"IDEOGRAM_API_KEY\";\n\n override get credential() {\n return {\n url: this.options?.baseURL || process.env.IDEOGRAM_BASE_URL || IDEOGRAM_BASE_URL,\n apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],\n model: this.options?.model || IDEOGRAM_DEFAULT_IMAGE_MODEL,\n };\n }\n\n get modelOptions() {\n return this.options?.modelOptions;\n }\n\n /**\n * Process the input and generate a response\n * @param input The input to process\n * @returns The generated response\n */\n override async process(\n input: IdeogramImageModelInput,\n _options: ModelInvokeOptions,\n ): Promise<ImageModelOutput> {\n const model = input.model || this.credential.model;\n const formData = new FormData();\n\n if (model !== \"ideogram-v3\") {\n throw new Error(`${this.name} only support ideogram-v3`);\n }\n\n const inputKeys = [\n \"prompt\",\n \"seed\",\n \"resolution\",\n \"aspectRatio\",\n \"renderingSpeed\",\n \"magicPrompt\",\n \"negativePrompt\",\n \"colorPalette\",\n \"styleCodes\",\n \"styleType\",\n ];\n\n const mergedInput = snakelize(\n pick({ ...this.modelOptions, ...input.modelOptions, ...input }, inputKeys),\n );\n\n Object.keys(mergedInput).forEach((key) => {\n if (mergedInput[key]) {\n formData.append(key, mergedInput[key] as string);\n }\n });\n\n if (input.n) {\n formData.append(\"num_images\", input.n.toString());\n }\n\n const inputImages = flat(input.image);\n const image = inputImages.at(0);\n if (image) {\n if (inputImages.length > 1) {\n throw new Error(`${this.name} only support one image for editing`);\n }\n const { data } = await this.transformFileType(\"file\", image);\n formData.append(\"image\", new Blob([Buffer.from(data, \"base64\")]));\n }\n\n const { url, apiKey } = this.credential;\n if (!apiKey)\n throw new Error(\n `${this.name} requires an API key. Please provide it via \\`options.apiKey\\`, or set the \\`${this.apiKeyEnvName}\\` environment variable`,\n );\n\n const apiURL = joinURL(new URL(url).origin, \"v1\", model, image ? \"remix\" : \"generate\");\n\n const response = await fetch(apiURL, {\n method: \"POST\",\n headers: { \"api-key\": apiKey },\n body: formData,\n timeout: this.options?.clientOptions?.timeout ?? 60 * 1000,\n });\n\n const data: { data: { url: string }[] } = await response.json();\n\n return {\n images: data.data.map((item) => ({ type: \"url\", url: item.url, mimeType: \"image/png\" })),\n usage: {\n inputTokens: 0,\n outputTokens: 0,\n },\n model,\n };\n }\n}\n"],"mappings":";;;;;;;;AAcA,MAAM,oBAAoB;AAC1B,MAAM,+BAA+B;AA0BrC,MAAM,gCAAgC,sBAAsB,OAAO,EAAE,CAAC;AAEtE,MAAM,kCAAkC,EAAE,OAAO;CAC/C,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,cAAc,EAAE,OAAO,EA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KAAK,kBAAkB,QAAQ,MAAM;AAC5D,YAAS,OAAO,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,CAAC;;EAGnE,MAAM,EAAE,KAAK,WAAW,KAAK;AAC7B,MAAI,CAAC,OACH,OAAM,IAAI,MACR,GAAG,KAAK,KAAK,+EAA+E,KAAK,cAAc,yBAChH;AAaH,SAAO;GACL,SAHwC,OAPzB,MAAM,MAFR,QAAQ,IAAI,IAAI,IAAI,CAAC,QAAQ,MAAM,OAAO,QAAQ,UAAU,WAAW,EAEjD;IACnC,QAAQ;IACR,SAAS,EAAE,WAAW,QAAQ;IAC9B,MAAM;IACN,SAAS,KAAK,SAAS,eAAe,WAAW,KAAK;IACvD,CAAC,EAEuD,MAAM,EAGhD,KAAK,KAAK,UAAU;IAAE,MAAM;IAAO,KAAK,KAAK;IAAK,UAAU;IAAa,EAAE;GACxF,OAAO;IACL,aAAa;IACb,cAAc;IACf;GACD;GACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/ideogram",
3
- "version": "1.74.0-beta.1",
3
+ "version": "1.74.0-beta.11",
4
4
  "description": "AIGNE Ideogram SDK for integrating with Ideogram's image models and API services",
5
5
  "license": "Elastic-2.0",
6
6
  "publishConfig": {
@@ -34,8 +34,8 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "ufo": "^1.6.1",
37
- "zod": "3.25.67",
38
- "@aigne/core": "1.74.0-beta.1"
37
+ "zod": "^4.3.6",
38
+ "@aigne/model-base": "1.74.0-beta.11"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/bun": "^1.3.6",
@@ -45,9 +45,7 @@
45
45
  "rimraf": "^6.1.2",
46
46
  "tsdown": "0.20.0-beta.3",
47
47
  "typescript": "5.9.2",
48
- "@aigne/scripts": "0.0.0",
49
- "@aigne/typescript-config": "0.0.0",
50
- "@aigne/utils": "1.74.0-beta.1"
48
+ "@aigne/typescript-config": "0.0.0"
51
49
  },
52
50
  "scripts": {
53
51
  "build": "tsdown",
package/LICENSE.md DELETED
@@ -1,93 +0,0 @@
1
- Elastic License 2.0
2
-
3
- URL: https://www.elastic.co/licensing/elastic-license
4
-
5
- ## Acceptance
6
-
7
- By using the software, you agree to all of the terms and conditions below.
8
-
9
- ## Copyright License
10
-
11
- The licensor grants you a non-exclusive, royalty-free, worldwide,
12
- non-sublicensable, non-transferable license to use, copy, distribute, make
13
- available, and prepare derivative works of the software, in each case subject to
14
- the limitations and conditions below.
15
-
16
- ## Limitations
17
-
18
- You may not provide the software to third parties as a hosted or managed
19
- service, where the service provides users with access to any substantial set of
20
- the features or functionality of the software.
21
-
22
- You may not move, change, disable, or circumvent the license key functionality
23
- in the software, and you may not remove or obscure any functionality in the
24
- software that is protected by the license key.
25
-
26
- You may not alter, remove, or obscure any licensing, copyright, or other notices
27
- of the licensor in the software. Any use of the licensor’s trademarks is subject
28
- to applicable law.
29
-
30
- ## Patents
31
-
32
- The licensor grants you a license, under any patent claims the licensor can
33
- license, or becomes able to license, to make, have made, use, sell, offer for
34
- sale, import and have imported the software, in each case subject to the
35
- limitations and conditions in this license. This license does not cover any
36
- patent claims that you cause to be infringed by modifications or additions to
37
- the software. If you or your company make any written claim that the software
38
- infringes or contributes to infringement of any patent, your patent license for
39
- the software granted under these terms ends immediately. If your company makes
40
- such a claim, your patent license ends immediately for work on behalf of your
41
- company.
42
-
43
- ## Notices
44
-
45
- You must ensure that anyone who gets a copy of any part of the software from you
46
- also gets a copy of these terms.
47
-
48
- If you modify the software, you must include in any modified copies of the
49
- software prominent notices stating that you have modified the software.
50
-
51
- ## No Other Rights
52
-
53
- These terms do not imply any licenses other than those expressly granted in
54
- these terms.
55
-
56
- ## Termination
57
-
58
- If you use the software in violation of these terms, such use is not licensed,
59
- and your licenses will automatically terminate. If the licensor provides you
60
- with a notice of your violation, and you cease all violation of this license no
61
- later than 30 days after you receive that notice, your licenses will be
62
- reinstated retroactively. However, if you violate these terms after such
63
- reinstatement, any additional violation of these terms will cause your licenses
64
- to terminate automatically and permanently.
65
-
66
- ## No Liability
67
-
68
- *As far as the law allows, the software comes as is, without any warranty or
69
- condition, and the licensor will not be liable to you for any damages arising
70
- out of these terms or the use or nature of the software, under any kind of
71
- legal claim.*
72
-
73
- ## Definitions
74
-
75
- The **licensor** is the entity offering these terms, and the **software** is the
76
- software the licensor makes available under these terms, including any portion
77
- of it.
78
-
79
- **you** refers to the individual or entity agreeing to these terms.
80
-
81
- **your company** is any legal entity, sole proprietorship, or other kind of
82
- organization that you work for, plus all organizations that have control over,
83
- are under the control of, or are under common control with that
84
- organization. **control** means ownership of substantially all the assets of an
85
- entity, or the power to direct its management and policies by vote, contract, or
86
- otherwise. Control can be direct or indirect.
87
-
88
- **your licenses** are all the licenses granted to you for the software under
89
- these terms.
90
-
91
- **use** means anything you do with the software requiring one of your licenses.
92
-
93
- **trademark** means trademarks, service marks, and similar rights.