@aigne/aigne-hub 0.10.17-beta.1 → 1.74.0-beta

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.
Files changed (107) hide show
  1. package/README.md +11 -11
  2. package/dist/aigne-hub-image-model.cjs +91 -0
  3. package/dist/aigne-hub-image-model.mjs +92 -0
  4. package/dist/aigne-hub-image-model.mjs.map +1 -0
  5. package/dist/aigne-hub-model.cjs +80 -0
  6. package/dist/aigne-hub-model.mjs +81 -0
  7. package/dist/aigne-hub-model.mjs.map +1 -0
  8. package/dist/aigne-hub-video-model.cjs +95 -0
  9. package/dist/aigne-hub-video-model.mjs +96 -0
  10. package/dist/aigne-hub-video-model.mjs.map +1 -0
  11. package/dist/index.cjs +139 -0
  12. package/dist/index.d.cts +118 -0
  13. package/dist/index.d.cts.map +1 -0
  14. package/dist/index.d.mts +118 -0
  15. package/dist/index.d.mts.map +1 -0
  16. package/dist/index.mjs +117 -0
  17. package/dist/index.mjs.map +1 -0
  18. package/dist/utils/blocklet.cjs +13 -0
  19. package/dist/utils/blocklet.d.cts +5 -0
  20. package/dist/utils/blocklet.d.cts.map +1 -0
  21. package/dist/utils/blocklet.d.mts +5 -0
  22. package/dist/utils/blocklet.d.mts.map +1 -0
  23. package/dist/utils/blocklet.mjs +14 -0
  24. package/dist/utils/blocklet.mjs.map +1 -0
  25. package/dist/utils/constants.cjs +46 -0
  26. package/dist/utils/constants.d.cts +26 -0
  27. package/dist/utils/constants.d.cts.map +1 -0
  28. package/dist/utils/constants.d.mts +26 -0
  29. package/dist/utils/constants.d.mts.map +1 -0
  30. package/dist/utils/constants.mjs +38 -0
  31. package/dist/utils/constants.mjs.map +1 -0
  32. package/dist/utils/find-provider.cjs +161 -0
  33. package/{lib/cjs/utils/find-provider.d.ts → dist/utils/find-provider.d.cts} +10 -5
  34. package/dist/utils/find-provider.d.cts.map +1 -0
  35. package/{lib/esm/utils/find-provider.d.ts → dist/utils/find-provider.d.mts} +10 -5
  36. package/dist/utils/find-provider.d.mts.map +1 -0
  37. package/dist/utils/find-provider.mjs +159 -0
  38. package/dist/utils/find-provider.mjs.map +1 -0
  39. package/dist/utils/hub.cjs +24 -0
  40. package/dist/utils/hub.mjs +25 -0
  41. package/dist/utils/hub.mjs.map +1 -0
  42. package/dist/utils/model.cjs +260 -0
  43. package/dist/utils/model.d.cts +57 -0
  44. package/dist/utils/model.d.cts.map +1 -0
  45. package/dist/utils/model.d.mts +57 -0
  46. package/dist/utils/model.d.mts.map +1 -0
  47. package/dist/utils/model.mjs +255 -0
  48. package/dist/utils/model.mjs.map +1 -0
  49. package/dist/utils/type.cjs +20 -0
  50. package/dist/utils/type.d.cts +28 -0
  51. package/dist/utils/type.d.cts.map +1 -0
  52. package/dist/utils/type.d.mts +29 -0
  53. package/dist/utils/type.d.mts.map +1 -0
  54. package/dist/utils/type.mjs +21 -0
  55. package/dist/utils/type.mjs.map +1 -0
  56. package/package.json +40 -41
  57. package/CHANGELOG.md +0 -4238
  58. package/lib/cjs/aigne-hub-image-model.d.ts +0 -28
  59. package/lib/cjs/aigne-hub-image-model.js +0 -90
  60. package/lib/cjs/aigne-hub-model.d.ts +0 -28
  61. package/lib/cjs/aigne-hub-model.js +0 -80
  62. package/lib/cjs/aigne-hub-video-model.d.ts +0 -28
  63. package/lib/cjs/aigne-hub-video-model.js +0 -89
  64. package/lib/cjs/index.d.ts +0 -112
  65. package/lib/cjs/index.js +0 -135
  66. package/lib/cjs/package.json +0 -3
  67. package/lib/cjs/utils/blocklet.d.ts +0 -1
  68. package/lib/cjs/utils/blocklet.js +0 -15
  69. package/lib/cjs/utils/constants.d.ts +0 -22
  70. package/lib/cjs/utils/constants.js +0 -37
  71. package/lib/cjs/utils/find-provider.js +0 -121
  72. package/lib/cjs/utils/hub.d.ts +0 -16
  73. package/lib/cjs/utils/hub.js +0 -30
  74. package/lib/cjs/utils/model.d.ts +0 -52
  75. package/lib/cjs/utils/model.js +0 -207
  76. package/lib/cjs/utils/type.d.ts +0 -78
  77. package/lib/cjs/utils/type.js +0 -20
  78. package/lib/dts/aigne-hub-image-model.d.ts +0 -28
  79. package/lib/dts/aigne-hub-model.d.ts +0 -28
  80. package/lib/dts/aigne-hub-video-model.d.ts +0 -28
  81. package/lib/dts/index.d.ts +0 -112
  82. package/lib/dts/utils/blocklet.d.ts +0 -1
  83. package/lib/dts/utils/constants.d.ts +0 -22
  84. package/lib/dts/utils/find-provider.d.ts +0 -17
  85. package/lib/dts/utils/hub.d.ts +0 -16
  86. package/lib/dts/utils/model.d.ts +0 -52
  87. package/lib/dts/utils/type.d.ts +0 -78
  88. package/lib/esm/aigne-hub-image-model.d.ts +0 -28
  89. package/lib/esm/aigne-hub-image-model.js +0 -86
  90. package/lib/esm/aigne-hub-model.d.ts +0 -28
  91. package/lib/esm/aigne-hub-model.js +0 -76
  92. package/lib/esm/aigne-hub-video-model.d.ts +0 -28
  93. package/lib/esm/aigne-hub-video-model.js +0 -85
  94. package/lib/esm/index.d.ts +0 -112
  95. package/lib/esm/index.js +0 -115
  96. package/lib/esm/package.json +0 -3
  97. package/lib/esm/utils/blocklet.d.ts +0 -1
  98. package/lib/esm/utils/blocklet.js +0 -12
  99. package/lib/esm/utils/constants.d.ts +0 -22
  100. package/lib/esm/utils/constants.js +0 -33
  101. package/lib/esm/utils/find-provider.js +0 -115
  102. package/lib/esm/utils/hub.d.ts +0 -16
  103. package/lib/esm/utils/hub.js +0 -27
  104. package/lib/esm/utils/model.d.ts +0 -52
  105. package/lib/esm/utils/model.js +0 -197
  106. package/lib/esm/utils/type.d.ts +0 -78
  107. package/lib/esm/utils/type.js +0 -17
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROVIDER_RANK = exports.AI_PROVIDERS = exports.aigneHubBaseUrl = exports.AIGNE_HUB_PROVIDER = exports.AIGNE_HUB_VIDEO_MODEL = exports.AIGNE_HUB_IMAGE_MODEL = exports.AIGNE_HUB_DEFAULT_MODEL = exports.AIGNE_HUB_BLOCKLET_DID = exports.AIGNE_HUB_URL = void 0;
4
- exports.AIGNE_HUB_URL = "https://hub.aigne.io/";
5
- exports.AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
6
- exports.AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
7
- exports.AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
8
- exports.AIGNE_HUB_VIDEO_MODEL = "openai/sora-2";
9
- exports.AIGNE_HUB_PROVIDER = "aignehub";
10
- const aigneHubBaseUrl = () => process.env.BLOCKLET_AIGNE_API_URL || process.env.AIGNE_HUB_API_URL || exports.AIGNE_HUB_URL;
11
- exports.aigneHubBaseUrl = aigneHubBaseUrl;
12
- exports.AI_PROVIDERS = {
13
- OPENAI: "openai",
14
- ANTHROPIC: "anthropic",
15
- BEDROCK: "bedrock",
16
- DEEPSEEK: "deepseek",
17
- GOOGLE: "google",
18
- OLLAMA: "ollama",
19
- OPENROUTER: "openrouter",
20
- XAI: "xai",
21
- DOUBAO: "doubao",
22
- POE: "poe",
23
- IDEOGRAM: "ideogram",
24
- };
25
- exports.PROVIDER_RANK = {
26
- openai: 1,
27
- anthropic: 1,
28
- google: 1,
29
- deepseek: 1,
30
- xai: 1,
31
- doubao: 1,
32
- ideogram: 1,
33
- bedrock: 2,
34
- openrouter: 3,
35
- poe: 3,
36
- ollama: 4,
37
- };
@@ -1,121 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.inferVendorFromModel = inferVendorFromModel;
4
- exports.getDefaultProviderForModel = getDefaultProviderForModel;
5
- exports.getSupportedProviders = getSupportedProviders;
6
- exports.resolveProviderModelId = resolveProviderModelId;
7
- const constants_js_1 = require("./constants.js");
8
- const MODEL_CONFIGS = [
9
- {
10
- pattern: /^gemini|^imagen|^veo/,
11
- vendor: "google",
12
- defaultProvider: "google",
13
- supportedProviders: ["google", "openrouter", "poe"],
14
- },
15
- {
16
- pattern: /^gpt-|^o[13]-|^dall-e-|^text-embedding|^sora-/,
17
- vendor: "openai",
18
- defaultProvider: "openai",
19
- supportedProviders: ["openai", "openrouter", "poe"],
20
- },
21
- {
22
- pattern: /^claude/,
23
- vendor: "anthropic",
24
- defaultProvider: "anthropic",
25
- supportedProviders: ["anthropic", "bedrock", "openrouter", "poe"],
26
- },
27
- {
28
- pattern: /^deepseek/,
29
- vendor: "deepseek",
30
- defaultProvider: "deepseek",
31
- supportedProviders: ["deepseek", "openrouter", "ollama"],
32
- },
33
- {
34
- pattern: /^grok/,
35
- vendor: "xai",
36
- defaultProvider: "xai",
37
- supportedProviders: ["xai", "openrouter", "poe"],
38
- },
39
- {
40
- pattern: /^doubao/,
41
- vendor: "doubao",
42
- defaultProvider: "doubao",
43
- supportedProviders: ["doubao"],
44
- },
45
- {
46
- pattern: /^llama/,
47
- vendor: "meta",
48
- supportedProviders: ["openrouter", "ollama", "bedrock"],
49
- },
50
- {
51
- pattern: /^mistral|^mixtral/,
52
- vendor: "mistral",
53
- supportedProviders: ["openrouter", "ollama", "bedrock"],
54
- },
55
- {
56
- pattern: /^qwen/,
57
- vendor: "qwen",
58
- supportedProviders: ["openrouter", "ollama", "bedrock"],
59
- },
60
- {
61
- pattern: /^gemma/,
62
- vendor: "google",
63
- supportedProviders: ["openrouter", "ollama", "bedrock"],
64
- },
65
- {
66
- pattern: /^yi/,
67
- vendor: "yi",
68
- supportedProviders: ["openrouter", "ollama", "bedrock"],
69
- },
70
- {
71
- pattern: /^phi/,
72
- vendor: "microsoft",
73
- supportedProviders: ["openrouter", "ollama", "bedrock"],
74
- },
75
- ];
76
- function findModelConfig(model) {
77
- if (!model)
78
- return undefined;
79
- const id = model.toLowerCase();
80
- return MODEL_CONFIGS.find((config) => config.pattern.test(id));
81
- }
82
- function inferVendorFromModel(model) {
83
- return findModelConfig(model)?.vendor;
84
- }
85
- function getDefaultProviderForModel(model) {
86
- const config = findModelConfig(model);
87
- if (!config)
88
- return null;
89
- return config.defaultProvider ?? (config.supportedProviders?.[0] || null);
90
- }
91
- function getSupportedProviders(model) {
92
- const config = findModelConfig(model);
93
- if (!config?.supportedProviders)
94
- return [];
95
- return config.supportedProviders.sort((a, b) => constants_js_1.PROVIDER_RANK[a] - constants_js_1.PROVIDER_RANK[b]);
96
- }
97
- /**
98
- * Resolve provider-specific model ID based on platform conventions
99
- * @param provider - The provider name (e.g., 'openrouter', 'bedrock', 'google')
100
- * @param canonicalModel - The canonical model name (e.g., 'gemini-2.5-pro', 'claude-3-5-sonnet-20241022')
101
- * @param vendor - Optional vendor hint (e.g., 'google' for gemini models, 'anthropic' for claude)
102
- * @returns Provider-specific model ID
103
- *
104
- * Examples:
105
- * - OpenRouter: 'google/gemini-2.5-pro', 'openai/gpt-4o', 'anthropic/claude-3-5-sonnet'
106
- * - Bedrock: 'anthropic.claude-3-5-sonnet-20241022-v2:0', 'meta.llama3-70b-instruct-v1:0'
107
- * - Direct providers (google, openai, etc.): 'gemini-2.5-pro', 'gpt-4o'
108
- */
109
- function resolveProviderModelId(provider, canonicalModel, vendor) {
110
- const v = vendor || inferVendorFromModel(canonicalModel);
111
- if (provider === "bedrock" && v) {
112
- if (canonicalModel.includes(".")) {
113
- return canonicalModel;
114
- }
115
- return `${v}.${canonicalModel}`;
116
- }
117
- if (provider === "openrouter" && v && !canonicalModel.startsWith(`${v}/`)) {
118
- return `${v}/${canonicalModel}`;
119
- }
120
- return canonicalModel;
121
- }
@@ -1,16 +0,0 @@
1
- export interface GetModelsOptions {
2
- baseURL?: string;
3
- type?: "image" | "chat" | "embedding" | "video";
4
- }
5
- export declare function getModels(options: GetModelsOptions): Promise<{
6
- type: string;
7
- model: string;
8
- provider: string;
9
- input_credits_per_token: string;
10
- output_credits_per_token: string;
11
- providerDisplayName: string;
12
- status?: {
13
- available: boolean;
14
- } | null | undefined;
15
- modelMetadata?: Record<string, unknown> | null | undefined;
16
- }[]>;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getModels = getModels;
4
- const fetch_js_1 = require("@aigne/core/utils/fetch.js");
5
- const ufo_1 = require("ufo");
6
- const zod_1 = require("zod");
7
- const blocklet_js_1 = require("./blocklet.js");
8
- const constants_js_1 = require("./constants.js");
9
- const modelsSchema = zod_1.z.array(zod_1.z.object({
10
- model: zod_1.z.string(),
11
- type: zod_1.z.string(),
12
- provider: zod_1.z.string(),
13
- input_credits_per_token: zod_1.z.string(),
14
- output_credits_per_token: zod_1.z.string(),
15
- modelMetadata: zod_1.z.record(zod_1.z.unknown()).nullish(),
16
- providerDisplayName: zod_1.z.string(),
17
- status: zod_1.z
18
- .object({
19
- available: zod_1.z.boolean(),
20
- })
21
- .nullish(),
22
- }));
23
- async function getModels(options) {
24
- const url = await (0, blocklet_js_1.getAIGNEHubMountPoint)(options.baseURL || (0, constants_js_1.aigneHubBaseUrl)(), constants_js_1.AIGNE_HUB_BLOCKLET_DID);
25
- const response = await (0, fetch_js_1.fetch)((0, ufo_1.withQuery)((0, ufo_1.joinURL)(url, "/api/ai/models"), {
26
- type: options.type,
27
- }));
28
- const json = await response.json();
29
- return modelsSchema.parse(json);
30
- }
@@ -1,52 +0,0 @@
1
- import type { ChatModel, ChatModelInputOptionsWithGetter, ImageModel, ImageModelInputOptionsWithGetter, VideoModel } from "@aigne/core";
2
- export interface LoadableModel {
3
- name: string | string[];
4
- apiKeyEnvName?: string | string[];
5
- create: (options: {
6
- model?: string;
7
- modelOptions?: ChatModelInputOptionsWithGetter;
8
- apiKey?: string;
9
- baseURL?: string;
10
- }) => ChatModel;
11
- }
12
- export declare function availableModels(): LoadableModel[];
13
- export interface LoadableImageModel {
14
- name: string | string[];
15
- apiKeyEnvName: string;
16
- create: (options: {
17
- apiKey?: string;
18
- baseURL?: string;
19
- model?: string;
20
- modelOptions?: ImageModelInputOptionsWithGetter;
21
- }) => ImageModel;
22
- }
23
- export interface LoadableVideoModel {
24
- name: string | string[];
25
- apiKeyEnvName: string;
26
- create: (options: {
27
- apiKey?: string;
28
- baseURL?: string;
29
- model?: string;
30
- modelOptions?: {
31
- [key: string]: any;
32
- };
33
- }) => VideoModel;
34
- }
35
- export declare function availableImageModels(): LoadableImageModel[];
36
- export declare function availableVideoModels(): LoadableVideoModel[];
37
- export declare function findModel(provider: string): {
38
- all: LoadableModel[];
39
- match: LoadableModel | undefined;
40
- };
41
- export declare function findImageModel(provider: string): {
42
- all: LoadableImageModel[];
43
- match: LoadableImageModel | undefined;
44
- };
45
- export declare function findVideoModel(provider: string): {
46
- all: LoadableVideoModel[];
47
- match: LoadableVideoModel | undefined;
48
- };
49
- export declare const parseModel: (model: string) => {
50
- provider: string | undefined;
51
- model: string | undefined;
52
- };
@@ -1,207 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseModel = void 0;
4
- exports.availableModels = availableModels;
5
- exports.availableImageModels = availableImageModels;
6
- exports.availableVideoModels = availableVideoModels;
7
- exports.findModel = findModel;
8
- exports.findImageModel = findImageModel;
9
- exports.findVideoModel = findVideoModel;
10
- const anthropic_1 = require("@aigne/anthropic");
11
- const bedrock_1 = require("@aigne/bedrock");
12
- const deepseek_1 = require("@aigne/deepseek");
13
- const doubao_1 = require("@aigne/doubao");
14
- const gemini_1 = require("@aigne/gemini");
15
- const ideogram_1 = require("@aigne/ideogram");
16
- const ollama_1 = require("@aigne/ollama");
17
- const open_router_1 = require("@aigne/open-router");
18
- const openai_1 = require("@aigne/openai");
19
- const poe_1 = require("@aigne/poe");
20
- const xai_1 = require("@aigne/xai");
21
- const node_http_handler_1 = require("@smithy/node-http-handler");
22
- const https_proxy_agent_1 = require("https-proxy-agent");
23
- const aigne_hub_image_model_js_1 = require("../aigne-hub-image-model.js");
24
- const aigne_hub_model_js_1 = require("../aigne-hub-model.js");
25
- const aigne_hub_video_model_js_1 = require("../aigne-hub-video-model.js");
26
- const constants_js_1 = require("./constants.js");
27
- const getClientOptions = () => {
28
- const proxy = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy"]
29
- .map((i) => process.env[i])
30
- .filter(Boolean)[0];
31
- const httpAgent = proxy ? new https_proxy_agent_1.HttpsProxyAgent(proxy) : undefined;
32
- const clientOptions = {
33
- fetchOptions: {
34
- // @ts-ignore
35
- agent: httpAgent,
36
- },
37
- };
38
- return {
39
- clientOptions,
40
- httpAgent,
41
- };
42
- };
43
- const GOOGLE = "google";
44
- function availableModels() {
45
- const { clientOptions, httpAgent } = getClientOptions();
46
- return [
47
- {
48
- name: openai_1.OpenAIChatModel.name,
49
- apiKeyEnvName: "OPENAI_API_KEY",
50
- create: (params) => new openai_1.OpenAIChatModel({ ...params, clientOptions }),
51
- },
52
- {
53
- name: anthropic_1.AnthropicChatModel.name,
54
- apiKeyEnvName: "ANTHROPIC_API_KEY",
55
- create: (params) => new anthropic_1.AnthropicChatModel({ ...params, clientOptions }),
56
- },
57
- {
58
- name: bedrock_1.BedrockChatModel.name,
59
- apiKeyEnvName: "AWS_ACCESS_KEY_ID",
60
- create: (params) => new bedrock_1.BedrockChatModel({
61
- ...params,
62
- clientOptions: {
63
- requestHandler: node_http_handler_1.NodeHttpHandler.create({ httpAgent, httpsAgent: httpAgent }),
64
- streamCollector: node_http_handler_1.streamCollector,
65
- },
66
- }),
67
- },
68
- {
69
- name: deepseek_1.DeepSeekChatModel.name,
70
- apiKeyEnvName: "DEEPSEEK_API_KEY",
71
- create: (params) => new deepseek_1.DeepSeekChatModel({ ...params, clientOptions }),
72
- },
73
- {
74
- name: [gemini_1.GeminiChatModel.name, GOOGLE],
75
- apiKeyEnvName: ["GEMINI_API_KEY", "GOOGLE_API_KEY"],
76
- create: (params) => new gemini_1.GeminiChatModel({
77
- ...params,
78
- clientOptions: { httpOptions: clientOptions.fetchOptions },
79
- }),
80
- },
81
- {
82
- name: ollama_1.OllamaChatModel.name,
83
- apiKeyEnvName: "OLLAMA_API_KEY",
84
- create: (params) => new ollama_1.OllamaChatModel({ ...params, clientOptions }),
85
- },
86
- {
87
- name: open_router_1.OpenRouterChatModel.name,
88
- apiKeyEnvName: "OPEN_ROUTER_API_KEY",
89
- create: (params) => new open_router_1.OpenRouterChatModel({ ...params, clientOptions }),
90
- },
91
- {
92
- name: xai_1.XAIChatModel.name,
93
- apiKeyEnvName: "XAI_API_KEY",
94
- create: (params) => new xai_1.XAIChatModel({ ...params, clientOptions }),
95
- },
96
- {
97
- name: doubao_1.DoubaoChatModel.name,
98
- apiKeyEnvName: "DOUBAO_API_KEY",
99
- create: (params) => new doubao_1.DoubaoChatModel({ ...params, clientOptions }),
100
- },
101
- {
102
- name: poe_1.PoeChatModel.name,
103
- apiKeyEnvName: "POE_API_KEY",
104
- create: (params) => new poe_1.PoeChatModel({ ...params, clientOptions }),
105
- },
106
- {
107
- name: aigne_hub_model_js_1.AIGNEHubChatModel.name,
108
- apiKeyEnvName: "AIGNE_HUB_API_KEY",
109
- create: (params) => new aigne_hub_model_js_1.AIGNEHubChatModel({ ...params, clientOptions }),
110
- },
111
- ];
112
- }
113
- function availableImageModels() {
114
- const { clientOptions } = getClientOptions();
115
- return [
116
- {
117
- name: openai_1.OpenAIImageModel.name,
118
- apiKeyEnvName: "OPENAI_API_KEY",
119
- create: (params) => new openai_1.OpenAIImageModel({ ...params, clientOptions }),
120
- },
121
- {
122
- name: [gemini_1.GeminiImageModel.name, GOOGLE],
123
- apiKeyEnvName: "GEMINI_API_KEY",
124
- create: (params) => new gemini_1.GeminiImageModel({ ...params, clientOptions }),
125
- },
126
- {
127
- name: ideogram_1.IdeogramImageModel.name,
128
- apiKeyEnvName: "IDEOGRAM_API_KEY",
129
- create: (params) => new ideogram_1.IdeogramImageModel({ ...params }),
130
- },
131
- {
132
- name: doubao_1.DoubaoImageModel.name,
133
- apiKeyEnvName: "DOUBAO_API_KEY",
134
- create: (params) => new doubao_1.DoubaoImageModel({ ...params, clientOptions }),
135
- },
136
- {
137
- name: aigne_hub_image_model_js_1.AIGNEHubImageModel.name,
138
- apiKeyEnvName: "AIGNE_HUB_API_KEY",
139
- create: (params) => new aigne_hub_image_model_js_1.AIGNEHubImageModel({ ...params, clientOptions }),
140
- },
141
- ];
142
- }
143
- function availableVideoModels() {
144
- const { clientOptions } = getClientOptions();
145
- return [
146
- {
147
- name: openai_1.OpenAIVideoModel.name,
148
- apiKeyEnvName: "OPENAI_API_KEY",
149
- create: (params) => new openai_1.OpenAIVideoModel({ ...params, clientOptions }),
150
- },
151
- {
152
- name: [gemini_1.GeminiVideoModel.name, GOOGLE],
153
- apiKeyEnvName: "GEMINI_API_KEY",
154
- create: (params) => new gemini_1.GeminiVideoModel({ ...params, clientOptions }),
155
- },
156
- {
157
- name: aigne_hub_video_model_js_1.AIGNEHubVideoModel.name,
158
- apiKeyEnvName: "AIGNE_HUB_API_KEY",
159
- create: (params) => new aigne_hub_video_model_js_1.AIGNEHubVideoModel({ ...params, clientOptions }),
160
- },
161
- ];
162
- }
163
- function findModel(provider) {
164
- provider = provider.toLowerCase().replace(/-/g, "");
165
- const all = availableModels();
166
- const match = all.find((m) => {
167
- if (typeof m.name === "string") {
168
- return m.name.toLowerCase().includes(provider);
169
- }
170
- return m.name.some((n) => n.toLowerCase().includes(provider));
171
- });
172
- return { all, match };
173
- }
174
- function findImageModel(provider) {
175
- provider = provider.toLowerCase().replace(/-/g, "");
176
- const all = availableImageModels();
177
- const match = all.find((m) => {
178
- if (typeof m.name === "string") {
179
- return m.name.toLowerCase().includes(provider);
180
- }
181
- return m.name.some((n) => n.toLowerCase().includes(provider));
182
- });
183
- return { all, match };
184
- }
185
- function findVideoModel(provider) {
186
- provider = provider.toLowerCase().replace(/-/g, "");
187
- const all = availableVideoModels();
188
- const match = all.find((m) => {
189
- if (typeof m.name === "string") {
190
- return m.name.toLowerCase().includes(provider);
191
- }
192
- return m.name.some((n) => n.toLowerCase().includes(provider));
193
- });
194
- return { all, match };
195
- }
196
- const parseModel = (model) => {
197
- // replace first ':' with '/' to compatible with `provider:model-name` format
198
- model = model.replace(/^([\w-]+):/, "$1/");
199
- let { provider, name } = model.match(/(?<provider>[^/]*)(\/(?<name>.*))?/)?.groups ?? {};
200
- provider = provider?.replace(/-/g, "");
201
- const match = provider ? findModel(provider)?.match : undefined;
202
- if (match) {
203
- return { provider, model: name };
204
- }
205
- return { provider: constants_js_1.AIGNE_HUB_PROVIDER, model };
206
- };
207
- exports.parseModel = parseModel;
@@ -1,78 +0,0 @@
1
- import type { ChatModelOptions, ImageModelOptions, VideoModelOptions } from "@aigne/core";
2
- import type { OpenAIChatModelOptions } from "@aigne/openai";
3
- import { z } from "zod";
4
- export declare const aigneHubModelOptionsSchema: z.ZodObject<{
5
- baseURL: 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
- model?: string | undefined;
33
- baseURL?: string | undefined;
34
- apiKey?: 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
- model?: string | undefined;
46
- baseURL?: string | undefined;
47
- apiKey?: 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 extends ChatModelOptions {
59
- baseURL?: string;
60
- apiKey?: string;
61
- clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
62
- clientId?: string;
63
- };
64
- }
65
- export interface AIGNEHubImageModelOptions extends ImageModelOptions {
66
- baseURL?: string;
67
- apiKey?: string;
68
- clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
69
- clientId?: string;
70
- };
71
- }
72
- export interface AIGNEHubVideoModelOptions extends VideoModelOptions {
73
- baseURL?: string;
74
- apiKey?: string;
75
- clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
76
- clientId?: string;
77
- };
78
- }
@@ -1,20 +0,0 @@
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
- baseURL: 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
- });
@@ -1,28 +0,0 @@
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
- models(): Promise<{
8
- type: string;
9
- model: string;
10
- provider: string;
11
- input_credits_per_token: string;
12
- output_credits_per_token: string;
13
- providerDisplayName: string;
14
- status?: {
15
- available: boolean;
16
- } | null | undefined;
17
- modelMetadata?: Record<string, unknown> | null | undefined;
18
- }[]>;
19
- protected _client?: Promise<BaseClient>;
20
- get client(): Promise<BaseClient>;
21
- private _credential?;
22
- get credential(): Promise<{
23
- url: string;
24
- apiKey?: string;
25
- model: string;
26
- }>;
27
- process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ImageModelOutput>>;
28
- }
@@ -1,28 +0,0 @@
1
- import { type AgentInvokeOptions, type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
2
- import { BaseClient, type BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
3
- import { type AIGNEHubChatModelOptions } from "./utils/type.js";
4
- export declare class AIGNEHubChatModel extends ChatModel {
5
- options: AIGNEHubChatModelOptions;
6
- constructor(options: AIGNEHubChatModelOptions);
7
- models(): Promise<{
8
- type: string;
9
- model: string;
10
- provider: string;
11
- input_credits_per_token: string;
12
- output_credits_per_token: string;
13
- providerDisplayName: string;
14
- status?: {
15
- available: boolean;
16
- } | null | undefined;
17
- modelMetadata?: Record<string, unknown> | null | undefined;
18
- }[]>;
19
- protected _client?: Promise<BaseClient>;
20
- get client(): Promise<BaseClient>;
21
- private _credential?;
22
- get credential(): Promise<{
23
- url: string;
24
- apiKey?: string;
25
- model: string;
26
- }>;
27
- process(input: ChatModelInput, options: BaseClientInvokeOptions & AgentInvokeOptions): Promise<AgentProcessResult<ChatModelOutput>>;
28
- }
@@ -1,28 +0,0 @@
1
- import { type AgentProcessResult, VideoModel, type VideoModelInput, type VideoModelOutput } from "@aigne/core";
2
- import { BaseClient, type BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
3
- import { type AIGNEHubVideoModelOptions } from "./utils/type.js";
4
- export declare class AIGNEHubVideoModel extends VideoModel {
5
- options: AIGNEHubVideoModelOptions;
6
- constructor(options: AIGNEHubVideoModelOptions);
7
- models(): Promise<{
8
- type: string;
9
- model: string;
10
- provider: string;
11
- input_credits_per_token: string;
12
- output_credits_per_token: string;
13
- providerDisplayName: string;
14
- status?: {
15
- available: boolean;
16
- } | null | undefined;
17
- modelMetadata?: Record<string, unknown> | null | undefined;
18
- }[]>;
19
- protected _client?: Promise<BaseClient>;
20
- get client(): Promise<BaseClient>;
21
- private _credential?;
22
- get credential(): Promise<{
23
- url: string;
24
- apiKey?: string;
25
- model: string;
26
- }>;
27
- process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<VideoModelOutput>>;
28
- }