@aigne/aigne-hub 0.1.2 → 0.2.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,50 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.0](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.1.3...aigne-hub-v0.2.0) (2025-07-24)
4
+
5
+
6
+ ### Features
7
+
8
+ * **cli:** support aigne hub connect and model use ([#267](https://github.com/AIGNE-io/aigne-framework/issues/267)) ([8e5a32a](https://github.com/AIGNE-io/aigne-framework/commit/8e5a32afc64593137153d7407bde13837312ac70))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update blocklet key name ([#279](https://github.com/AIGNE-io/aigne-framework/issues/279)) ([210ef61](https://github.com/AIGNE-io/aigne-framework/commit/210ef612f9d1dcbbb9cbe10635b056114bfd10b7))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @aigne/transport bumped to 0.10.4
21
+ * @aigne/anthropic bumped to 0.10.0
22
+ * @aigne/bedrock bumped to 0.8.4
23
+ * @aigne/core bumped to 1.38.0
24
+ * @aigne/deepseek bumped to 0.7.4
25
+ * @aigne/default-memory bumped to 1.0.4
26
+ * @aigne/gemini bumped to 0.8.4
27
+ * @aigne/ollama bumped to 0.7.4
28
+ * @aigne/open-router bumped to 0.7.4
29
+ * @aigne/openai bumped to 0.10.4
30
+ * @aigne/xai bumped to 0.7.4
31
+ * devDependencies
32
+ * @aigne/openai bumped to 0.10.4
33
+ * @aigne/test-utils bumped to 0.5.12
34
+
35
+ ## [0.1.3](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.1.2...aigne-hub-v0.1.3) (2025-07-22)
36
+
37
+
38
+ ### Dependencies
39
+
40
+ * The following workspace dependencies were updated
41
+ * dependencies
42
+ * @aigne/core bumped to 1.37.0
43
+ * @aigne/transport bumped to 0.10.3
44
+ * devDependencies
45
+ * @aigne/openai bumped to 0.10.3
46
+ * @aigne/test-utils bumped to 0.5.11
47
+
3
48
  ## [0.1.2](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.1.1...aigne-hub-v0.1.2) (2025-07-17)
4
49
 
5
50
 
package/README.md CHANGED
@@ -58,7 +58,7 @@ pnpm add @aigne/aigne-hub @aigne/core
58
58
  import { AIGNEHubChatModel } from "@aigne/aigne-hub";
59
59
 
60
60
  const model = new AIGNEHubChatModel({
61
- url: "https://your-aigne-hub-instance/ai-kit/api/v2/chat",
61
+ url: "https://your-aigne-hub-instance/ai-kit/",
62
62
  accessKey: "your-access-key-id",
63
63
  model: "openai/gpt-4o-mini",
64
64
  });
@@ -84,7 +84,7 @@ console.log(result);
84
84
  import { AIGNEHubChatModel } from "@aigne/aigne-hub";
85
85
 
86
86
  const model = new AIGNEHubChatModel({
87
- url: "https://your-aigne-hub-instance/ai-kit/api/v2/chat",
87
+ url: "https://your-aigne-hub-instance/ai-kit/",
88
88
  accessKey: "your-access-key-id",
89
89
  model: "openai/gpt-4o-mini",
90
90
  });
@@ -1,7 +1,7 @@
1
1
  import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOptions, type ChatModelOutput } from "@aigne/core";
2
2
  import { type PromiseOrValue } from "@aigne/core/utils/type-utils.js";
3
3
  import type { OpenAIChatModelOptions } from "@aigne/openai";
4
- interface AIGNEHubChatModelOptions {
4
+ export interface AIGNEHubChatModelOptions {
5
5
  url?: string;
6
6
  accessKey?: string;
7
7
  model?: string;
@@ -14,4 +14,3 @@ export declare class AIGNEHubChatModel extends ChatModel {
14
14
  constructor(options: AIGNEHubChatModelOptions);
15
15
  process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
16
16
  }
17
- export {};
@@ -4,9 +4,10 @@ exports.AIGNEHubChatModel = void 0;
4
4
  const core_1 = require("@aigne/core");
5
5
  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
+ const ufo_1 = require("ufo");
7
8
  const zod_1 = require("zod");
8
9
  const DEFAULT_CHAT_MODEL = "openai/gpt-4o";
9
- const DEFAULT_URL = "https://www.aikit.rocks/ai-kit/api/v2/chat";
10
+ const DEFAULT_URL = "https://hub.aigne.io/ai-kit/";
10
11
  const aigneHubChatModelOptionsSchema = zod_1.z.object({
11
12
  url: zod_1.z.string().optional(),
12
13
  accessKey: zod_1.z.string().optional(),
@@ -32,9 +33,9 @@ class AIGNEHubChatModel extends core_1.ChatModel {
32
33
  this.options = options;
33
34
  this.client = new base_client_js_1.BaseClient({
34
35
  ...options,
35
- url: options.url ?? process.env.AIGNE_HUB_BASE_URL ?? DEFAULT_URL,
36
- model: options.model ?? DEFAULT_CHAT_MODEL,
37
- accessKey: options.accessKey ?? process.env.AIGNE_HUB_ACCESS_KEY,
36
+ url: (0, ufo_1.joinURL)(options.url || process.env.AIGNE_HUB_API_URL || DEFAULT_URL, "/api/v2/chat"),
37
+ model: options.model || DEFAULT_CHAT_MODEL,
38
+ accessKey: options.accessKey || process.env.AIGNE_HUB_API_KEY,
38
39
  });
39
40
  }
40
41
  process(input, options) {
@@ -0,0 +1,21 @@
1
+ import { type AnthropicChatModelOptions } from "@aigne/anthropic";
2
+ import { type BedrockChatModelOptions } from "@aigne/bedrock";
3
+ import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
4
+ import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
5
+ import { type OpenAIChatModelOptions } from "@aigne/openai";
6
+ import { type AIGNEHubChatModelOptions } from "./aigne-hub-model.js";
7
+ export type HubChatModelOptions = AIGNEHubChatModelOptions | AnthropicChatModelOptions | BedrockChatModelOptions | OpenAIChatModelOptions;
8
+ export declare class HubChatModel extends ChatModel {
9
+ options: HubChatModelOptions & {
10
+ apiKey?: string;
11
+ baseURL?: string;
12
+ url?: string;
13
+ };
14
+ private client;
15
+ constructor(options: HubChatModelOptions & {
16
+ apiKey?: string;
17
+ baseURL?: string;
18
+ url?: string;
19
+ });
20
+ process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
21
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HubChatModel = void 0;
4
+ const anthropic_1 = require("@aigne/anthropic");
5
+ const bedrock_1 = require("@aigne/bedrock");
6
+ const core_1 = require("@aigne/core");
7
+ const deepseek_1 = require("@aigne/deepseek");
8
+ const gemini_1 = require("@aigne/gemini");
9
+ const ollama_1 = require("@aigne/ollama");
10
+ const open_router_1 = require("@aigne/open-router");
11
+ const openai_1 = require("@aigne/openai");
12
+ const xai_1 = require("@aigne/xai");
13
+ const aigne_hub_model_js_1 = require("./aigne-hub-model.js");
14
+ function availableModels() {
15
+ return [
16
+ {
17
+ name: openai_1.OpenAIChatModel.name,
18
+ apiKeyEnvName: "OPENAI_API_KEY",
19
+ create: (params) => new openai_1.OpenAIChatModel({ ...params }),
20
+ },
21
+ {
22
+ name: anthropic_1.AnthropicChatModel.name,
23
+ apiKeyEnvName: "ANTHROPIC_API_KEY",
24
+ create: (params) => new anthropic_1.AnthropicChatModel({ ...params }),
25
+ },
26
+ {
27
+ name: bedrock_1.BedrockChatModel.name,
28
+ apiKeyEnvName: "AWS_ACCESS_KEY_ID",
29
+ create: (params) => new bedrock_1.BedrockChatModel({ ...params }),
30
+ },
31
+ {
32
+ name: deepseek_1.DeepSeekChatModel.name,
33
+ apiKeyEnvName: "DEEPSEEK_API_KEY",
34
+ create: (params) => new deepseek_1.DeepSeekChatModel({ ...params }),
35
+ },
36
+ {
37
+ name: gemini_1.GeminiChatModel.name,
38
+ apiKeyEnvName: "GEMINI_API_KEY",
39
+ create: (params) => new gemini_1.GeminiChatModel({ ...params }),
40
+ },
41
+ {
42
+ name: ollama_1.OllamaChatModel.name,
43
+ apiKeyEnvName: "OLLAMA_API_KEY",
44
+ create: (params) => new ollama_1.OllamaChatModel({ ...params }),
45
+ },
46
+ {
47
+ name: open_router_1.OpenRouterChatModel.name,
48
+ apiKeyEnvName: "OPEN_ROUTER_API_KEY",
49
+ create: (params) => new open_router_1.OpenRouterChatModel({ ...params }),
50
+ },
51
+ {
52
+ name: xai_1.XAIChatModel.name,
53
+ apiKeyEnvName: "XAI_API_KEY",
54
+ create: (params) => new xai_1.XAIChatModel({ ...params }),
55
+ },
56
+ {
57
+ name: aigne_hub_model_js_1.AIGNEHubChatModel.name,
58
+ apiKeyEnvName: "AIGNE_HUB_API_KEY",
59
+ create: (params) => new aigne_hub_model_js_1.AIGNEHubChatModel({ ...params }),
60
+ },
61
+ ];
62
+ }
63
+ class HubChatModel extends core_1.ChatModel {
64
+ options;
65
+ client;
66
+ constructor(options) {
67
+ super();
68
+ this.options = options;
69
+ const models = availableModels();
70
+ const PROVIDER = process.env.BLOCKLET_AIGNE_API_PROVIDER?.toLowerCase() ?? "";
71
+ const provider = PROVIDER.replace(/-/g, "");
72
+ const m = models.find((m) => m.name.toLowerCase().includes(provider));
73
+ if (!m) {
74
+ throw new Error(`Unsupported model: ${process.env.BLOCKLET_AIGNE_API_PROVIDER} ${process.env.BLOCKLET_AIGNE_API_MODEL}`);
75
+ }
76
+ const credential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
77
+ const credentialOptions = credential
78
+ ? typeof credential === "string"
79
+ ? JSON.parse(credential)
80
+ : credential
81
+ : {};
82
+ const { apiKey, ...rest } = credentialOptions;
83
+ this.client = m.create({
84
+ ...options,
85
+ model: options.model ?? process.env.BLOCKLET_AIGNE_API_MODEL,
86
+ modelOptions: options.modelOptions,
87
+ baseURL: options.baseURL ?? options.url ?? process.env.BLOCKLET_AIGNE_API_URL,
88
+ apiKey: options.apiKey ?? apiKey,
89
+ ...rest,
90
+ });
91
+ }
92
+ process(input, options) {
93
+ return this.client.invoke(input, options);
94
+ }
95
+ }
96
+ exports.HubChatModel = HubChatModel;
@@ -1 +1,9 @@
1
- export * from "./aigne-hub-model.js";
1
+ import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
2
+ import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
3
+ import { type HubChatModelOptions } from "./hub-model.js";
4
+ export declare class AIGNEHubChatModel extends ChatModel {
5
+ options: HubChatModelOptions;
6
+ private client;
7
+ constructor(options: HubChatModelOptions);
8
+ process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
9
+ }
package/lib/cjs/index.js CHANGED
@@ -1,17 +1,21 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./aigne-hub-model.js"), exports);
3
+ exports.AIGNEHubChatModel = void 0;
4
+ const core_1 = require("@aigne/core");
5
+ const aigne_hub_model_js_1 = require("./aigne-hub-model.js");
6
+ const hub_model_js_1 = require("./hub-model.js");
7
+ class AIGNEHubChatModel extends core_1.ChatModel {
8
+ options;
9
+ client;
10
+ constructor(options) {
11
+ super();
12
+ this.options = options;
13
+ this.client = process.env.BLOCKLET_AIGNE_API_PROVIDER
14
+ ? new hub_model_js_1.HubChatModel(options)
15
+ : new aigne_hub_model_js_1.AIGNEHubChatModel(options);
16
+ }
17
+ process(input, options) {
18
+ return this.client.process(input, options);
19
+ }
20
+ }
21
+ exports.AIGNEHubChatModel = AIGNEHubChatModel;
@@ -1,7 +1,7 @@
1
1
  import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOptions, type ChatModelOutput } from "@aigne/core";
2
2
  import { type PromiseOrValue } from "@aigne/core/utils/type-utils.js";
3
3
  import type { OpenAIChatModelOptions } from "@aigne/openai";
4
- interface AIGNEHubChatModelOptions {
4
+ export interface AIGNEHubChatModelOptions {
5
5
  url?: string;
6
6
  accessKey?: string;
7
7
  model?: string;
@@ -14,4 +14,3 @@ export declare class AIGNEHubChatModel extends ChatModel {
14
14
  constructor(options: AIGNEHubChatModelOptions);
15
15
  process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
16
16
  }
17
- export {};
@@ -0,0 +1,21 @@
1
+ import { type AnthropicChatModelOptions } from "@aigne/anthropic";
2
+ import { type BedrockChatModelOptions } from "@aigne/bedrock";
3
+ import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
4
+ import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
5
+ import { type OpenAIChatModelOptions } from "@aigne/openai";
6
+ import { type AIGNEHubChatModelOptions } from "./aigne-hub-model.js";
7
+ export type HubChatModelOptions = AIGNEHubChatModelOptions | AnthropicChatModelOptions | BedrockChatModelOptions | OpenAIChatModelOptions;
8
+ export declare class HubChatModel extends ChatModel {
9
+ options: HubChatModelOptions & {
10
+ apiKey?: string;
11
+ baseURL?: string;
12
+ url?: string;
13
+ };
14
+ private client;
15
+ constructor(options: HubChatModelOptions & {
16
+ apiKey?: string;
17
+ baseURL?: string;
18
+ url?: string;
19
+ });
20
+ process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
21
+ }
@@ -1 +1,9 @@
1
- export * from "./aigne-hub-model.js";
1
+ import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
2
+ import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
3
+ import { type HubChatModelOptions } from "./hub-model.js";
4
+ export declare class AIGNEHubChatModel extends ChatModel {
5
+ options: HubChatModelOptions;
6
+ private client;
7
+ constructor(options: HubChatModelOptions);
8
+ process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
9
+ }
@@ -1,7 +1,7 @@
1
1
  import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOptions, type ChatModelOutput } from "@aigne/core";
2
2
  import { type PromiseOrValue } from "@aigne/core/utils/type-utils.js";
3
3
  import type { OpenAIChatModelOptions } from "@aigne/openai";
4
- interface AIGNEHubChatModelOptions {
4
+ export interface AIGNEHubChatModelOptions {
5
5
  url?: string;
6
6
  accessKey?: string;
7
7
  model?: string;
@@ -14,4 +14,3 @@ export declare class AIGNEHubChatModel extends ChatModel {
14
14
  constructor(options: AIGNEHubChatModelOptions);
15
15
  process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
16
16
  }
17
- export {};
@@ -1,9 +1,10 @@
1
1
  import { ChatModel, } from "@aigne/core";
2
2
  import { checkArguments } from "@aigne/core/utils/type-utils.js";
3
3
  import { BaseClient } from "@aigne/transport/http-client/base-client.js";
4
+ import { joinURL } from "ufo";
4
5
  import { z } from "zod";
5
6
  const DEFAULT_CHAT_MODEL = "openai/gpt-4o";
6
- const DEFAULT_URL = "https://www.aikit.rocks/ai-kit/api/v2/chat";
7
+ const DEFAULT_URL = "https://hub.aigne.io/ai-kit/";
7
8
  const aigneHubChatModelOptionsSchema = z.object({
8
9
  url: z.string().optional(),
9
10
  accessKey: z.string().optional(),
@@ -29,9 +30,9 @@ export class AIGNEHubChatModel extends ChatModel {
29
30
  this.options = options;
30
31
  this.client = new BaseClient({
31
32
  ...options,
32
- url: options.url ?? process.env.AIGNE_HUB_BASE_URL ?? DEFAULT_URL,
33
- model: options.model ?? DEFAULT_CHAT_MODEL,
34
- accessKey: options.accessKey ?? process.env.AIGNE_HUB_ACCESS_KEY,
33
+ url: joinURL(options.url || process.env.AIGNE_HUB_API_URL || DEFAULT_URL, "/api/v2/chat"),
34
+ model: options.model || DEFAULT_CHAT_MODEL,
35
+ accessKey: options.accessKey || process.env.AIGNE_HUB_API_KEY,
35
36
  });
36
37
  }
37
38
  process(input, options) {
@@ -0,0 +1,21 @@
1
+ import { type AnthropicChatModelOptions } from "@aigne/anthropic";
2
+ import { type BedrockChatModelOptions } from "@aigne/bedrock";
3
+ import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
4
+ import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
5
+ import { type OpenAIChatModelOptions } from "@aigne/openai";
6
+ import { type AIGNEHubChatModelOptions } from "./aigne-hub-model.js";
7
+ export type HubChatModelOptions = AIGNEHubChatModelOptions | AnthropicChatModelOptions | BedrockChatModelOptions | OpenAIChatModelOptions;
8
+ export declare class HubChatModel extends ChatModel {
9
+ options: HubChatModelOptions & {
10
+ apiKey?: string;
11
+ baseURL?: string;
12
+ url?: string;
13
+ };
14
+ private client;
15
+ constructor(options: HubChatModelOptions & {
16
+ apiKey?: string;
17
+ baseURL?: string;
18
+ url?: string;
19
+ });
20
+ process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
21
+ }
@@ -0,0 +1,92 @@
1
+ import { AnthropicChatModel } from "@aigne/anthropic";
2
+ import { BedrockChatModel } from "@aigne/bedrock";
3
+ import { ChatModel, } from "@aigne/core";
4
+ import { DeepSeekChatModel } from "@aigne/deepseek";
5
+ import { GeminiChatModel } from "@aigne/gemini";
6
+ import { OllamaChatModel } from "@aigne/ollama";
7
+ import { OpenRouterChatModel } from "@aigne/open-router";
8
+ import { OpenAIChatModel } from "@aigne/openai";
9
+ import { XAIChatModel } from "@aigne/xai";
10
+ import { AIGNEHubChatModel } from "./aigne-hub-model.js";
11
+ function availableModels() {
12
+ return [
13
+ {
14
+ name: OpenAIChatModel.name,
15
+ apiKeyEnvName: "OPENAI_API_KEY",
16
+ create: (params) => new OpenAIChatModel({ ...params }),
17
+ },
18
+ {
19
+ name: AnthropicChatModel.name,
20
+ apiKeyEnvName: "ANTHROPIC_API_KEY",
21
+ create: (params) => new AnthropicChatModel({ ...params }),
22
+ },
23
+ {
24
+ name: BedrockChatModel.name,
25
+ apiKeyEnvName: "AWS_ACCESS_KEY_ID",
26
+ create: (params) => new BedrockChatModel({ ...params }),
27
+ },
28
+ {
29
+ name: DeepSeekChatModel.name,
30
+ apiKeyEnvName: "DEEPSEEK_API_KEY",
31
+ create: (params) => new DeepSeekChatModel({ ...params }),
32
+ },
33
+ {
34
+ name: GeminiChatModel.name,
35
+ apiKeyEnvName: "GEMINI_API_KEY",
36
+ create: (params) => new GeminiChatModel({ ...params }),
37
+ },
38
+ {
39
+ name: OllamaChatModel.name,
40
+ apiKeyEnvName: "OLLAMA_API_KEY",
41
+ create: (params) => new OllamaChatModel({ ...params }),
42
+ },
43
+ {
44
+ name: OpenRouterChatModel.name,
45
+ apiKeyEnvName: "OPEN_ROUTER_API_KEY",
46
+ create: (params) => new OpenRouterChatModel({ ...params }),
47
+ },
48
+ {
49
+ name: XAIChatModel.name,
50
+ apiKeyEnvName: "XAI_API_KEY",
51
+ create: (params) => new XAIChatModel({ ...params }),
52
+ },
53
+ {
54
+ name: AIGNEHubChatModel.name,
55
+ apiKeyEnvName: "AIGNE_HUB_API_KEY",
56
+ create: (params) => new AIGNEHubChatModel({ ...params }),
57
+ },
58
+ ];
59
+ }
60
+ export class HubChatModel extends ChatModel {
61
+ options;
62
+ client;
63
+ constructor(options) {
64
+ super();
65
+ this.options = options;
66
+ const models = availableModels();
67
+ const PROVIDER = process.env.BLOCKLET_AIGNE_API_PROVIDER?.toLowerCase() ?? "";
68
+ const provider = PROVIDER.replace(/-/g, "");
69
+ const m = models.find((m) => m.name.toLowerCase().includes(provider));
70
+ if (!m) {
71
+ throw new Error(`Unsupported model: ${process.env.BLOCKLET_AIGNE_API_PROVIDER} ${process.env.BLOCKLET_AIGNE_API_MODEL}`);
72
+ }
73
+ const credential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
74
+ const credentialOptions = credential
75
+ ? typeof credential === "string"
76
+ ? JSON.parse(credential)
77
+ : credential
78
+ : {};
79
+ const { apiKey, ...rest } = credentialOptions;
80
+ this.client = m.create({
81
+ ...options,
82
+ model: options.model ?? process.env.BLOCKLET_AIGNE_API_MODEL,
83
+ modelOptions: options.modelOptions,
84
+ baseURL: options.baseURL ?? options.url ?? process.env.BLOCKLET_AIGNE_API_URL,
85
+ apiKey: options.apiKey ?? apiKey,
86
+ ...rest,
87
+ });
88
+ }
89
+ process(input, options) {
90
+ return this.client.invoke(input, options);
91
+ }
92
+ }
@@ -1 +1,9 @@
1
- export * from "./aigne-hub-model.js";
1
+ import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
2
+ import type { PromiseOrValue } from "@aigne/core/utils/type-utils.js";
3
+ import { type HubChatModelOptions } from "./hub-model.js";
4
+ export declare class AIGNEHubChatModel extends ChatModel {
5
+ options: HubChatModelOptions;
6
+ private client;
7
+ constructor(options: HubChatModelOptions);
8
+ process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
9
+ }
package/lib/esm/index.js CHANGED
@@ -1 +1,17 @@
1
- export * from "./aigne-hub-model.js";
1
+ import { ChatModel, } from "@aigne/core";
2
+ import { AIGNEHubChatModel as _AIGNEHubChatModel, } from "./aigne-hub-model.js";
3
+ import { HubChatModel } from "./hub-model.js";
4
+ export class AIGNEHubChatModel extends ChatModel {
5
+ options;
6
+ client;
7
+ constructor(options) {
8
+ super();
9
+ this.options = options;
10
+ this.client = process.env.BLOCKLET_AIGNE_API_PROVIDER
11
+ ? new HubChatModel(options)
12
+ : new _AIGNEHubChatModel(options);
13
+ }
14
+ process(input, options) {
15
+ return this.client.process(input, options);
16
+ }
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/aigne-hub",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "AIGNE Hub SDK for integrating with Hub AI models",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -26,8 +26,17 @@
26
26
  "types": "./lib/dts/index.d.ts",
27
27
  "dependencies": {
28
28
  "zod": "^3.25.67",
29
- "@aigne/core": "^1.36.0",
30
- "@aigne/transport": "^0.10.2"
29
+ "@aigne/transport": "^0.10.4",
30
+ "@aigne/anthropic": "^0.10.0",
31
+ "@aigne/bedrock": "^0.8.4",
32
+ "@aigne/core": "^1.38.0",
33
+ "@aigne/deepseek": "^0.7.4",
34
+ "@aigne/default-memory": "^1.0.4",
35
+ "@aigne/gemini": "^0.8.4",
36
+ "@aigne/ollama": "^0.7.4",
37
+ "@aigne/open-router": "^0.7.4",
38
+ "@aigne/openai": "^0.10.4",
39
+ "@aigne/xai": "^0.7.4"
31
40
  },
32
41
  "devDependencies": {
33
42
  "@types/bun": "^1.2.18",
@@ -36,8 +45,8 @@
36
45
  "npm-run-all": "^4.1.5",
37
46
  "rimraf": "^6.0.1",
38
47
  "typescript": "^5.8.3",
39
- "@aigne/openai": "^0.10.2",
40
- "@aigne/test-utils": "^0.5.10"
48
+ "@aigne/openai": "^0.10.4",
49
+ "@aigne/test-utils": "^0.5.12"
41
50
  },
42
51
  "scripts": {
43
52
  "lint": "tsc --noEmit",