@aigne/aigne-hub 0.4.4 → 0.4.6

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,55 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.6](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.4.5...aigne-hub-v0.4.6) (2025-08-08)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * The following workspace dependencies were updated
9
+ * dependencies
10
+ * @aigne/anthropic bumped to 0.10.11
11
+ * @aigne/bedrock bumped to 0.8.15
12
+ * @aigne/core bumped to 1.46.1
13
+ * @aigne/deepseek bumped to 0.7.15
14
+ * @aigne/default-memory bumped to 1.0.15
15
+ * @aigne/gemini bumped to 0.8.15
16
+ * @aigne/ollama bumped to 0.7.15
17
+ * @aigne/open-router bumped to 0.7.15
18
+ * @aigne/openai bumped to 0.10.15
19
+ * @aigne/transport bumped to 0.12.3
20
+ * @aigne/xai bumped to 0.7.15
21
+ * devDependencies
22
+ * @aigne/openai bumped to 0.10.15
23
+ * @aigne/test-utils bumped to 0.5.23
24
+
25
+ ## [0.4.5](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.4.4...aigne-hub-v0.4.5) (2025-08-06)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **models:** improve aigne-model chat logic and fix incorrect input in blocklet usage ([#329](https://github.com/AIGNE-io/aigne-framework/issues/329)) ([f50a9b8](https://github.com/AIGNE-io/aigne-framework/commit/f50a9b84e12f129396006784e810be25a3fa15fc))
31
+
32
+
33
+ ### Dependencies
34
+
35
+ * The following workspace dependencies were updated
36
+ * dependencies
37
+ * @aigne/anthropic bumped to 0.10.10
38
+ * @aigne/bedrock bumped to 0.8.14
39
+ * @aigne/core bumped to 1.46.0
40
+ * @aigne/deepseek bumped to 0.7.14
41
+ * @aigne/default-memory bumped to 1.0.14
42
+ * @aigne/gemini bumped to 0.8.14
43
+ * @aigne/ollama bumped to 0.7.14
44
+ * @aigne/open-router bumped to 0.7.14
45
+ * @aigne/openai bumped to 0.10.14
46
+ * @aigne/platform-helpers bumped to 0.6.0
47
+ * @aigne/transport bumped to 0.12.2
48
+ * @aigne/xai bumped to 0.7.14
49
+ * devDependencies
50
+ * @aigne/openai bumped to 0.10.14
51
+ * @aigne/test-utils bumped to 0.5.22
52
+
3
53
  ## [0.4.4](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.4.3...aigne-hub-v0.4.4) (2025-08-06)
4
54
 
5
55
 
package/README.md CHANGED
@@ -22,6 +22,12 @@ AIGNE SDK for accessing AI chat models via [AIGNE Hub](https://github.com/AIGNE-
22
22
 
23
23
  It enables you to switch providers without changing your client-side logic.
24
24
 
25
+ <picture>
26
+ <source srcset="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/assets/aigne-hub-dark.png" media="(prefers-color-scheme: dark)">
27
+ <source srcset="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/assets/aigne-hub.png" media="(prefers-color-scheme: light)">
28
+ <img src="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/aigne-hub.png" alt="AIGNE Arch" />
29
+ </picture>
30
+
25
31
  ## Supported Providers
26
32
 
27
33
  The AIGNE Hub backend supports the following AI providers via a single, unified API:
@@ -10,27 +10,32 @@ class BlockletAIGNEHubChatModel extends core_1.ChatModel {
10
10
  super();
11
11
  this.options = options;
12
12
  const models = (0, constants_js_1.availableModels)();
13
- const PROVIDER = process.env.BLOCKLET_AIGNE_API_PROVIDER?.toLowerCase() ?? "";
14
- const provider = PROVIDER.replace(/-/g, "");
15
- const m = (0, constants_js_1.findModel)(models, provider);
16
- if (!m) {
17
- throw new Error(`Unsupported model: ${process.env.BLOCKLET_AIGNE_API_PROVIDER} ${process.env.BLOCKLET_AIGNE_API_MODEL}`);
13
+ const rawProvider = process.env.BLOCKLET_AIGNE_API_PROVIDER ?? "";
14
+ const providerKey = rawProvider.toLowerCase().replace(/-/g, "");
15
+ const modelEntry = (0, constants_js_1.findModel)(models, providerKey);
16
+ if (!modelEntry) {
17
+ const available = models.map((m) => m.name).join(", ");
18
+ throw new Error(`Unsupported model provider: ${rawProvider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
18
19
  }
19
- const credential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
20
- const credentialOptions = credential
21
- ? typeof credential === "string"
22
- ? JSON.parse(credential)
23
- : credential
24
- : {};
25
- const { apiKey, ...rest } = credentialOptions;
26
- this.client = m.create({
20
+ const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
21
+ let credentialOptions = {};
22
+ try {
23
+ credentialOptions =
24
+ typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
25
+ }
26
+ catch (err) {
27
+ console.error(err);
28
+ }
29
+ const { apiKey, ...extraCredentialOptions } = credentialOptions;
30
+ const params = {
27
31
  ...options,
28
- model: options.model ?? process.env.BLOCKLET_AIGNE_API_MODEL,
32
+ model: options.model || process.env.BLOCKLET_AIGNE_API_MODEL,
29
33
  modelOptions: options.modelOptions,
30
- baseURL: options.baseURL ?? options.url ?? process.env.BLOCKLET_AIGNE_API_URL,
31
- apiKey: options.apiKey ?? apiKey,
32
- ...rest,
33
- });
34
+ url: options.url || process.env.BLOCKLET_AIGNE_API_URL || constants_js_1.AIGNE_HUB_URL,
35
+ apiKey: options.apiKey || apiKey,
36
+ ...extraCredentialOptions,
37
+ };
38
+ this.client = modelEntry.create(params);
34
39
  }
35
40
  process(input, options) {
36
41
  return this.client.invoke(input, options);
@@ -6,8 +6,8 @@ const type_utils_js_1 = require("@aigne/core/utils/type-utils.js");
6
6
  const base_client_js_1 = require("@aigne/transport/http-client/base-client.js");
7
7
  const ufo_1 = require("ufo");
8
8
  const zod_1 = require("zod");
9
+ const constants_js_1 = require("./constants.js");
9
10
  const DEFAULT_CHAT_MODEL = "openai/gpt-4o";
10
- const DEFAULT_URL = "https://hub.aigne.io/ai-kit/";
11
11
  const aigneHubChatModelOptionsSchema = zod_1.z.object({
12
12
  url: zod_1.z.string().optional(),
13
13
  apiKey: zod_1.z.string().optional(),
@@ -31,12 +31,15 @@ class CliAIGNEHubChatModel extends core_1.ChatModel {
31
31
  (0, type_utils_js_1.checkArguments)("AIGNEHubChatModel", aigneHubChatModelOptionsSchema, options);
32
32
  super();
33
33
  this.options = options;
34
- this.client = new base_client_js_1.BaseClient({
34
+ const url = options.url || process.env.AIGNE_HUB_API_URL || constants_js_1.AIGNE_HUB_URL;
35
+ const path = "/api/v2/chat";
36
+ const params = {
35
37
  ...options,
36
- url: (0, ufo_1.joinURL)(options.url || process.env.AIGNE_HUB_API_URL || DEFAULT_URL, "/api/v2/chat"),
38
+ url: url.endsWith(path) ? url : (0, ufo_1.joinURL)(url, path),
37
39
  model: options.model || DEFAULT_CHAT_MODEL,
38
40
  apiKey: options.apiKey || process.env.AIGNE_HUB_API_KEY,
39
- });
41
+ };
42
+ this.client = new base_client_js_1.BaseClient(params);
40
43
  }
41
44
  process(input, options) {
42
45
  return this.client.__invoke(undefined, input, options);
@@ -1,4 +1,5 @@
1
1
  import type { ChatModel, ChatModelOptions } from "@aigne/core/agents/chat-model.js";
2
+ export declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
2
3
  export declare function availableModels(): LoadableModel[];
3
4
  export interface LoadableModel {
4
5
  name: string | string[];
@@ -23,4 +24,5 @@ export declare function loadModel(model?: Model, modelOptions?: ChatModelOptions
23
24
  apiKey?: string;
24
25
  url?: string;
25
26
  }): Promise<ChatModel | undefined>;
27
+ export declare function getAIGNEHubMountPoint(url: string): Promise<string>;
26
28
  export {};
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AIGNE_HUB_URL = void 0;
3
4
  exports.availableModels = availableModels;
4
5
  exports.findModel = findModel;
5
6
  exports.loadModel = loadModel;
7
+ exports.getAIGNEHubMountPoint = getAIGNEHubMountPoint;
6
8
  const anthropic_1 = require("@aigne/anthropic");
7
9
  const bedrock_1 = require("@aigne/bedrock");
8
10
  const deepseek_1 = require("@aigne/deepseek");
@@ -14,7 +16,10 @@ const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
14
16
  const xai_1 = require("@aigne/xai");
15
17
  const node_http_handler_1 = require("@smithy/node-http-handler");
16
18
  const https_proxy_agent_1 = require("https-proxy-agent");
19
+ const ufo_1 = require("ufo");
17
20
  const cli_aigne_hub_model_js_1 = require("./cli-aigne-hub-model.js");
21
+ const AIGNE_HUB_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
22
+ exports.AIGNE_HUB_URL = "https://hub.aigne.io/";
18
23
  function availableModels() {
19
24
  const proxy = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy"]
20
25
  .map((i) => process.env[i])
@@ -108,3 +113,11 @@ async function loadModel(model, modelOptions, credential) {
108
113
  modelOptions: { ...params, ...modelOptions },
109
114
  });
110
115
  }
116
+ async function getAIGNEHubMountPoint(url) {
117
+ const { origin } = new URL(url);
118
+ const BLOCKLET_JSON_PATH = "__blocklet__.js?type=json";
119
+ const blockletInfo = await fetch((0, ufo_1.joinURL)(origin, BLOCKLET_JSON_PATH));
120
+ const blocklet = await blockletInfo.json();
121
+ const aigneHubMount = (blocklet?.componentMountPoints || []).find((m) => m.did === AIGNE_HUB_DID);
122
+ return (0, ufo_1.joinURL)(origin, aigneHubMount?.mountPoint || "");
123
+ }
@@ -1,10 +1,12 @@
1
1
  import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
2
2
  import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
3
3
  import { type HubChatModelOptions } from "./blocklet-aigne-hub-model.js";
4
+ import { type AIGNEHubChatModelOptions } from "./cli-aigne-hub-model.js";
4
5
  export * from "./constants.js";
5
6
  export declare class AIGNEHubChatModel extends ChatModel {
6
7
  options: HubChatModelOptions;
7
8
  private client;
9
+ static load(options: AIGNEHubChatModelOptions): Promise<AIGNEHubChatModel>;
8
10
  constructor(options: HubChatModelOptions);
9
11
  process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
10
12
  }
package/lib/cjs/index.js CHANGED
@@ -18,16 +18,25 @@ exports.AIGNEHubChatModel = void 0;
18
18
  const core_1 = require("@aigne/core");
19
19
  const blocklet_aigne_hub_model_js_1 = require("./blocklet-aigne-hub-model.js");
20
20
  const cli_aigne_hub_model_js_1 = require("./cli-aigne-hub-model.js");
21
+ const constants_js_1 = require("./constants.js");
21
22
  __exportStar(require("./constants.js"), exports);
22
23
  class AIGNEHubChatModel extends core_1.ChatModel {
23
24
  options;
24
25
  client;
26
+ static async load(options) {
27
+ const u = process.env.BLOCKLET_AIGNE_API_URL ?? process.env.AIGNE_HUB_API_URL ?? constants_js_1.AIGNE_HUB_URL;
28
+ let url = options.url ?? u;
29
+ if ((process.env.BLOCKLET_AIGNE_API_PROVIDER || "").toLocaleLowerCase().includes("aignehub")) {
30
+ url = await (0, constants_js_1.getAIGNEHubMountPoint)(url);
31
+ }
32
+ return new AIGNEHubChatModel({ ...options, url });
33
+ }
25
34
  constructor(options) {
26
35
  super();
27
36
  this.options = options;
28
- this.client = process.env.BLOCKLET_AIGNE_API_PROVIDER
29
- ? new blocklet_aigne_hub_model_js_1.BlockletAIGNEHubChatModel(options)
30
- : new cli_aigne_hub_model_js_1.CliAIGNEHubChatModel(options);
37
+ const isBlocklet = process.env.BLOCKLET_AIGNE_API_URL && process.env.BLOCKLET_AIGNE_API_PROVIDER;
38
+ const AIGNEHubModel = isBlocklet ? blocklet_aigne_hub_model_js_1.BlockletAIGNEHubChatModel : cli_aigne_hub_model_js_1.CliAIGNEHubChatModel;
39
+ this.client = new AIGNEHubModel(options);
31
40
  }
32
41
  process(input, options) {
33
42
  return this.client.process(input, options);
@@ -1,4 +1,5 @@
1
1
  import type { ChatModel, ChatModelOptions } from "@aigne/core/agents/chat-model.js";
2
+ export declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
2
3
  export declare function availableModels(): LoadableModel[];
3
4
  export interface LoadableModel {
4
5
  name: string | string[];
@@ -23,4 +24,5 @@ export declare function loadModel(model?: Model, modelOptions?: ChatModelOptions
23
24
  apiKey?: string;
24
25
  url?: string;
25
26
  }): Promise<ChatModel | undefined>;
27
+ export declare function getAIGNEHubMountPoint(url: string): Promise<string>;
26
28
  export {};
@@ -1,10 +1,12 @@
1
1
  import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
2
2
  import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
3
3
  import { type HubChatModelOptions } from "./blocklet-aigne-hub-model.js";
4
+ import { type AIGNEHubChatModelOptions } from "./cli-aigne-hub-model.js";
4
5
  export * from "./constants.js";
5
6
  export declare class AIGNEHubChatModel extends ChatModel {
6
7
  options: HubChatModelOptions;
7
8
  private client;
9
+ static load(options: AIGNEHubChatModelOptions): Promise<AIGNEHubChatModel>;
8
10
  constructor(options: HubChatModelOptions);
9
11
  process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
10
12
  }
@@ -1,5 +1,5 @@
1
1
  import { ChatModel, } from "@aigne/core";
2
- import { availableModels, findModel } from "./constants.js";
2
+ import { AIGNE_HUB_URL, availableModels, findModel } from "./constants.js";
3
3
  export class BlockletAIGNEHubChatModel extends ChatModel {
4
4
  options;
5
5
  client;
@@ -7,27 +7,32 @@ export class BlockletAIGNEHubChatModel extends ChatModel {
7
7
  super();
8
8
  this.options = options;
9
9
  const models = availableModels();
10
- const PROVIDER = process.env.BLOCKLET_AIGNE_API_PROVIDER?.toLowerCase() ?? "";
11
- const provider = PROVIDER.replace(/-/g, "");
12
- const m = findModel(models, provider);
13
- if (!m) {
14
- throw new Error(`Unsupported model: ${process.env.BLOCKLET_AIGNE_API_PROVIDER} ${process.env.BLOCKLET_AIGNE_API_MODEL}`);
10
+ const rawProvider = process.env.BLOCKLET_AIGNE_API_PROVIDER ?? "";
11
+ const providerKey = rawProvider.toLowerCase().replace(/-/g, "");
12
+ const modelEntry = findModel(models, providerKey);
13
+ if (!modelEntry) {
14
+ const available = models.map((m) => m.name).join(", ");
15
+ throw new Error(`Unsupported model provider: ${rawProvider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
15
16
  }
16
- const credential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
17
- const credentialOptions = credential
18
- ? typeof credential === "string"
19
- ? JSON.parse(credential)
20
- : credential
21
- : {};
22
- const { apiKey, ...rest } = credentialOptions;
23
- this.client = m.create({
17
+ const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
18
+ let credentialOptions = {};
19
+ try {
20
+ credentialOptions =
21
+ typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
22
+ }
23
+ catch (err) {
24
+ console.error(err);
25
+ }
26
+ const { apiKey, ...extraCredentialOptions } = credentialOptions;
27
+ const params = {
24
28
  ...options,
25
- model: options.model ?? process.env.BLOCKLET_AIGNE_API_MODEL,
29
+ model: options.model || process.env.BLOCKLET_AIGNE_API_MODEL,
26
30
  modelOptions: options.modelOptions,
27
- baseURL: options.baseURL ?? options.url ?? process.env.BLOCKLET_AIGNE_API_URL,
28
- apiKey: options.apiKey ?? apiKey,
29
- ...rest,
30
- });
31
+ url: options.url || process.env.BLOCKLET_AIGNE_API_URL || AIGNE_HUB_URL,
32
+ apiKey: options.apiKey || apiKey,
33
+ ...extraCredentialOptions,
34
+ };
35
+ this.client = modelEntry.create(params);
31
36
  }
32
37
  process(input, options) {
33
38
  return this.client.invoke(input, options);
@@ -3,8 +3,8 @@ import { checkArguments } from "@aigne/core/utils/type-utils.js";
3
3
  import { BaseClient } from "@aigne/transport/http-client/base-client.js";
4
4
  import { joinURL } from "ufo";
5
5
  import { z } from "zod";
6
+ import { AIGNE_HUB_URL } from "./constants.js";
6
7
  const DEFAULT_CHAT_MODEL = "openai/gpt-4o";
7
- const DEFAULT_URL = "https://hub.aigne.io/ai-kit/";
8
8
  const aigneHubChatModelOptionsSchema = z.object({
9
9
  url: z.string().optional(),
10
10
  apiKey: z.string().optional(),
@@ -28,12 +28,15 @@ export class CliAIGNEHubChatModel extends ChatModel {
28
28
  checkArguments("AIGNEHubChatModel", aigneHubChatModelOptionsSchema, options);
29
29
  super();
30
30
  this.options = options;
31
- this.client = new BaseClient({
31
+ const url = options.url || process.env.AIGNE_HUB_API_URL || AIGNE_HUB_URL;
32
+ const path = "/api/v2/chat";
33
+ const params = {
32
34
  ...options,
33
- url: joinURL(options.url || process.env.AIGNE_HUB_API_URL || DEFAULT_URL, "/api/v2/chat"),
35
+ url: url.endsWith(path) ? url : joinURL(url, path),
34
36
  model: options.model || DEFAULT_CHAT_MODEL,
35
37
  apiKey: options.apiKey || process.env.AIGNE_HUB_API_KEY,
36
- });
38
+ };
39
+ this.client = new BaseClient(params);
37
40
  }
38
41
  process(input, options) {
39
42
  return this.client.__invoke(undefined, input, options);
@@ -1,4 +1,5 @@
1
1
  import type { ChatModel, ChatModelOptions } from "@aigne/core/agents/chat-model.js";
2
+ export declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
2
3
  export declare function availableModels(): LoadableModel[];
3
4
  export interface LoadableModel {
4
5
  name: string | string[];
@@ -23,4 +24,5 @@ export declare function loadModel(model?: Model, modelOptions?: ChatModelOptions
23
24
  apiKey?: string;
24
25
  url?: string;
25
26
  }): Promise<ChatModel | undefined>;
27
+ export declare function getAIGNEHubMountPoint(url: string): Promise<string>;
26
28
  export {};
@@ -9,7 +9,10 @@ import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
9
9
  import { XAIChatModel } from "@aigne/xai";
10
10
  import { NodeHttpHandler, streamCollector } from "@smithy/node-http-handler";
11
11
  import { HttpsProxyAgent } from "https-proxy-agent";
12
+ import { joinURL } from "ufo";
12
13
  import { CliAIGNEHubChatModel } from "./cli-aigne-hub-model.js";
14
+ const AIGNE_HUB_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
15
+ export const AIGNE_HUB_URL = "https://hub.aigne.io/";
13
16
  export function availableModels() {
14
17
  const proxy = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy"]
15
18
  .map((i) => process.env[i])
@@ -103,3 +106,11 @@ export async function loadModel(model, modelOptions, credential) {
103
106
  modelOptions: { ...params, ...modelOptions },
104
107
  });
105
108
  }
109
+ export async function getAIGNEHubMountPoint(url) {
110
+ const { origin } = new URL(url);
111
+ const BLOCKLET_JSON_PATH = "__blocklet__.js?type=json";
112
+ const blockletInfo = await fetch(joinURL(origin, BLOCKLET_JSON_PATH));
113
+ const blocklet = await blockletInfo.json();
114
+ const aigneHubMount = (blocklet?.componentMountPoints || []).find((m) => m.did === AIGNE_HUB_DID);
115
+ return joinURL(origin, aigneHubMount?.mountPoint || "");
116
+ }
@@ -1,10 +1,12 @@
1
1
  import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
2
2
  import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
3
3
  import { type HubChatModelOptions } from "./blocklet-aigne-hub-model.js";
4
+ import { type AIGNEHubChatModelOptions } from "./cli-aigne-hub-model.js";
4
5
  export * from "./constants.js";
5
6
  export declare class AIGNEHubChatModel extends ChatModel {
6
7
  options: HubChatModelOptions;
7
8
  private client;
9
+ static load(options: AIGNEHubChatModelOptions): Promise<AIGNEHubChatModel>;
8
10
  constructor(options: HubChatModelOptions);
9
11
  process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
10
12
  }
package/lib/esm/index.js CHANGED
@@ -1,16 +1,25 @@
1
1
  import { ChatModel, } from "@aigne/core";
2
2
  import { BlockletAIGNEHubChatModel } from "./blocklet-aigne-hub-model.js";
3
3
  import { CliAIGNEHubChatModel } from "./cli-aigne-hub-model.js";
4
+ import { AIGNE_HUB_URL, getAIGNEHubMountPoint } from "./constants.js";
4
5
  export * from "./constants.js";
5
6
  export class AIGNEHubChatModel extends ChatModel {
6
7
  options;
7
8
  client;
9
+ static async load(options) {
10
+ const u = process.env.BLOCKLET_AIGNE_API_URL ?? process.env.AIGNE_HUB_API_URL ?? AIGNE_HUB_URL;
11
+ let url = options.url ?? u;
12
+ if ((process.env.BLOCKLET_AIGNE_API_PROVIDER || "").toLocaleLowerCase().includes("aignehub")) {
13
+ url = await getAIGNEHubMountPoint(url);
14
+ }
15
+ return new AIGNEHubChatModel({ ...options, url });
16
+ }
8
17
  constructor(options) {
9
18
  super();
10
19
  this.options = options;
11
- this.client = process.env.BLOCKLET_AIGNE_API_PROVIDER
12
- ? new BlockletAIGNEHubChatModel(options)
13
- : new CliAIGNEHubChatModel(options);
20
+ const isBlocklet = process.env.BLOCKLET_AIGNE_API_URL && process.env.BLOCKLET_AIGNE_API_PROVIDER;
21
+ const AIGNEHubModel = isBlocklet ? BlockletAIGNEHubChatModel : CliAIGNEHubChatModel;
22
+ this.client = new AIGNEHubModel(options);
14
23
  }
15
24
  process(input, options) {
16
25
  return this.client.process(input, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/aigne-hub",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "AIGNE Hub SDK for integrating with Hub AI models",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -45,18 +45,18 @@
45
45
  "openai": "^5.8.3",
46
46
  "ufo": "^1.6.1",
47
47
  "zod": "^3.25.67",
48
- "@aigne/anthropic": "^0.10.9",
49
- "@aigne/bedrock": "^0.8.13",
50
- "@aigne/core": "^1.45.0",
51
- "@aigne/default-memory": "^1.0.13",
52
- "@aigne/deepseek": "^0.7.13",
53
- "@aigne/ollama": "^0.7.13",
54
- "@aigne/gemini": "^0.8.13",
55
- "@aigne/open-router": "^0.7.13",
56
- "@aigne/openai": "^0.10.13",
57
- "@aigne/platform-helpers": "^0.5.1",
58
- "@aigne/transport": "^0.12.1",
59
- "@aigne/xai": "^0.7.13"
48
+ "@aigne/anthropic": "^0.10.11",
49
+ "@aigne/bedrock": "^0.8.15",
50
+ "@aigne/core": "^1.46.1",
51
+ "@aigne/deepseek": "^0.7.15",
52
+ "@aigne/gemini": "^0.8.15",
53
+ "@aigne/default-memory": "^1.0.15",
54
+ "@aigne/ollama": "^0.7.15",
55
+ "@aigne/openai": "^0.10.15",
56
+ "@aigne/platform-helpers": "^0.6.0",
57
+ "@aigne/open-router": "^0.7.15",
58
+ "@aigne/transport": "^0.12.3",
59
+ "@aigne/xai": "^0.7.15"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/bun": "^1.2.18",
@@ -65,8 +65,8 @@
65
65
  "npm-run-all": "^4.1.5",
66
66
  "rimraf": "^6.0.1",
67
67
  "typescript": "^5.8.3",
68
- "@aigne/test-utils": "^0.5.21",
69
- "@aigne/openai": "^0.10.13"
68
+ "@aigne/openai": "^0.10.15",
69
+ "@aigne/test-utils": "^0.5.23"
70
70
  },
71
71
  "scripts": {
72
72
  "lint": "tsc --noEmit",