@aigne/doubao 1.74.0-beta.3 → 1.74.0-beta.5

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/README.md CHANGED
@@ -36,19 +36,19 @@ AIGNE Doubao SDK for integrating with Doubao AI models within the [AIGNE Framewo
36
36
  ### Using npm
37
37
 
38
38
  ```bash
39
- npm install @aigne/doubao @aigne/core
39
+ npm install @aigne/doubao @aigne/model-base
40
40
  ```
41
41
 
42
42
  ### Using yarn
43
43
 
44
44
  ```bash
45
- yarn add @aigne/doubao @aigne/core
45
+ yarn add @aigne/doubao @aigne/model-base
46
46
  ```
47
47
 
48
48
  ### Using pnpm
49
49
 
50
50
  ```bash
51
- pnpm add @aigne/doubao @aigne/core
51
+ pnpm add @aigne/doubao @aigne/model-base
52
52
  ```
53
53
 
54
54
  ## Basic Usage
@@ -90,7 +90,7 @@ console.log(result);
90
90
  // todo
91
91
 
92
92
  ```typescript file="test/doubao-chat-model.test.ts" region="example-doubao-chat-model-streaming"
93
- import { isAgentResponseDelta } from "@aigne/core";
93
+ import { isAgentResponseDelta } from "@aigne/model-base";
94
94
  import { DoubaoChatModel } from "@aigne/doubao";
95
95
 
96
96
  const model = new DoubaoChatModel({
@@ -1 +1 @@
1
- {"version":3,"file":"doubao-chat-model.d.cts","names":[],"sources":["../src/doubao-chat-model.ts"],"mappings":";;;;AAqBA;;;;;;;;;;;;;;;cAAa,eAAA,SAAwB,eAAA;EAAA,YAAA,OAAA,GACb,sBAAA;EAAA,UAAA,aAAA;AAAA"}
1
+ {"version":3,"file":"doubao-chat-model.d.cts","names":[],"sources":["../src/doubao-chat-model.ts"],"mappings":";;;;;AAqBA;;;;;;;;;;;;;;cAAa,eAAA,SAAwB,eAAA;cACvB,OAAA,GAAU,sBAAA;EAAA,UAQH,aAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"doubao-chat-model.d.mts","names":[],"sources":["../src/doubao-chat-model.ts"],"mappings":";;;;AAqBA;;;;;;;;;;;;;;;cAAa,eAAA,SAAwB,eAAA;EAAA,YAAA,OAAA,GACb,sBAAA;EAAA,UAAA,aAAA;AAAA"}
1
+ {"version":3,"file":"doubao-chat-model.d.mts","names":[],"sources":["../src/doubao-chat-model.ts"],"mappings":";;;;;AAqBA;;;;;;;;;;;;;;cAAa,eAAA,SAAwB,eAAA;cACvB,OAAA,GAAU,sBAAA;EAAA,UAQH,aAAA;AAAA"}
@@ -1,7 +1,7 @@
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
 
@@ -9,7 +9,7 @@ let zod = require("zod");
9
9
  const DOUBAO_DEFAULT_IMAGE_MODEL = "doubao-seedream-4-0-250828";
10
10
  const DOUBAO_BASE_URL = "https://ark.cn-beijing.volces.com/api/v3";
11
11
  const OUTPUT_MIME_TYPE = "image/jpeg";
12
- const doubaoImageModelInputSchema = _aigne_core.imageModelInputSchema.extend({});
12
+ const doubaoImageModelInputSchema = _aigne_model_base.imageModelInputSchema.extend({});
13
13
  const doubaoImageModelOptionsSchema = zod.z.object({
14
14
  apiKey: zod.z.string().optional(),
15
15
  baseURL: zod.z.string().optional(),
@@ -17,7 +17,7 @@ const doubaoImageModelOptionsSchema = zod.z.object({
17
17
  modelOptions: zod.z.object({}).optional(),
18
18
  clientOptions: zod.z.object({}).optional()
19
19
  });
20
- var DoubaoImageModel = class extends _aigne_core.ImageModel {
20
+ var DoubaoImageModel = class extends _aigne_model_base.ImageModel {
21
21
  constructor(options) {
22
22
  super({
23
23
  ...options,
@@ -25,7 +25,7 @@ var DoubaoImageModel = class extends _aigne_core.ImageModel {
25
25
  description: options?.description ?? "Draw or edit image by Doubao image models"
26
26
  });
27
27
  this.options = options;
28
- if (options) (0, _aigne_core_utils_type_utils.checkArguments)(this.name, doubaoImageModelOptionsSchema, options);
28
+ if (options) (0, _aigne_model_base_utils_type_utils.checkArguments)(this.name, doubaoImageModelOptionsSchema, options);
29
29
  }
30
30
  apiKeyEnvName = "DOUBAO_API_KEY";
31
31
  get credential() {
@@ -98,15 +98,15 @@ var DoubaoImageModel = class extends _aigne_core.ImageModel {
98
98
  ...input.modelOptions,
99
99
  ...input
100
100
  };
101
- const image = await Promise.all((0, _aigne_core_utils_type_utils.flat)(input.image).map((image$1) => this.transformFileType("file", image$1).then((file) => `data:${file.mimeType || "image/png"};base64,${file.data}`)));
101
+ const image = await Promise.all((0, _aigne_model_base_utils_type_utils.flat)(input.image).map((image$1) => this.transformFileType("file", image$1).then((file) => `data:${file.mimeType || "image/png"};base64,${file.data}`)));
102
102
  const body = {
103
- ...(0, _aigne_core_utils_camelize.snakelize)((0, _aigne_core_utils_type_utils.pick)(mergeInput, map[key])),
103
+ ...(0, _aigne_model_base_utils_camelize.snakelize)((0, _aigne_model_base_utils_type_utils.pick)(mergeInput, map[key])),
104
104
  model,
105
105
  response_format: "b64_json",
106
106
  watermark: mergeInput.watermark ?? false,
107
107
  image: image.length ? image : void 0
108
108
  };
109
- const response = await (0, _aigne_core_utils_fetch.fetch)((0, ufo.joinURL)(url, `/images/generations`), {
109
+ const response = await (0, _aigne_model_base_utils_fetch.fetch)((0, ufo.joinURL)(url, `/images/generations`), {
110
110
  method: "POST",
111
111
  headers: {
112
112
  Authorization: `Bearer ${apiKey}`,
@@ -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/doubao-image-model.d.ts
4
4
  interface DoubaoImageModelInput extends ImageModelInput {
@@ -31,7 +31,7 @@ declare class DoubaoImageModel extends ImageModel<DoubaoImageModelInput, DoubaoI
31
31
  };
32
32
  get modelOptions(): Omit<Partial<DoubaoImageModelInput>, "model"> | undefined;
33
33
  private extractDataObjects;
34
- process(input: DoubaoImageModelInput, _options: AgentInvokeOptions): Promise<ImageModelOutput>;
34
+ process(input: DoubaoImageModelInput, _options: ModelInvokeOptions): Promise<ImageModelOutput>;
35
35
  }
36
36
  //#endregion
37
37
  export { DoubaoImageModel, DoubaoImageModelInput, DoubaoImageModelOptions, DoubaoImageModelOutput };
@@ -1 +1 @@
1
- {"version":3,"file":"doubao-image-model.d.cts","names":[],"sources":["../src/doubao-image-model.ts"],"mappings":";;;UAmBiB,qBAAA,SAA8B,eAAA;EAAA,IAAA;EAAA,IAAA;EAAA,yBAAA;EAAA,gCAAA;IAAA,SAAA;EAAA;EAAA,MAAA;EAAA,aAAA;EAAA,SAAA;AAAA;AAAA,UAY9B,sBAAA,SAA+B,gBAAA;AAAA,UAE/B,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;EAAA,MAAA;EAAA,OAAA;EAAA,KAAA;EAAA,YAAA,GAIlC,IAAA,CAAK,OAAA,CAAQ,qBAAA;EAAA,aAAA,GACZ,MAAA;AAAA;AAAA,cAaL,gBAAA,SAAyB,UAAA,CAAW,qBAAA,EAAuB,sBAAA;EAAA,OAAA,GAChC,uBAAA;EAAA,YAAA,OAAA,GAAA,uBAAA;EAAA,UAAA,aAAA;EAAA,IAAA,WAAA;IAAA,GAAA;IAAA,MAAA;IAAA,KAAA;EAAA;EAAA,IAAA,aAAA,GAoBtB,IAAA,CAAA,OAAA,CAAA,qBAAA;EAAA,QAAA,kBAAA;EAAA,QAAA,KAAA,EA4BP,qBAAA,EAAA,QAAA,EACG,kBAAA,GACT,OAAA,CAAQ,gBAAA;AAAA"}
1
+ {"version":3,"file":"doubao-image-model.d.cts","names":[],"sources":["../src/doubao-image-model.ts"],"mappings":";;;UAmBiB,qBAAA,SAA8B,eAAA;EAC7C,IAAA;EACA,IAAA;EACA,yBAAA;EACA,gCAAA;IACE,SAAA;EAAA;EAEF,MAAA;EACA,aAAA;EACA,SAAA;AAAA;AAAA,UAGe,sBAAA,SAA+B,gBAAA;AAAA,UAE/B,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;EACjD,MAAA;EACA,OAAA;EACA,KAAA;EACA,YAAA,GAAe,IAAA,CAAK,OAAA,CAAQ,qBAAA;EAC5B,aAAA,GAAgB,MAAA;AAAA;AAAA,cAaL,gBAAA,SAAyB,UAAA,CAAW,qBAAA,EAAuB,sBAAA;EAC1C,OAAA,GAAU,uBAAA;cAAV,OAAA,GAAU,uBAAA;EAAA,UAU5B,aAAA;EAAA,IAEG,UAAA,CAAA;;;;;MAQT,YAAA,CAAA,GAAY,IAAA,CAAA,OAAA,CAAA,qBAAA;EAAA,QAIR,kBAAA;EAuBO,OAAA,CACb,KAAA,EAAO,qBAAA,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/doubao-image-model.d.ts
4
4
  interface DoubaoImageModelInput extends ImageModelInput {
@@ -31,7 +31,7 @@ declare class DoubaoImageModel extends ImageModel<DoubaoImageModelInput, DoubaoI
31
31
  };
32
32
  get modelOptions(): Omit<Partial<DoubaoImageModelInput>, "model"> | undefined;
33
33
  private extractDataObjects;
34
- process(input: DoubaoImageModelInput, _options: AgentInvokeOptions): Promise<ImageModelOutput>;
34
+ process(input: DoubaoImageModelInput, _options: ModelInvokeOptions): Promise<ImageModelOutput>;
35
35
  }
36
36
  //#endregion
37
37
  export { DoubaoImageModel, DoubaoImageModelInput, DoubaoImageModelOptions, DoubaoImageModelOutput };
@@ -1 +1 @@
1
- {"version":3,"file":"doubao-image-model.d.mts","names":[],"sources":["../src/doubao-image-model.ts"],"mappings":";;;UAmBiB,qBAAA,SAA8B,eAAA;EAAA,IAAA;EAAA,IAAA;EAAA,yBAAA;EAAA,gCAAA;IAAA,SAAA;EAAA;EAAA,MAAA;EAAA,aAAA;EAAA,SAAA;AAAA;AAAA,UAY9B,sBAAA,SAA+B,gBAAA;AAAA,UAE/B,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;EAAA,MAAA;EAAA,OAAA;EAAA,KAAA;EAAA,YAAA,GAIlC,IAAA,CAAK,OAAA,CAAQ,qBAAA;EAAA,aAAA,GACZ,MAAA;AAAA;AAAA,cAaL,gBAAA,SAAyB,UAAA,CAAW,qBAAA,EAAuB,sBAAA;EAAA,OAAA,GAChC,uBAAA;EAAA,YAAA,OAAA,GAAA,uBAAA;EAAA,UAAA,aAAA;EAAA,IAAA,WAAA;IAAA,GAAA;IAAA,MAAA;IAAA,KAAA;EAAA;EAAA,IAAA,aAAA,GAoBtB,IAAA,CAAA,OAAA,CAAA,qBAAA;EAAA,QAAA,kBAAA;EAAA,QAAA,KAAA,EA4BP,qBAAA,EAAA,QAAA,EACG,kBAAA,GACT,OAAA,CAAQ,gBAAA;AAAA"}
1
+ {"version":3,"file":"doubao-image-model.d.mts","names":[],"sources":["../src/doubao-image-model.ts"],"mappings":";;;UAmBiB,qBAAA,SAA8B,eAAA;EAC7C,IAAA;EACA,IAAA;EACA,yBAAA;EACA,gCAAA;IACE,SAAA;EAAA;EAEF,MAAA;EACA,aAAA;EACA,SAAA;AAAA;AAAA,UAGe,sBAAA,SAA+B,gBAAA;AAAA,UAE/B,uBAAA,SACP,iBAAA,CAAkB,qBAAA,EAAuB,sBAAA;EACjD,MAAA;EACA,OAAA;EACA,KAAA;EACA,YAAA,GAAe,IAAA,CAAK,OAAA,CAAQ,qBAAA;EAC5B,aAAA,GAAgB,MAAA;AAAA;AAAA,cAaL,gBAAA,SAAyB,UAAA,CAAW,qBAAA,EAAuB,sBAAA;EAC1C,OAAA,GAAU,uBAAA;cAAV,OAAA,GAAU,uBAAA;EAAA,UAU5B,aAAA;EAAA,IAEG,UAAA,CAAA;;;;;MAQT,YAAA,CAAA,GAAY,IAAA,CAAA,OAAA,CAAA,qBAAA;EAAA,QAIR,kBAAA;EAuBO,OAAA,CACb,KAAA,EAAO,qBAAA,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":"doubao-image-model.mjs","names":["key","image"],"sources":["../src/doubao-image-model.ts"],"sourcesContent":["import {\n type AgentInvokeOptions,\n type FileUnionContent,\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 DOUBAO_DEFAULT_IMAGE_MODEL = \"doubao-seedream-4-0-250828\";\nconst DOUBAO_BASE_URL = \"https://ark.cn-beijing.volces.com/api/v3\";\nconst OUTPUT_MIME_TYPE = \"image/jpeg\";\n\nexport interface DoubaoImageModelInput extends ImageModelInput {\n size?: string;\n seed?: number;\n sequentialImageGeneration?: boolean;\n sequentialImageGenerationOptions?: {\n maxImages: number;\n };\n stream?: boolean;\n guidanceScale?: number;\n watermark?: boolean;\n}\n\nexport interface DoubaoImageModelOutput extends ImageModelOutput {}\n\nexport interface DoubaoImageModelOptions\n extends ImageModelOptions<DoubaoImageModelInput, DoubaoImageModelOutput> {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n modelOptions?: Omit<Partial<DoubaoImageModelInput>, \"model\">;\n clientOptions?: Record<string, any>;\n}\n\nconst doubaoImageModelInputSchema = imageModelInputSchema.extend({});\n\nconst doubaoImageModelOptionsSchema = 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 DoubaoImageModel extends ImageModel<DoubaoImageModelInput, DoubaoImageModelOutput> {\n constructor(public override options?: DoubaoImageModelOptions) {\n super({\n ...options,\n inputSchema: doubaoImageModelInputSchema,\n description: options?.description ?? \"Draw or edit image by Doubao image models\",\n });\n\n if (options) checkArguments(this.name, doubaoImageModelOptionsSchema, options);\n }\n\n protected apiKeyEnvName = \"DOUBAO_API_KEY\";\n\n override get credential() {\n return {\n url: this.options?.baseURL || process.env.DOUBAO_BASE_URL || DOUBAO_BASE_URL,\n apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],\n model: this.options?.model || DOUBAO_DEFAULT_IMAGE_MODEL,\n };\n }\n\n get modelOptions() {\n return this.options?.modelOptions;\n }\n\n private extractDataObjects(text: string) {\n const dataObjects = [];\n const lines = text.split(\"\\n\");\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n if (trimmed.startsWith(\"data:\")) {\n const jsonPart = trimmed.slice(5).trim();\n if (jsonPart === \"[DONE]\") continue;\n\n try {\n const obj = JSON.parse(jsonPart);\n dataObjects.push(obj);\n } catch (e) {\n console.warn(\"Failed to parse JSON data object:\", jsonPart, e);\n }\n }\n }\n\n return dataObjects;\n }\n\n override async process(\n input: DoubaoImageModelInput,\n _options: AgentInvokeOptions,\n ): Promise<ImageModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\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\n const map: { [key: string]: string[] } = {\n \"doubao-seedream-4\": [\n \"model\",\n \"prompt\",\n \"size\",\n \"sequentialImageGeneration\",\n \"sequentialImageGenerationOptions\",\n \"stream\",\n \"responseFormat\",\n \"watermark\",\n ],\n \"doubao-seedream-3-0-t2i\": [\n \"model\",\n \"prompt\",\n \"size\",\n \"seed\",\n \"guidanceScale\",\n \"responseFormat\",\n \"watermark\",\n ],\n \"doubao-seededit-3-0-i2i\": [\n \"model\",\n \"prompt\",\n \"size\",\n \"seed\",\n \"guidanceScale\",\n \"responseFormat\",\n \"watermark\",\n ],\n };\n\n const key = Object.keys(map).find((key) => model.includes(key));\n if (!key) {\n throw new Error(`${this.name} only support ${Object.keys(map).join(\", \")}`);\n }\n\n if (!map[key]) {\n throw new Error(`${this.name} only support ${Object.keys(map).join(\", \")}`);\n }\n\n const mergeInput = { ...this.modelOptions, ...input.modelOptions, ...input };\n\n const image = await Promise.all(\n flat(input.image).map((image) =>\n this.transformFileType(\"file\", image).then(\n (file) => `data:${file.mimeType || \"image/png\"};base64,${file.data}`,\n ),\n ),\n );\n\n const body = {\n ...snakelize(pick(mergeInput, map[key])),\n model,\n response_format: \"b64_json\",\n watermark: mergeInput.watermark ?? false,\n image: image.length ? image : undefined,\n };\n\n const response = await fetch(joinURL(url, `/images/generations`), {\n method: \"POST\",\n headers: { Authorization: `Bearer ${apiKey}`, \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n timeout: this.options?.clientOptions?.timeout ?? 60 * 1000,\n });\n\n if (body.stream) {\n if (!response.body) throw new Error(\"Streaming not supported in this environment\");\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let done = false;\n let buffer = \"\";\n\n while (!done) {\n const { value, done: doneReading } = await reader.read();\n done = doneReading;\n if (value) {\n buffer += decoder.decode(value);\n }\n }\n\n const dataObjects = this.extractDataObjects(buffer);\n const error = dataObjects.find((i) => i.type === \"image_generation.partial_failed\");\n if (error) {\n throw new Error(`Doubao API error: ${error.error.message}`);\n }\n\n const completed = dataObjects.find((i) => i.type === \"image_generation.completed\");\n\n return {\n images: dataObjects\n .filter((i) => i.type === \"image_generation.partial_succeeded\")\n .map<FileUnionContent>((i) => {\n if (typeof i.url === \"string\")\n return { type: \"url\", url: i.url, mimeType: OUTPUT_MIME_TYPE };\n if (typeof i.b64_json === \"string\")\n return { type: \"file\", data: i.b64_json, mimeType: OUTPUT_MIME_TYPE };\n throw new Error(\"Image response does not contain a valid URL or base64 data\");\n }),\n usage: { inputTokens: 0, outputTokens: completed?.usage.output_tokens || 0 },\n model: model,\n };\n }\n\n const data: {\n model: string;\n usage?: { output_tokens?: number };\n data: { url?: string; b64_json?: string }[];\n error?: { message: string };\n } = await response.json();\n\n if (data.error) {\n throw new Error(`Doubao API error: ${data.error.message}`);\n }\n\n return {\n images: data.data.map<FileUnionContent>((item) => {\n if (item.url) return { type: \"url\", url: item.url, mimeType: OUTPUT_MIME_TYPE };\n if (item.b64_json) return { type: \"file\", data: item.b64_json, mimeType: OUTPUT_MIME_TYPE };\n throw new Error(\"Image response does not contain a valid URL or base64 data\");\n }),\n usage: {\n inputTokens: 0,\n outputTokens: data?.usage?.output_tokens || 0,\n },\n model: data.model,\n };\n }\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,6BAA6B;AACnC,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AAyBzB,MAAM,8BAA8B,sBAAsB,OAAO,EAAE,CAAC;AAEpE,MAAM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,OAAO,iBAAiB;IAC7C;GACD,OAAO,KAAK;GACb"}
1
+ {"version":3,"file":"doubao-image-model.mjs","names":["key","image"],"sources":["../src/doubao-image-model.ts"],"sourcesContent":["import {\n type FileUnionContent,\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 DOUBAO_DEFAULT_IMAGE_MODEL = \"doubao-seedream-4-0-250828\";\nconst DOUBAO_BASE_URL = \"https://ark.cn-beijing.volces.com/api/v3\";\nconst OUTPUT_MIME_TYPE = \"image/jpeg\";\n\nexport interface DoubaoImageModelInput extends ImageModelInput {\n size?: string;\n seed?: number;\n sequentialImageGeneration?: boolean;\n sequentialImageGenerationOptions?: {\n maxImages: number;\n };\n stream?: boolean;\n guidanceScale?: number;\n watermark?: boolean;\n}\n\nexport interface DoubaoImageModelOutput extends ImageModelOutput {}\n\nexport interface DoubaoImageModelOptions\n extends ImageModelOptions<DoubaoImageModelInput, DoubaoImageModelOutput> {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n modelOptions?: Omit<Partial<DoubaoImageModelInput>, \"model\">;\n clientOptions?: Record<string, any>;\n}\n\nconst doubaoImageModelInputSchema = imageModelInputSchema.extend({});\n\nconst doubaoImageModelOptionsSchema = 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 DoubaoImageModel extends ImageModel<DoubaoImageModelInput, DoubaoImageModelOutput> {\n constructor(public override options?: DoubaoImageModelOptions) {\n super({\n ...options,\n inputSchema: doubaoImageModelInputSchema,\n description: options?.description ?? \"Draw or edit image by Doubao image models\",\n });\n\n if (options) checkArguments(this.name, doubaoImageModelOptionsSchema, options);\n }\n\n protected apiKeyEnvName = \"DOUBAO_API_KEY\";\n\n override get credential() {\n return {\n url: this.options?.baseURL || process.env.DOUBAO_BASE_URL || DOUBAO_BASE_URL,\n apiKey: this.options?.apiKey || process.env[this.apiKeyEnvName],\n model: this.options?.model || DOUBAO_DEFAULT_IMAGE_MODEL,\n };\n }\n\n get modelOptions() {\n return this.options?.modelOptions;\n }\n\n private extractDataObjects(text: string) {\n const dataObjects = [];\n const lines = text.split(\"\\n\");\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n if (trimmed.startsWith(\"data:\")) {\n const jsonPart = trimmed.slice(5).trim();\n if (jsonPart === \"[DONE]\") continue;\n\n try {\n const obj = JSON.parse(jsonPart);\n dataObjects.push(obj);\n } catch (e) {\n console.warn(\"Failed to parse JSON data object:\", jsonPart, e);\n }\n }\n }\n\n return dataObjects;\n }\n\n override async process(\n input: DoubaoImageModelInput,\n _options: ModelInvokeOptions,\n ): Promise<ImageModelOutput> {\n const model = input.modelOptions?.model || this.credential.model;\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\n const map: { [key: string]: string[] } = {\n \"doubao-seedream-4\": [\n \"model\",\n \"prompt\",\n \"size\",\n \"sequentialImageGeneration\",\n \"sequentialImageGenerationOptions\",\n \"stream\",\n \"responseFormat\",\n \"watermark\",\n ],\n \"doubao-seedream-3-0-t2i\": [\n \"model\",\n \"prompt\",\n \"size\",\n \"seed\",\n \"guidanceScale\",\n \"responseFormat\",\n \"watermark\",\n ],\n \"doubao-seededit-3-0-i2i\": [\n \"model\",\n \"prompt\",\n \"size\",\n \"seed\",\n \"guidanceScale\",\n \"responseFormat\",\n \"watermark\",\n ],\n };\n\n const key = Object.keys(map).find((key) => model.includes(key));\n if (!key) {\n throw new Error(`${this.name} only support ${Object.keys(map).join(\", \")}`);\n }\n\n if (!map[key]) {\n throw new Error(`${this.name} only support ${Object.keys(map).join(\", \")}`);\n }\n\n const mergeInput = { ...this.modelOptions, ...input.modelOptions, ...input };\n\n const image = await Promise.all(\n flat(input.image).map((image) =>\n this.transformFileType(\"file\", image).then(\n (file) => `data:${file.mimeType || \"image/png\"};base64,${file.data}`,\n ),\n ),\n );\n\n const body = {\n ...snakelize(pick(mergeInput, map[key])),\n model,\n response_format: \"b64_json\",\n watermark: mergeInput.watermark ?? false,\n image: image.length ? image : undefined,\n };\n\n const response = await fetch(joinURL(url, `/images/generations`), {\n method: \"POST\",\n headers: { Authorization: `Bearer ${apiKey}`, \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n timeout: this.options?.clientOptions?.timeout ?? 60 * 1000,\n });\n\n if (body.stream) {\n if (!response.body) throw new Error(\"Streaming not supported in this environment\");\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let done = false;\n let buffer = \"\";\n\n while (!done) {\n const { value, done: doneReading } = await reader.read();\n done = doneReading;\n if (value) {\n buffer += decoder.decode(value);\n }\n }\n\n const dataObjects = this.extractDataObjects(buffer);\n const error = dataObjects.find((i) => i.type === \"image_generation.partial_failed\");\n if (error) {\n throw new Error(`Doubao API error: ${error.error.message}`);\n }\n\n const completed = dataObjects.find((i) => i.type === \"image_generation.completed\");\n\n return {\n images: dataObjects\n .filter((i) => i.type === \"image_generation.partial_succeeded\")\n .map<FileUnionContent>((i) => {\n if (typeof i.url === \"string\")\n return { type: \"url\", url: i.url, mimeType: OUTPUT_MIME_TYPE };\n if (typeof i.b64_json === \"string\")\n return { type: \"file\", data: i.b64_json, mimeType: OUTPUT_MIME_TYPE };\n throw new Error(\"Image response does not contain a valid URL or base64 data\");\n }),\n usage: { inputTokens: 0, outputTokens: completed?.usage.output_tokens || 0 },\n model: model,\n };\n }\n\n const data: {\n model: string;\n usage?: { output_tokens?: number };\n data: { url?: string; b64_json?: string }[];\n error?: { message: string };\n } = await response.json();\n\n if (data.error) {\n throw new Error(`Doubao API error: ${data.error.message}`);\n }\n\n return {\n images: data.data.map<FileUnionContent>((item) => {\n if (item.url) return { type: \"url\", url: item.url, mimeType: OUTPUT_MIME_TYPE };\n if (item.b64_json) return { type: \"file\", data: item.b64_json, mimeType: OUTPUT_MIME_TYPE };\n throw new Error(\"Image response does not contain a valid URL or base64 data\");\n }),\n usage: {\n inputTokens: 0,\n outputTokens: data?.usage?.output_tokens || 0,\n },\n model: data.model,\n };\n }\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,6BAA6B;AACnC,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AAyBzB,MAAM,8BAA8B,sBAAsB,OAAO,EAAE,CAAC;AAEpE,MAAM,gCAAgC,EAAE,OAAO;CAC7C,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU;CACrC,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU;CACvC,CAAC;AAEF,IAAa,mBAAb,cAAsC,WAA0D;CAC9F,YAAY,AAAgB,SAAmC;AAC7D,QAAM;GACJ,GAAG;GACH,aAAa;GACb,aAAa,SAAS,eAAe;GACtC,CAAC;EALwB;AAO1B,MAAI,QAAS,gBAAe,KAAK,MAAM,+BAA+B,QAAQ;;CAGhF,AAAU,gBAAgB;CAE1B,IAAa,aAAa;AACxB,SAAO;GACL,KAAK,KAAK,SAAS,WAAW,QAAQ,IAAI,mBAAmB;GAC7D,QAAQ,KAAK,SAAS,UAAU,QAAQ,IAAI,KAAK;GACjD,OAAO,KAAK,SAAS,SAAS;GAC/B;;CAGH,IAAI,eAAe;AACjB,SAAO,KAAK,SAAS;;CAGvB,AAAQ,mBAAmB,MAAc;EACvC,MAAM,cAAc,EAAE;EACtB,MAAM,QAAQ,KAAK,MAAM,KAA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,OAAO;KAAE,aAAa;KAAG,cAAc,WAAW,MAAM,iBAAiB;KAAG;IACrE;IACR;;EAGH,MAAM,OAKF,MAAM,SAAS,MAAM;AAEzB,MAAI,KAAK,MACP,OAAM,IAAI,MAAM,qBAAqB,KAAK,MAAM,UAAU;AAG5D,SAAO;GACL,QAAQ,KAAK,KAAK,KAAuB,SAAS;AAChD,QAAI,KAAK,IAAK,QAAO;KAAE,MAAM;KAAO,KAAK,KAAK;KAAK,UAAU;KAAkB;AAC/E,QAAI,KAAK,SAAU,QAAO;KAAE,MAAM;KAAQ,MAAM,KAAK;KAAU,UAAU;KAAkB;AAC3F,UAAM,IAAI,MAAM,6DAA6D;KAC7E;GACF,OAAO;IACL,aAAa;IACb,cAAc,MAAM,OAAO,iBAAiB;IAC7C;GACD,OAAO,KAAK;GACb"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/doubao",
3
- "version": "1.74.0-beta.3",
3
+ "version": "1.74.0-beta.5",
4
4
  "description": "AIGNE doubao SDK for integrating with doubao AI models",
5
5
  "license": "Elastic-2.0",
6
6
  "publishConfig": {
@@ -35,8 +35,8 @@
35
35
  "dependencies": {
36
36
  "ufo": "^1.6.1",
37
37
  "zod": "^3.25.67",
38
- "@aigne/core": "1.74.0-beta.3",
39
- "@aigne/openai": "^1.74.0-beta.3"
38
+ "@aigne/openai": "^1.74.0-beta.5",
39
+ "@aigne/model-base": "1.74.0-beta.5"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/bun": "^1.3.6",
@@ -46,9 +46,7 @@
46
46
  "rimraf": "^6.1.2",
47
47
  "tsdown": "0.20.0-beta.3",
48
48
  "typescript": "5.9.2",
49
- "@aigne/scripts": "0.0.0",
50
- "@aigne/typescript-config": "0.0.0",
51
- "@aigne/utils": "1.74.0-beta.3"
49
+ "@aigne/typescript-config": "0.0.0"
52
50
  },
53
51
  "scripts": {
54
52
  "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.