@aigne/aigne-hub 0.7.0 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.0](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.7.0...aigne-hub-v0.8.0) (2025-08-27)
4
+
5
+
6
+ ### Features
7
+
8
+ * **models:** support aigne hub models ([#416](https://github.com/AIGNE-io/aigne-framework/issues/416)) ([b4f014c](https://github.com/AIGNE-io/aigne-framework/commit/b4f014cf5ed08ef930d3ddfc278d3610e64c6af3))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @aigne/anthropic bumped to 0.11.11
16
+ * @aigne/bedrock bumped to 0.9.11
17
+ * @aigne/core bumped to 1.56.0
18
+ * @aigne/deepseek bumped to 0.7.30
19
+ * @aigne/doubao bumped to 1.0.24
20
+ * @aigne/gemini bumped to 0.11.0
21
+ * @aigne/ideogram bumped to 0.3.0
22
+ * @aigne/ollama bumped to 0.7.30
23
+ * @aigne/open-router bumped to 0.7.30
24
+ * @aigne/openai bumped to 0.13.1
25
+ * @aigne/poe bumped to 1.0.10
26
+ * @aigne/transport bumped to 0.14.10
27
+ * @aigne/xai bumped to 0.7.30
28
+ * devDependencies
29
+ * @aigne/test-utils bumped to 0.5.37
30
+
3
31
  ## [0.7.0](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.6.10...aigne-hub-v0.7.0) (2025-08-27)
4
32
 
5
33
 
@@ -0,0 +1,16 @@
1
+ import { type AgentProcessResult, ImageModel, type ImageModelInput, type ImageModelOutput } from "@aigne/core";
2
+ import { BaseClient, type BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
3
+ import { type AIGNEHubImageModelOptions } from "./utils/type.js";
4
+ export declare class AIGNEHubImageModel extends ImageModel {
5
+ options: AIGNEHubImageModelOptions;
6
+ constructor(options: AIGNEHubImageModelOptions);
7
+ protected _client?: Promise<BaseClient>;
8
+ get client(): Promise<BaseClient>;
9
+ private _credential?;
10
+ get credential(): Promise<{
11
+ url: string;
12
+ apiKey?: string;
13
+ model: string;
14
+ }>;
15
+ process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ImageModelOutput>>;
16
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AIGNEHubImageModel = void 0;
4
+ const core_1 = require("@aigne/core");
5
+ const type_utils_js_1 = require("@aigne/core/utils/type-utils.js");
6
+ const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
7
+ const base_client_js_1 = require("@aigne/transport/http-client/base-client.js");
8
+ const ufo_1 = require("ufo");
9
+ const blocklet_js_1 = require("./utils/blocklet.js");
10
+ const constants_js_1 = require("./utils/constants.js");
11
+ const type_js_1 = require("./utils/type.js");
12
+ class AIGNEHubImageModel extends core_1.ImageModel {
13
+ options;
14
+ constructor(options) {
15
+ (0, type_utils_js_1.checkArguments)("AIGNEHubImageModel", type_js_1.aigneHubModelOptionsSchema, options);
16
+ super();
17
+ this.options = options;
18
+ }
19
+ _client;
20
+ get client() {
21
+ this._client ??= this.credential.then(({ url, apiKey, model }) => {
22
+ const options = { ...this.options, url, apiKey, model };
23
+ return new base_client_js_1.BaseClient(options);
24
+ });
25
+ return this._client;
26
+ }
27
+ _credential;
28
+ get credential() {
29
+ this._credential ??= (0, blocklet_js_1.getAIGNEHubMountPoint)(this.options.url ||
30
+ this.options.baseURL ||
31
+ process.env.BLOCKLET_AIGNE_API_URL ||
32
+ process.env.AIGNE_HUB_API_URL ||
33
+ constants_js_1.AIGNE_HUB_URL, constants_js_1.AIGNE_HUB_BLOCKLET_DID).then((url) => {
34
+ const path = "/api/v2/image";
35
+ const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
36
+ let credentialOptions = {};
37
+ try {
38
+ credentialOptions =
39
+ typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
40
+ }
41
+ catch (err) {
42
+ console.error(err);
43
+ }
44
+ return {
45
+ ...credentialOptions,
46
+ url: url.endsWith(path) ? url : (0, ufo_1.joinURL)(url, path),
47
+ apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY || credentialOptions.apiKey,
48
+ model: this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL || constants_js_1.AIGNE_HUB_IMAGE_MODEL,
49
+ };
50
+ });
51
+ return this._credential;
52
+ }
53
+ async process(input, options) {
54
+ const { BLOCKLET_APP_PID, ABT_NODE_DID } = index_js_1.nodejs.env;
55
+ const clientId = this.options?.clientOptions?.clientId ||
56
+ BLOCKLET_APP_PID ||
57
+ ABT_NODE_DID ||
58
+ `@aigne/aigne-hub:${typeof process !== "undefined" ? index_js_1.nodejs.os.hostname() : "unknown"}`;
59
+ const response = await (await this.client).__invoke(undefined, input, {
60
+ ...options,
61
+ streaming: false,
62
+ fetchOptions: {
63
+ ...options.fetchOptions,
64
+ headers: {
65
+ ...options.fetchOptions?.headers,
66
+ "x-aigne-hub-client-did": clientId,
67
+ },
68
+ },
69
+ });
70
+ return {
71
+ images: response.images,
72
+ usage: {
73
+ inputTokens: response.usage?.inputTokens ?? 0,
74
+ outputTokens: response.usage?.outputTokens ?? 0,
75
+ aigneHubCredits: response.usage?.aigneHubCredits,
76
+ },
77
+ model: response?.model,
78
+ };
79
+ }
80
+ }
81
+ exports.AIGNEHubImageModel = AIGNEHubImageModel;
@@ -1,15 +1,6 @@
1
- import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOptions, type ChatModelOutput } from "@aigne/core";
2
- import type { OpenAIChatModelOptions } from "@aigne/openai";
1
+ import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
3
2
  import { BaseClient, type BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
4
- export interface AIGNEHubChatModelOptions {
5
- url?: string;
6
- apiKey?: string;
7
- model?: string;
8
- modelOptions?: ChatModelOptions;
9
- clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
10
- clientId?: string;
11
- };
12
- }
3
+ import { type AIGNEHubChatModelOptions } from "./utils/type.js";
13
4
  export declare class AIGNEHubChatModel extends ChatModel {
14
5
  options: AIGNEHubChatModelOptions;
15
6
  constructor(options: AIGNEHubChatModelOptions);
@@ -6,29 +6,13 @@ const type_utils_js_1 = require("@aigne/core/utils/type-utils.js");
6
6
  const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
7
7
  const base_client_js_1 = require("@aigne/transport/http-client/base-client.js");
8
8
  const ufo_1 = require("ufo");
9
- const zod_1 = require("zod");
10
9
  const blocklet_js_1 = require("./utils/blocklet.js");
11
10
  const constants_js_1 = require("./utils/constants.js");
12
- const aigneHubChatModelOptionsSchema = zod_1.z.object({
13
- url: zod_1.z.string().optional(),
14
- apiKey: zod_1.z.string().optional(),
15
- model: zod_1.z.string().optional(),
16
- modelOptions: zod_1.z
17
- .object({
18
- model: zod_1.z.string().optional(),
19
- temperature: zod_1.z.number().optional(),
20
- topP: zod_1.z.number().optional(),
21
- frequencyPenalty: zod_1.z.number().optional(),
22
- presencePenalty: zod_1.z.number().optional(),
23
- parallelToolCalls: zod_1.z.boolean().optional().default(true),
24
- })
25
- .optional(),
26
- clientOptions: zod_1.z.object({}).optional(),
27
- });
11
+ const type_js_1 = require("./utils/type.js");
28
12
  class AIGNEHubChatModel extends core_1.ChatModel {
29
13
  options;
30
14
  constructor(options) {
31
- (0, type_utils_js_1.checkArguments)("AIGNEHubChatModel", aigneHubChatModelOptionsSchema, options);
15
+ (0, type_utils_js_1.checkArguments)("AIGNEHubChatModel", type_js_1.aigneHubModelOptionsSchema, options);
32
16
  super();
33
17
  this.options = options;
34
18
  }
@@ -42,7 +26,8 @@ class AIGNEHubChatModel extends core_1.ChatModel {
42
26
  }
43
27
  _credential;
44
28
  get credential() {
45
- this._credential = (0, blocklet_js_1.getAIGNEHubMountPoint)(this.options.url ||
29
+ this._credential ??= (0, blocklet_js_1.getAIGNEHubMountPoint)(this.options.url ||
30
+ this.options.baseURL ||
46
31
  process.env.BLOCKLET_AIGNE_API_URL ||
47
32
  process.env.AIGNE_HUB_API_URL ||
48
33
  constants_js_1.AIGNE_HUB_URL, constants_js_1.AIGNE_HUB_BLOCKLET_DID).then((url) => {
@@ -1,6 +1,6 @@
1
- import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
1
+ import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput, ImageModel, type ImageModelInput, type ImageModelOutput } from "@aigne/core";
2
2
  import type { BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
3
- import type { AIGNEHubChatModelOptions } from "./aigne-hub-model.js";
3
+ import type { AIGNEHubChatModelOptions, AIGNEHubImageModelOptions } from "./utils/type.js";
4
4
  export * from "./utils/blocklet.js";
5
5
  export * from "./utils/constants.js";
6
6
  export * from "./utils/model.js";
@@ -16,3 +16,15 @@ export declare class AIGNEHubChatModel extends ChatModel {
16
16
  }>;
17
17
  process(input: ChatModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ChatModelOutput>>;
18
18
  }
19
+ export declare class AIGNEHubImageModel extends ImageModel {
20
+ options: AIGNEHubImageModelOptions;
21
+ static load(options: AIGNEHubImageModelOptions): Promise<AIGNEHubImageModel>;
22
+ constructor(options: AIGNEHubImageModelOptions);
23
+ protected client: ImageModel;
24
+ get credential(): import("@aigne/core/utils/type-utils.js").PromiseOrValue<{
25
+ url?: string;
26
+ apiKey?: string;
27
+ model?: string;
28
+ }>;
29
+ process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ImageModelOutput>>;
30
+ }
package/lib/cjs/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.AIGNEHubChatModel = void 0;
17
+ exports.AIGNEHubImageModel = exports.AIGNEHubChatModel = void 0;
18
18
  const core_1 = require("@aigne/core");
19
19
  const model_js_1 = require("./utils/model.js");
20
20
  __exportStar(require("./utils/blocklet.js"), exports);
@@ -46,3 +46,29 @@ class AIGNEHubChatModel extends core_1.ChatModel {
46
46
  }
47
47
  }
48
48
  exports.AIGNEHubChatModel = AIGNEHubChatModel;
49
+ class AIGNEHubImageModel extends core_1.ImageModel {
50
+ options;
51
+ static async load(options) {
52
+ return new AIGNEHubImageModel(options);
53
+ }
54
+ constructor(options) {
55
+ const provider = process.env.BLOCKLET_AIGNE_API_PROVIDER || AIGNEHubImageModel.name;
56
+ const { match, all } = (0, model_js_1.findImageModel)(provider);
57
+ if (!match) {
58
+ const available = all.map((m) => m.name).join(", ");
59
+ throw new Error(`Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
60
+ }
61
+ const client = match.create(options);
62
+ super({ name: client.name });
63
+ this.options = options;
64
+ this.client = client;
65
+ }
66
+ client;
67
+ get credential() {
68
+ return this.client.credential;
69
+ }
70
+ async process(input, options) {
71
+ return this.client.invoke(input, options);
72
+ }
73
+ }
74
+ exports.AIGNEHubImageModel = AIGNEHubImageModel;
@@ -1,3 +1,4 @@
1
1
  export declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
2
2
  export declare const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
3
3
  export declare const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
4
+ export declare const AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AIGNE_HUB_DEFAULT_MODEL = exports.AIGNE_HUB_BLOCKLET_DID = exports.AIGNE_HUB_URL = void 0;
3
+ exports.AIGNE_HUB_IMAGE_MODEL = exports.AIGNE_HUB_DEFAULT_MODEL = exports.AIGNE_HUB_BLOCKLET_DID = exports.AIGNE_HUB_URL = void 0;
4
4
  exports.AIGNE_HUB_URL = "https://hub.aigne.io/";
5
5
  exports.AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
6
6
  exports.AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
7
+ exports.AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
@@ -1,4 +1,4 @@
1
- import type { ChatModel, ChatModelOptions, ImageModel, ImageModelOptions } from "@aigne/core";
1
+ import type { ChatModel, ChatModelOptions, ImageModel } from "@aigne/core";
2
2
  export interface LoadableModel {
3
3
  name: string | string[];
4
4
  apiKeyEnvName?: string | string[];
@@ -14,8 +14,10 @@ export interface LoadableImageModel {
14
14
  name: string;
15
15
  apiKeyEnvName: string;
16
16
  create: (options: {
17
+ apiKey?: string;
18
+ url?: string;
17
19
  model?: string;
18
- modelOptions?: ImageModelOptions;
20
+ modelOptions?: any;
19
21
  }) => ImageModel;
20
22
  }
21
23
  export declare function availableImageModels(): LoadableImageModel[];
@@ -23,3 +25,7 @@ export declare function findModel(provider: string): {
23
25
  all: LoadableModel[];
24
26
  match: LoadableModel | undefined;
25
27
  };
28
+ export declare function findImageModel(provider: string): {
29
+ all: LoadableImageModel[];
30
+ match: LoadableImageModel | undefined;
31
+ };
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.availableModels = availableModels;
4
4
  exports.availableImageModels = availableImageModels;
5
5
  exports.findModel = findModel;
6
+ exports.findImageModel = findImageModel;
6
7
  const anthropic_1 = require("@aigne/anthropic");
7
8
  const bedrock_1 = require("@aigne/bedrock");
8
9
  const deepseek_1 = require("@aigne/deepseek");
@@ -16,6 +17,7 @@ const poe_1 = require("@aigne/poe");
16
17
  const xai_1 = require("@aigne/xai");
17
18
  const node_http_handler_1 = require("@smithy/node-http-handler");
18
19
  const https_proxy_agent_1 = require("https-proxy-agent");
20
+ const aigne_hub_image_model_js_1 = require("../aigne-hub-image-model.js");
19
21
  const aigne_hub_model_js_1 = require("../aigne-hub-model.js");
20
22
  const getClientOptions = () => {
21
23
  const proxy = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy"]
@@ -105,32 +107,22 @@ function availableImageModels() {
105
107
  {
106
108
  name: openai_1.OpenAIImageModel.name,
107
109
  apiKeyEnvName: "OPENAI_API_KEY",
108
- create: (params) => new openai_1.OpenAIImageModel({
109
- model: params.model,
110
- clientOptions,
111
- ...(params.modelOptions && {
112
- modelOptions: params.modelOptions,
113
- }),
114
- }),
110
+ create: (params) => new openai_1.OpenAIImageModel({ ...params, clientOptions }),
115
111
  },
116
112
  {
117
113
  name: gemini_1.GeminiImageModel.name,
118
114
  apiKeyEnvName: "GEMINI_API_KEY",
119
- create: (params) => new gemini_1.GeminiImageModel({
120
- ...params,
121
- clientOptions,
122
- ...(params.modelOptions && {
123
- modelOptions: params.modelOptions,
124
- }),
125
- }),
115
+ create: (params) => new gemini_1.GeminiImageModel({ ...params, clientOptions }),
126
116
  },
127
117
  {
128
118
  name: ideogram_1.IdeogramImageModel.name,
129
119
  apiKeyEnvName: "IDEOGRAM_API_KEY",
130
- create: (params) => new ideogram_1.IdeogramImageModel({
131
- ...params,
132
- modelOptions: params.modelOptions,
133
- }),
120
+ create: (params) => new ideogram_1.IdeogramImageModel({ ...params }),
121
+ },
122
+ {
123
+ name: aigne_hub_image_model_js_1.AIGNEHubImageModel.name,
124
+ apiKeyEnvName: "AIGNE_HUB_API_KEY",
125
+ create: (params) => new aigne_hub_image_model_js_1.AIGNEHubImageModel({ ...params, clientOptions }),
134
126
  },
135
127
  ];
136
128
  }
@@ -145,3 +137,9 @@ function findModel(provider) {
145
137
  });
146
138
  return { all, match };
147
139
  }
140
+ function findImageModel(provider) {
141
+ provider = provider.toLowerCase().replace(/-/g, "");
142
+ const all = availableImageModels();
143
+ const match = all.find((m) => m.name.toLowerCase().includes(provider));
144
+ return { all, match };
145
+ }
@@ -0,0 +1,72 @@
1
+ import type { ChatModelOptions } from "@aigne/core";
2
+ import type { OpenAIChatModelOptions } from "@aigne/openai";
3
+ import { z } from "zod";
4
+ export declare const aigneHubModelOptionsSchema: z.ZodObject<{
5
+ url: z.ZodOptional<z.ZodString>;
6
+ apiKey: z.ZodOptional<z.ZodString>;
7
+ model: z.ZodOptional<z.ZodString>;
8
+ modelOptions: z.ZodOptional<z.ZodObject<{
9
+ model: z.ZodOptional<z.ZodString>;
10
+ temperature: z.ZodOptional<z.ZodNumber>;
11
+ topP: z.ZodOptional<z.ZodNumber>;
12
+ frequencyPenalty: z.ZodOptional<z.ZodNumber>;
13
+ presencePenalty: z.ZodOptional<z.ZodNumber>;
14
+ parallelToolCalls: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ parallelToolCalls: boolean;
17
+ model?: string | undefined;
18
+ temperature?: number | undefined;
19
+ topP?: number | undefined;
20
+ frequencyPenalty?: number | undefined;
21
+ presencePenalty?: number | undefined;
22
+ }, {
23
+ model?: string | undefined;
24
+ temperature?: number | undefined;
25
+ topP?: number | undefined;
26
+ frequencyPenalty?: number | undefined;
27
+ presencePenalty?: number | undefined;
28
+ parallelToolCalls?: boolean | undefined;
29
+ }>>;
30
+ clientOptions: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ url?: string | undefined;
33
+ apiKey?: string | undefined;
34
+ model?: string | undefined;
35
+ modelOptions?: {
36
+ parallelToolCalls: boolean;
37
+ model?: string | undefined;
38
+ temperature?: number | undefined;
39
+ topP?: number | undefined;
40
+ frequencyPenalty?: number | undefined;
41
+ presencePenalty?: number | undefined;
42
+ } | undefined;
43
+ clientOptions?: {} | undefined;
44
+ }, {
45
+ url?: string | undefined;
46
+ apiKey?: string | undefined;
47
+ model?: string | undefined;
48
+ modelOptions?: {
49
+ model?: string | undefined;
50
+ temperature?: number | undefined;
51
+ topP?: number | undefined;
52
+ frequencyPenalty?: number | undefined;
53
+ presencePenalty?: number | undefined;
54
+ parallelToolCalls?: boolean | undefined;
55
+ } | undefined;
56
+ clientOptions?: {} | undefined;
57
+ }>;
58
+ export interface AIGNEHubChatModelOptions {
59
+ url?: string;
60
+ baseURL?: string;
61
+ apiKey?: string;
62
+ model?: string;
63
+ modelOptions?: ChatModelOptions;
64
+ clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
65
+ clientId?: string;
66
+ };
67
+ }
68
+ export type AIGNEHubImageModelOptions = Omit<AIGNEHubChatModelOptions, "modelOptions"> & {
69
+ modelOptions?: {
70
+ [key: string]: any;
71
+ };
72
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.aigneHubModelOptionsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.aigneHubModelOptionsSchema = zod_1.z.object({
6
+ url: zod_1.z.string().optional(),
7
+ apiKey: zod_1.z.string().optional(),
8
+ model: zod_1.z.string().optional(),
9
+ modelOptions: zod_1.z
10
+ .object({
11
+ model: zod_1.z.string().optional(),
12
+ temperature: zod_1.z.number().optional(),
13
+ topP: zod_1.z.number().optional(),
14
+ frequencyPenalty: zod_1.z.number().optional(),
15
+ presencePenalty: zod_1.z.number().optional(),
16
+ parallelToolCalls: zod_1.z.boolean().optional().default(true),
17
+ })
18
+ .optional(),
19
+ clientOptions: zod_1.z.object({}).optional(),
20
+ });
@@ -0,0 +1,16 @@
1
+ import { type AgentProcessResult, ImageModel, type ImageModelInput, type ImageModelOutput } from "@aigne/core";
2
+ import { BaseClient, type BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
3
+ import { type AIGNEHubImageModelOptions } from "./utils/type.js";
4
+ export declare class AIGNEHubImageModel extends ImageModel {
5
+ options: AIGNEHubImageModelOptions;
6
+ constructor(options: AIGNEHubImageModelOptions);
7
+ protected _client?: Promise<BaseClient>;
8
+ get client(): Promise<BaseClient>;
9
+ private _credential?;
10
+ get credential(): Promise<{
11
+ url: string;
12
+ apiKey?: string;
13
+ model: string;
14
+ }>;
15
+ process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ImageModelOutput>>;
16
+ }
@@ -1,15 +1,6 @@
1
- import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOptions, type ChatModelOutput } from "@aigne/core";
2
- import type { OpenAIChatModelOptions } from "@aigne/openai";
1
+ import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
3
2
  import { BaseClient, type BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
4
- export interface AIGNEHubChatModelOptions {
5
- url?: string;
6
- apiKey?: string;
7
- model?: string;
8
- modelOptions?: ChatModelOptions;
9
- clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
10
- clientId?: string;
11
- };
12
- }
3
+ import { type AIGNEHubChatModelOptions } from "./utils/type.js";
13
4
  export declare class AIGNEHubChatModel extends ChatModel {
14
5
  options: AIGNEHubChatModelOptions;
15
6
  constructor(options: AIGNEHubChatModelOptions);
@@ -1,6 +1,6 @@
1
- import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
1
+ import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput, ImageModel, type ImageModelInput, type ImageModelOutput } from "@aigne/core";
2
2
  import type { BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
3
- import type { AIGNEHubChatModelOptions } from "./aigne-hub-model.js";
3
+ import type { AIGNEHubChatModelOptions, AIGNEHubImageModelOptions } from "./utils/type.js";
4
4
  export * from "./utils/blocklet.js";
5
5
  export * from "./utils/constants.js";
6
6
  export * from "./utils/model.js";
@@ -16,3 +16,15 @@ export declare class AIGNEHubChatModel extends ChatModel {
16
16
  }>;
17
17
  process(input: ChatModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ChatModelOutput>>;
18
18
  }
19
+ export declare class AIGNEHubImageModel extends ImageModel {
20
+ options: AIGNEHubImageModelOptions;
21
+ static load(options: AIGNEHubImageModelOptions): Promise<AIGNEHubImageModel>;
22
+ constructor(options: AIGNEHubImageModelOptions);
23
+ protected client: ImageModel;
24
+ get credential(): import("@aigne/core/utils/type-utils.js").PromiseOrValue<{
25
+ url?: string;
26
+ apiKey?: string;
27
+ model?: string;
28
+ }>;
29
+ process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ImageModelOutput>>;
30
+ }
@@ -1,3 +1,4 @@
1
1
  export declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
2
2
  export declare const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
3
3
  export declare const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
4
+ export declare const AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
@@ -1,4 +1,4 @@
1
- import type { ChatModel, ChatModelOptions, ImageModel, ImageModelOptions } from "@aigne/core";
1
+ import type { ChatModel, ChatModelOptions, ImageModel } from "@aigne/core";
2
2
  export interface LoadableModel {
3
3
  name: string | string[];
4
4
  apiKeyEnvName?: string | string[];
@@ -14,8 +14,10 @@ export interface LoadableImageModel {
14
14
  name: string;
15
15
  apiKeyEnvName: string;
16
16
  create: (options: {
17
+ apiKey?: string;
18
+ url?: string;
17
19
  model?: string;
18
- modelOptions?: ImageModelOptions;
20
+ modelOptions?: any;
19
21
  }) => ImageModel;
20
22
  }
21
23
  export declare function availableImageModels(): LoadableImageModel[];
@@ -23,3 +25,7 @@ export declare function findModel(provider: string): {
23
25
  all: LoadableModel[];
24
26
  match: LoadableModel | undefined;
25
27
  };
28
+ export declare function findImageModel(provider: string): {
29
+ all: LoadableImageModel[];
30
+ match: LoadableImageModel | undefined;
31
+ };
@@ -0,0 +1,72 @@
1
+ import type { ChatModelOptions } from "@aigne/core";
2
+ import type { OpenAIChatModelOptions } from "@aigne/openai";
3
+ import { z } from "zod";
4
+ export declare const aigneHubModelOptionsSchema: z.ZodObject<{
5
+ url: z.ZodOptional<z.ZodString>;
6
+ apiKey: z.ZodOptional<z.ZodString>;
7
+ model: z.ZodOptional<z.ZodString>;
8
+ modelOptions: z.ZodOptional<z.ZodObject<{
9
+ model: z.ZodOptional<z.ZodString>;
10
+ temperature: z.ZodOptional<z.ZodNumber>;
11
+ topP: z.ZodOptional<z.ZodNumber>;
12
+ frequencyPenalty: z.ZodOptional<z.ZodNumber>;
13
+ presencePenalty: z.ZodOptional<z.ZodNumber>;
14
+ parallelToolCalls: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ parallelToolCalls: boolean;
17
+ model?: string | undefined;
18
+ temperature?: number | undefined;
19
+ topP?: number | undefined;
20
+ frequencyPenalty?: number | undefined;
21
+ presencePenalty?: number | undefined;
22
+ }, {
23
+ model?: string | undefined;
24
+ temperature?: number | undefined;
25
+ topP?: number | undefined;
26
+ frequencyPenalty?: number | undefined;
27
+ presencePenalty?: number | undefined;
28
+ parallelToolCalls?: boolean | undefined;
29
+ }>>;
30
+ clientOptions: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ url?: string | undefined;
33
+ apiKey?: string | undefined;
34
+ model?: string | undefined;
35
+ modelOptions?: {
36
+ parallelToolCalls: boolean;
37
+ model?: string | undefined;
38
+ temperature?: number | undefined;
39
+ topP?: number | undefined;
40
+ frequencyPenalty?: number | undefined;
41
+ presencePenalty?: number | undefined;
42
+ } | undefined;
43
+ clientOptions?: {} | undefined;
44
+ }, {
45
+ url?: string | undefined;
46
+ apiKey?: string | undefined;
47
+ model?: string | undefined;
48
+ modelOptions?: {
49
+ model?: string | undefined;
50
+ temperature?: number | undefined;
51
+ topP?: number | undefined;
52
+ frequencyPenalty?: number | undefined;
53
+ presencePenalty?: number | undefined;
54
+ parallelToolCalls?: boolean | undefined;
55
+ } | undefined;
56
+ clientOptions?: {} | undefined;
57
+ }>;
58
+ export interface AIGNEHubChatModelOptions {
59
+ url?: string;
60
+ baseURL?: string;
61
+ apiKey?: string;
62
+ model?: string;
63
+ modelOptions?: ChatModelOptions;
64
+ clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
65
+ clientId?: string;
66
+ };
67
+ }
68
+ export type AIGNEHubImageModelOptions = Omit<AIGNEHubChatModelOptions, "modelOptions"> & {
69
+ modelOptions?: {
70
+ [key: string]: any;
71
+ };
72
+ };
@@ -0,0 +1,16 @@
1
+ import { type AgentProcessResult, ImageModel, type ImageModelInput, type ImageModelOutput } from "@aigne/core";
2
+ import { BaseClient, type BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
3
+ import { type AIGNEHubImageModelOptions } from "./utils/type.js";
4
+ export declare class AIGNEHubImageModel extends ImageModel {
5
+ options: AIGNEHubImageModelOptions;
6
+ constructor(options: AIGNEHubImageModelOptions);
7
+ protected _client?: Promise<BaseClient>;
8
+ get client(): Promise<BaseClient>;
9
+ private _credential?;
10
+ get credential(): Promise<{
11
+ url: string;
12
+ apiKey?: string;
13
+ model: string;
14
+ }>;
15
+ process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ImageModelOutput>>;
16
+ }
@@ -0,0 +1,77 @@
1
+ import { ImageModel, } from "@aigne/core";
2
+ import { checkArguments } from "@aigne/core/utils/type-utils.js";
3
+ import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
4
+ import { BaseClient, } from "@aigne/transport/http-client/base-client.js";
5
+ import { joinURL } from "ufo";
6
+ import { getAIGNEHubMountPoint } from "./utils/blocklet.js";
7
+ import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_IMAGE_MODEL, AIGNE_HUB_URL } from "./utils/constants.js";
8
+ import { aigneHubModelOptionsSchema } from "./utils/type.js";
9
+ export class AIGNEHubImageModel extends ImageModel {
10
+ options;
11
+ constructor(options) {
12
+ checkArguments("AIGNEHubImageModel", aigneHubModelOptionsSchema, options);
13
+ super();
14
+ this.options = options;
15
+ }
16
+ _client;
17
+ get client() {
18
+ this._client ??= this.credential.then(({ url, apiKey, model }) => {
19
+ const options = { ...this.options, url, apiKey, model };
20
+ return new BaseClient(options);
21
+ });
22
+ return this._client;
23
+ }
24
+ _credential;
25
+ get credential() {
26
+ this._credential ??= getAIGNEHubMountPoint(this.options.url ||
27
+ this.options.baseURL ||
28
+ process.env.BLOCKLET_AIGNE_API_URL ||
29
+ process.env.AIGNE_HUB_API_URL ||
30
+ AIGNE_HUB_URL, AIGNE_HUB_BLOCKLET_DID).then((url) => {
31
+ const path = "/api/v2/image";
32
+ const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
33
+ let credentialOptions = {};
34
+ try {
35
+ credentialOptions =
36
+ typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
37
+ }
38
+ catch (err) {
39
+ console.error(err);
40
+ }
41
+ return {
42
+ ...credentialOptions,
43
+ url: url.endsWith(path) ? url : joinURL(url, path),
44
+ apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY || credentialOptions.apiKey,
45
+ model: this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL || AIGNE_HUB_IMAGE_MODEL,
46
+ };
47
+ });
48
+ return this._credential;
49
+ }
50
+ async process(input, options) {
51
+ const { BLOCKLET_APP_PID, ABT_NODE_DID } = nodejs.env;
52
+ const clientId = this.options?.clientOptions?.clientId ||
53
+ BLOCKLET_APP_PID ||
54
+ ABT_NODE_DID ||
55
+ `@aigne/aigne-hub:${typeof process !== "undefined" ? nodejs.os.hostname() : "unknown"}`;
56
+ const response = await (await this.client).__invoke(undefined, input, {
57
+ ...options,
58
+ streaming: false,
59
+ fetchOptions: {
60
+ ...options.fetchOptions,
61
+ headers: {
62
+ ...options.fetchOptions?.headers,
63
+ "x-aigne-hub-client-did": clientId,
64
+ },
65
+ },
66
+ });
67
+ return {
68
+ images: response.images,
69
+ usage: {
70
+ inputTokens: response.usage?.inputTokens ?? 0,
71
+ outputTokens: response.usage?.outputTokens ?? 0,
72
+ aigneHubCredits: response.usage?.aigneHubCredits,
73
+ },
74
+ model: response?.model,
75
+ };
76
+ }
77
+ }
@@ -1,15 +1,6 @@
1
- import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOptions, type ChatModelOutput } from "@aigne/core";
2
- import type { OpenAIChatModelOptions } from "@aigne/openai";
1
+ import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
3
2
  import { BaseClient, type BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
4
- export interface AIGNEHubChatModelOptions {
5
- url?: string;
6
- apiKey?: string;
7
- model?: string;
8
- modelOptions?: ChatModelOptions;
9
- clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
10
- clientId?: string;
11
- };
12
- }
3
+ import { type AIGNEHubChatModelOptions } from "./utils/type.js";
13
4
  export declare class AIGNEHubChatModel extends ChatModel {
14
5
  options: AIGNEHubChatModelOptions;
15
6
  constructor(options: AIGNEHubChatModelOptions);
@@ -3,29 +3,13 @@ import { checkArguments } from "@aigne/core/utils/type-utils.js";
3
3
  import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
4
4
  import { BaseClient, } from "@aigne/transport/http-client/base-client.js";
5
5
  import { joinURL } from "ufo";
6
- import { z } from "zod";
7
6
  import { getAIGNEHubMountPoint } from "./utils/blocklet.js";
8
7
  import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_DEFAULT_MODEL, AIGNE_HUB_URL, } from "./utils/constants.js";
9
- const aigneHubChatModelOptionsSchema = z.object({
10
- url: z.string().optional(),
11
- apiKey: z.string().optional(),
12
- model: z.string().optional(),
13
- modelOptions: z
14
- .object({
15
- model: z.string().optional(),
16
- temperature: z.number().optional(),
17
- topP: z.number().optional(),
18
- frequencyPenalty: z.number().optional(),
19
- presencePenalty: z.number().optional(),
20
- parallelToolCalls: z.boolean().optional().default(true),
21
- })
22
- .optional(),
23
- clientOptions: z.object({}).optional(),
24
- });
8
+ import { aigneHubModelOptionsSchema } from "./utils/type.js";
25
9
  export class AIGNEHubChatModel extends ChatModel {
26
10
  options;
27
11
  constructor(options) {
28
- checkArguments("AIGNEHubChatModel", aigneHubChatModelOptionsSchema, options);
12
+ checkArguments("AIGNEHubChatModel", aigneHubModelOptionsSchema, options);
29
13
  super();
30
14
  this.options = options;
31
15
  }
@@ -39,7 +23,8 @@ export class AIGNEHubChatModel extends ChatModel {
39
23
  }
40
24
  _credential;
41
25
  get credential() {
42
- this._credential = getAIGNEHubMountPoint(this.options.url ||
26
+ this._credential ??= getAIGNEHubMountPoint(this.options.url ||
27
+ this.options.baseURL ||
43
28
  process.env.BLOCKLET_AIGNE_API_URL ||
44
29
  process.env.AIGNE_HUB_API_URL ||
45
30
  AIGNE_HUB_URL, AIGNE_HUB_BLOCKLET_DID).then((url) => {
@@ -1,6 +1,6 @@
1
- import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
1
+ import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput, ImageModel, type ImageModelInput, type ImageModelOutput } from "@aigne/core";
2
2
  import type { BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
3
- import type { AIGNEHubChatModelOptions } from "./aigne-hub-model.js";
3
+ import type { AIGNEHubChatModelOptions, AIGNEHubImageModelOptions } from "./utils/type.js";
4
4
  export * from "./utils/blocklet.js";
5
5
  export * from "./utils/constants.js";
6
6
  export * from "./utils/model.js";
@@ -16,3 +16,15 @@ export declare class AIGNEHubChatModel extends ChatModel {
16
16
  }>;
17
17
  process(input: ChatModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ChatModelOutput>>;
18
18
  }
19
+ export declare class AIGNEHubImageModel extends ImageModel {
20
+ options: AIGNEHubImageModelOptions;
21
+ static load(options: AIGNEHubImageModelOptions): Promise<AIGNEHubImageModel>;
22
+ constructor(options: AIGNEHubImageModelOptions);
23
+ protected client: ImageModel;
24
+ get credential(): import("@aigne/core/utils/type-utils.js").PromiseOrValue<{
25
+ url?: string;
26
+ apiKey?: string;
27
+ model?: string;
28
+ }>;
29
+ process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ImageModelOutput>>;
30
+ }
package/lib/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ChatModel, } from "@aigne/core";
2
- import { findModel } from "./utils/model.js";
1
+ import { ChatModel, ImageModel, } from "@aigne/core";
2
+ import { findImageModel, findModel } from "./utils/model.js";
3
3
  export * from "./utils/blocklet.js";
4
4
  export * from "./utils/constants.js";
5
5
  export * from "./utils/model.js";
@@ -28,3 +28,28 @@ export class AIGNEHubChatModel extends ChatModel {
28
28
  return this.client.invoke(input, options);
29
29
  }
30
30
  }
31
+ export class AIGNEHubImageModel extends ImageModel {
32
+ options;
33
+ static async load(options) {
34
+ return new AIGNEHubImageModel(options);
35
+ }
36
+ constructor(options) {
37
+ const provider = process.env.BLOCKLET_AIGNE_API_PROVIDER || AIGNEHubImageModel.name;
38
+ const { match, all } = findImageModel(provider);
39
+ if (!match) {
40
+ const available = all.map((m) => m.name).join(", ");
41
+ throw new Error(`Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
42
+ }
43
+ const client = match.create(options);
44
+ super({ name: client.name });
45
+ this.options = options;
46
+ this.client = client;
47
+ }
48
+ client;
49
+ get credential() {
50
+ return this.client.credential;
51
+ }
52
+ async process(input, options) {
53
+ return this.client.invoke(input, options);
54
+ }
55
+ }
@@ -1,3 +1,4 @@
1
1
  export declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
2
2
  export declare const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
3
3
  export declare const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
4
+ export declare const AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
@@ -1,3 +1,4 @@
1
1
  export const AIGNE_HUB_URL = "https://hub.aigne.io/";
2
2
  export const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
3
3
  export const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
4
+ export const AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
@@ -1,4 +1,4 @@
1
- import type { ChatModel, ChatModelOptions, ImageModel, ImageModelOptions } from "@aigne/core";
1
+ import type { ChatModel, ChatModelOptions, ImageModel } from "@aigne/core";
2
2
  export interface LoadableModel {
3
3
  name: string | string[];
4
4
  apiKeyEnvName?: string | string[];
@@ -14,8 +14,10 @@ export interface LoadableImageModel {
14
14
  name: string;
15
15
  apiKeyEnvName: string;
16
16
  create: (options: {
17
+ apiKey?: string;
18
+ url?: string;
17
19
  model?: string;
18
- modelOptions?: ImageModelOptions;
20
+ modelOptions?: any;
19
21
  }) => ImageModel;
20
22
  }
21
23
  export declare function availableImageModels(): LoadableImageModel[];
@@ -23,3 +25,7 @@ export declare function findModel(provider: string): {
23
25
  all: LoadableModel[];
24
26
  match: LoadableModel | undefined;
25
27
  };
28
+ export declare function findImageModel(provider: string): {
29
+ all: LoadableImageModel[];
30
+ match: LoadableImageModel | undefined;
31
+ };
@@ -6,11 +6,12 @@ import { GeminiChatModel, GeminiImageModel } from "@aigne/gemini";
6
6
  import { IdeogramImageModel } from "@aigne/ideogram";
7
7
  import { OllamaChatModel } from "@aigne/ollama";
8
8
  import { OpenRouterChatModel } from "@aigne/open-router";
9
- import { OpenAIChatModel, OpenAIImageModel, } from "@aigne/openai";
9
+ import { OpenAIChatModel, OpenAIImageModel } from "@aigne/openai";
10
10
  import { PoeChatModel } from "@aigne/poe";
11
11
  import { XAIChatModel } from "@aigne/xai";
12
12
  import { NodeHttpHandler, streamCollector } from "@smithy/node-http-handler";
13
13
  import { HttpsProxyAgent } from "https-proxy-agent";
14
+ import { AIGNEHubImageModel } from "../aigne-hub-image-model.js";
14
15
  import { AIGNEHubChatModel } from "../aigne-hub-model.js";
15
16
  const getClientOptions = () => {
16
17
  const proxy = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy"]
@@ -100,32 +101,22 @@ export function availableImageModels() {
100
101
  {
101
102
  name: OpenAIImageModel.name,
102
103
  apiKeyEnvName: "OPENAI_API_KEY",
103
- create: (params) => new OpenAIImageModel({
104
- model: params.model,
105
- clientOptions,
106
- ...(params.modelOptions && {
107
- modelOptions: params.modelOptions,
108
- }),
109
- }),
104
+ create: (params) => new OpenAIImageModel({ ...params, clientOptions }),
110
105
  },
111
106
  {
112
107
  name: GeminiImageModel.name,
113
108
  apiKeyEnvName: "GEMINI_API_KEY",
114
- create: (params) => new GeminiImageModel({
115
- ...params,
116
- clientOptions,
117
- ...(params.modelOptions && {
118
- modelOptions: params.modelOptions,
119
- }),
120
- }),
109
+ create: (params) => new GeminiImageModel({ ...params, clientOptions }),
121
110
  },
122
111
  {
123
112
  name: IdeogramImageModel.name,
124
113
  apiKeyEnvName: "IDEOGRAM_API_KEY",
125
- create: (params) => new IdeogramImageModel({
126
- ...params,
127
- modelOptions: params.modelOptions,
128
- }),
114
+ create: (params) => new IdeogramImageModel({ ...params }),
115
+ },
116
+ {
117
+ name: AIGNEHubImageModel.name,
118
+ apiKeyEnvName: "AIGNE_HUB_API_KEY",
119
+ create: (params) => new AIGNEHubImageModel({ ...params, clientOptions }),
129
120
  },
130
121
  ];
131
122
  }
@@ -140,3 +131,9 @@ export function findModel(provider) {
140
131
  });
141
132
  return { all, match };
142
133
  }
134
+ export function findImageModel(provider) {
135
+ provider = provider.toLowerCase().replace(/-/g, "");
136
+ const all = availableImageModels();
137
+ const match = all.find((m) => m.name.toLowerCase().includes(provider));
138
+ return { all, match };
139
+ }
@@ -0,0 +1,72 @@
1
+ import type { ChatModelOptions } from "@aigne/core";
2
+ import type { OpenAIChatModelOptions } from "@aigne/openai";
3
+ import { z } from "zod";
4
+ export declare const aigneHubModelOptionsSchema: z.ZodObject<{
5
+ url: z.ZodOptional<z.ZodString>;
6
+ apiKey: z.ZodOptional<z.ZodString>;
7
+ model: z.ZodOptional<z.ZodString>;
8
+ modelOptions: z.ZodOptional<z.ZodObject<{
9
+ model: z.ZodOptional<z.ZodString>;
10
+ temperature: z.ZodOptional<z.ZodNumber>;
11
+ topP: z.ZodOptional<z.ZodNumber>;
12
+ frequencyPenalty: z.ZodOptional<z.ZodNumber>;
13
+ presencePenalty: z.ZodOptional<z.ZodNumber>;
14
+ parallelToolCalls: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ parallelToolCalls: boolean;
17
+ model?: string | undefined;
18
+ temperature?: number | undefined;
19
+ topP?: number | undefined;
20
+ frequencyPenalty?: number | undefined;
21
+ presencePenalty?: number | undefined;
22
+ }, {
23
+ model?: string | undefined;
24
+ temperature?: number | undefined;
25
+ topP?: number | undefined;
26
+ frequencyPenalty?: number | undefined;
27
+ presencePenalty?: number | undefined;
28
+ parallelToolCalls?: boolean | undefined;
29
+ }>>;
30
+ clientOptions: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ url?: string | undefined;
33
+ apiKey?: string | undefined;
34
+ model?: string | undefined;
35
+ modelOptions?: {
36
+ parallelToolCalls: boolean;
37
+ model?: string | undefined;
38
+ temperature?: number | undefined;
39
+ topP?: number | undefined;
40
+ frequencyPenalty?: number | undefined;
41
+ presencePenalty?: number | undefined;
42
+ } | undefined;
43
+ clientOptions?: {} | undefined;
44
+ }, {
45
+ url?: string | undefined;
46
+ apiKey?: string | undefined;
47
+ model?: string | undefined;
48
+ modelOptions?: {
49
+ model?: string | undefined;
50
+ temperature?: number | undefined;
51
+ topP?: number | undefined;
52
+ frequencyPenalty?: number | undefined;
53
+ presencePenalty?: number | undefined;
54
+ parallelToolCalls?: boolean | undefined;
55
+ } | undefined;
56
+ clientOptions?: {} | undefined;
57
+ }>;
58
+ export interface AIGNEHubChatModelOptions {
59
+ url?: string;
60
+ baseURL?: string;
61
+ apiKey?: string;
62
+ model?: string;
63
+ modelOptions?: ChatModelOptions;
64
+ clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
65
+ clientId?: string;
66
+ };
67
+ }
68
+ export type AIGNEHubImageModelOptions = Omit<AIGNEHubChatModelOptions, "modelOptions"> & {
69
+ modelOptions?: {
70
+ [key: string]: any;
71
+ };
72
+ };
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+ export const aigneHubModelOptionsSchema = z.object({
3
+ url: z.string().optional(),
4
+ apiKey: z.string().optional(),
5
+ model: z.string().optional(),
6
+ modelOptions: z
7
+ .object({
8
+ model: z.string().optional(),
9
+ temperature: z.number().optional(),
10
+ topP: z.number().optional(),
11
+ frequencyPenalty: z.number().optional(),
12
+ presencePenalty: z.number().optional(),
13
+ parallelToolCalls: z.boolean().optional().default(true),
14
+ })
15
+ .optional(),
16
+ clientOptions: z.object({}).optional(),
17
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/aigne-hub",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "AIGNE Hub SDK for integrating with Hub AI models",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -39,20 +39,20 @@
39
39
  "https-proxy-agent": "^7.0.6",
40
40
  "ufo": "^1.6.1",
41
41
  "zod": "^3.25.67",
42
- "@aigne/anthropic": "^0.11.10",
43
- "@aigne/core": "^1.55.1",
44
- "@aigne/bedrock": "^0.9.10",
45
- "@aigne/deepseek": "^0.7.29",
46
- "@aigne/gemini": "^0.10.0",
47
- "@aigne/doubao": "^1.0.23",
48
- "@aigne/open-router": "^0.7.29",
49
- "@aigne/ollama": "^0.7.29",
50
- "@aigne/ideogram": "^0.2.0",
51
- "@aigne/openai": "^0.13.0",
52
- "@aigne/platform-helpers": "^0.6.2",
53
- "@aigne/xai": "^0.7.29",
54
- "@aigne/poe": "^1.0.9",
55
- "@aigne/transport": "^0.14.9"
42
+ "@aigne/anthropic": "^0.11.11",
43
+ "@aigne/bedrock": "^0.9.11",
44
+ "@aigne/core": "^1.56.0",
45
+ "@aigne/doubao": "^1.0.24",
46
+ "@aigne/deepseek": "^0.7.30",
47
+ "@aigne/gemini": "^0.11.0",
48
+ "@aigne/ideogram": "^0.3.0",
49
+ "@aigne/ollama": "^0.7.30",
50
+ "@aigne/open-router": "^0.7.30",
51
+ "@aigne/openai": "^0.13.1",
52
+ "@aigne/poe": "^1.0.10",
53
+ "@aigne/xai": "^0.7.30",
54
+ "@aigne/transport": "^0.14.10",
55
+ "@aigne/platform-helpers": "^0.6.2"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/bun": "^1.2.18",
@@ -61,8 +61,7 @@
61
61
  "npm-run-all": "^4.1.5",
62
62
  "rimraf": "^6.0.1",
63
63
  "typescript": "^5.8.3",
64
- "@aigne/openai": "^0.13.0",
65
- "@aigne/test-utils": "^0.5.36"
64
+ "@aigne/test-utils": "^0.5.37"
66
65
  },
67
66
  "scripts": {
68
67
  "lint": "tsc --noEmit",