@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,112 +0,0 @@
1
- import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput, ImageModel, type ImageModelInput, type ImageModelOutput, VideoModel, type VideoModelInput, type VideoModelOutput } from "@aigne/core";
2
- import type { BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
3
- import type { AIGNEHubChatModelOptions, AIGNEHubImageModelOptions, AIGNEHubVideoModelOptions } from "./utils/type.js";
4
- export * from "./utils/blocklet.js";
5
- export * from "./utils/constants.js";
6
- export * from "./utils/find-provider.js";
7
- export * from "./utils/model.js";
8
- export declare class AIGNEHubChatModel extends ChatModel {
9
- options: AIGNEHubChatModelOptions;
10
- static models(): Promise<{
11
- type: string;
12
- model: string;
13
- provider: string;
14
- input_credits_per_token: string;
15
- output_credits_per_token: string;
16
- providerDisplayName: string;
17
- status?: {
18
- available: boolean;
19
- } | null | undefined;
20
- modelMetadata?: Record<string, unknown> | null | undefined;
21
- }[]>;
22
- models(): Promise<{
23
- type: string;
24
- model: string;
25
- provider: string;
26
- input_credits_per_token: string;
27
- output_credits_per_token: string;
28
- providerDisplayName: string;
29
- status?: {
30
- available: boolean;
31
- } | null | undefined;
32
- modelMetadata?: Record<string, unknown> | null | undefined;
33
- }[]>;
34
- constructor(options: AIGNEHubChatModelOptions);
35
- protected client: ChatModel;
36
- get credential(): import("@aigne/core/utils/type-utils.js").PromiseOrValue<{
37
- url?: string;
38
- apiKey?: string;
39
- model?: string;
40
- }>;
41
- process(input: ChatModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ChatModelOutput>>;
42
- }
43
- export declare class AIGNEHubImageModel extends ImageModel {
44
- options: AIGNEHubImageModelOptions;
45
- static models(): Promise<{
46
- type: string;
47
- model: string;
48
- provider: string;
49
- input_credits_per_token: string;
50
- output_credits_per_token: string;
51
- providerDisplayName: string;
52
- status?: {
53
- available: boolean;
54
- } | null | undefined;
55
- modelMetadata?: Record<string, unknown> | null | undefined;
56
- }[]>;
57
- models(): Promise<{
58
- type: string;
59
- model: string;
60
- provider: string;
61
- input_credits_per_token: string;
62
- output_credits_per_token: string;
63
- providerDisplayName: string;
64
- status?: {
65
- available: boolean;
66
- } | null | undefined;
67
- modelMetadata?: Record<string, unknown> | null | undefined;
68
- }[]>;
69
- constructor(options: AIGNEHubImageModelOptions);
70
- protected client: ImageModel;
71
- get credential(): import("@aigne/core/utils/type-utils.js").PromiseOrValue<{
72
- url?: string;
73
- apiKey?: string;
74
- model?: string;
75
- }>;
76
- process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ImageModelOutput>>;
77
- }
78
- export declare class AIGNEHubVideoModel extends VideoModel {
79
- options: AIGNEHubVideoModelOptions;
80
- static models(): Promise<{
81
- type: string;
82
- model: string;
83
- provider: string;
84
- input_credits_per_token: string;
85
- output_credits_per_token: string;
86
- providerDisplayName: string;
87
- status?: {
88
- available: boolean;
89
- } | null | undefined;
90
- modelMetadata?: Record<string, unknown> | null | undefined;
91
- }[]>;
92
- models(): Promise<{
93
- type: string;
94
- model: string;
95
- provider: string;
96
- input_credits_per_token: string;
97
- output_credits_per_token: string;
98
- providerDisplayName: string;
99
- status?: {
100
- available: boolean;
101
- } | null | undefined;
102
- modelMetadata?: Record<string, unknown> | null | undefined;
103
- }[]>;
104
- constructor(options: AIGNEHubVideoModelOptions);
105
- protected client: VideoModel;
106
- get credential(): import("@aigne/core/utils/type-utils.js").PromiseOrValue<{
107
- url?: string;
108
- apiKey?: string;
109
- model?: string;
110
- }>;
111
- process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<VideoModelOutput>>;
112
- }
package/lib/esm/index.js DELETED
@@ -1,115 +0,0 @@
1
- import { ChatModel, ImageModel, VideoModel, } from "@aigne/core";
2
- import { getModels } from "./utils/hub.js";
3
- import { findImageModel, findModel, findVideoModel, parseModel } from "./utils/model.js";
4
- export * from "./utils/blocklet.js";
5
- export * from "./utils/constants.js";
6
- export * from "./utils/find-provider.js";
7
- export * from "./utils/model.js";
8
- export class AIGNEHubChatModel extends ChatModel {
9
- options;
10
- static async models() {
11
- return getModels({ type: "chat" });
12
- }
13
- models() {
14
- return getModels({ type: "chat" });
15
- }
16
- constructor(options) {
17
- let provider = process.env.BLOCKLET_AIGNE_API_PROVIDER;
18
- if (!provider && options.model) {
19
- const parsed = parseModel(options.model);
20
- if (parsed.provider && parsed.model) {
21
- provider = parsed.provider;
22
- options.model = parsed.model;
23
- }
24
- }
25
- provider ||= AIGNEHubChatModel.name;
26
- const { match, all } = findModel(provider);
27
- if (!match) {
28
- const available = all.map((m) => m.name).join(", ");
29
- throw new Error(`Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
30
- }
31
- const client = match.create(options);
32
- super({ name: client.name });
33
- this.options = options;
34
- this.client = client;
35
- }
36
- client;
37
- get credential() {
38
- return this.client.credential;
39
- }
40
- async process(input, options) {
41
- return this.client.invoke(input, options);
42
- }
43
- }
44
- export class AIGNEHubImageModel extends ImageModel {
45
- options;
46
- static async models() {
47
- return getModels({ type: "image" });
48
- }
49
- models() {
50
- return getModels({ type: "image" });
51
- }
52
- constructor(options) {
53
- let provider = process.env.BLOCKLET_AIGNE_API_PROVIDER;
54
- if (!provider && options.model) {
55
- const parsed = parseModel(options.model);
56
- if (parsed.provider && parsed.model) {
57
- provider = parsed.provider;
58
- options.model = parsed.model;
59
- }
60
- }
61
- provider ||= AIGNEHubImageModel.name;
62
- const { match, all } = findImageModel(provider);
63
- if (!match) {
64
- const available = all.map((m) => m.name).join(", ");
65
- throw new Error(`Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
66
- }
67
- const client = match.create(options);
68
- super({ name: client.name });
69
- this.options = options;
70
- this.client = client;
71
- }
72
- client;
73
- get credential() {
74
- return this.client.credential;
75
- }
76
- async process(input, options) {
77
- return this.client.invoke(input, options);
78
- }
79
- }
80
- export class AIGNEHubVideoModel extends VideoModel {
81
- options;
82
- static async models() {
83
- return getModels({ type: "video" });
84
- }
85
- models() {
86
- return getModels({ type: "video" });
87
- }
88
- constructor(options) {
89
- let provider = process.env.BLOCKLET_AIGNE_API_PROVIDER;
90
- if (!provider && options.model) {
91
- const parsed = parseModel(options.model);
92
- if (parsed.provider && parsed.model) {
93
- provider = parsed.provider;
94
- options.model = parsed.model;
95
- }
96
- }
97
- provider ||= AIGNEHubVideoModel.name;
98
- const { match, all } = findVideoModel(provider);
99
- if (!match) {
100
- const available = all.map((m) => m.name).join(", ");
101
- throw new Error(`Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
102
- }
103
- const client = match.create(options);
104
- super({ name: client.name });
105
- this.options = options;
106
- this.client = client;
107
- }
108
- client;
109
- get credential() {
110
- return this.client.credential;
111
- }
112
- async process(input, options) {
113
- return this.client.invoke(input, options);
114
- }
115
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1 +0,0 @@
1
- export declare function getAIGNEHubMountPoint(url: string, component: string): Promise<string>;
@@ -1,12 +0,0 @@
1
- import { fetch } from "@aigne/core/utils/fetch.js";
2
- import { joinURL } from "ufo";
3
- export async function getAIGNEHubMountPoint(url, component) {
4
- const { origin } = new URL(url);
5
- const BLOCKLET_JSON_PATH = "__blocklet__.js?type=json";
6
- const blockletInfo = await fetch(joinURL(origin, BLOCKLET_JSON_PATH));
7
- const blocklet = await blockletInfo.json();
8
- const comp = (blocklet?.componentMountPoints || []).find((m) => m.did === component);
9
- if (!comp)
10
- throw new Error(`Component ${component} not found in blocklet ${url}`);
11
- return joinURL(origin, comp.mountPoint);
12
- }
@@ -1,22 +0,0 @@
1
- export declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
2
- export declare const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
3
- export declare const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
4
- export declare const AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
5
- export declare const AIGNE_HUB_VIDEO_MODEL = "openai/sora-2";
6
- export declare const AIGNE_HUB_PROVIDER = "aignehub";
7
- export declare const aigneHubBaseUrl: () => string;
8
- export declare const AI_PROVIDERS: {
9
- readonly OPENAI: "openai";
10
- readonly ANTHROPIC: "anthropic";
11
- readonly BEDROCK: "bedrock";
12
- readonly DEEPSEEK: "deepseek";
13
- readonly GOOGLE: "google";
14
- readonly OLLAMA: "ollama";
15
- readonly OPENROUTER: "openrouter";
16
- readonly XAI: "xai";
17
- readonly DOUBAO: "doubao";
18
- readonly POE: "poe";
19
- readonly IDEOGRAM: "ideogram";
20
- };
21
- export type AIProviderType = (typeof AI_PROVIDERS)[keyof typeof AI_PROVIDERS];
22
- export declare const PROVIDER_RANK: Record<AIProviderType, number>;
@@ -1,33 +0,0 @@
1
- export const AIGNE_HUB_URL = "https://hub.aigne.io/";
2
- export const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
3
- export const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
4
- export const AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
5
- export const AIGNE_HUB_VIDEO_MODEL = "openai/sora-2";
6
- export const AIGNE_HUB_PROVIDER = "aignehub";
7
- export const aigneHubBaseUrl = () => process.env.BLOCKLET_AIGNE_API_URL || process.env.AIGNE_HUB_API_URL || AIGNE_HUB_URL;
8
- export const AI_PROVIDERS = {
9
- OPENAI: "openai",
10
- ANTHROPIC: "anthropic",
11
- BEDROCK: "bedrock",
12
- DEEPSEEK: "deepseek",
13
- GOOGLE: "google",
14
- OLLAMA: "ollama",
15
- OPENROUTER: "openrouter",
16
- XAI: "xai",
17
- DOUBAO: "doubao",
18
- POE: "poe",
19
- IDEOGRAM: "ideogram",
20
- };
21
- export const PROVIDER_RANK = {
22
- openai: 1,
23
- anthropic: 1,
24
- google: 1,
25
- deepseek: 1,
26
- xai: 1,
27
- doubao: 1,
28
- ideogram: 1,
29
- bedrock: 2,
30
- openrouter: 3,
31
- poe: 3,
32
- ollama: 4,
33
- };
@@ -1,115 +0,0 @@
1
- import { PROVIDER_RANK } from "./constants.js";
2
- const MODEL_CONFIGS = [
3
- {
4
- pattern: /^gemini|^imagen|^veo/,
5
- vendor: "google",
6
- defaultProvider: "google",
7
- supportedProviders: ["google", "openrouter", "poe"],
8
- },
9
- {
10
- pattern: /^gpt-|^o[13]-|^dall-e-|^text-embedding|^sora-/,
11
- vendor: "openai",
12
- defaultProvider: "openai",
13
- supportedProviders: ["openai", "openrouter", "poe"],
14
- },
15
- {
16
- pattern: /^claude/,
17
- vendor: "anthropic",
18
- defaultProvider: "anthropic",
19
- supportedProviders: ["anthropic", "bedrock", "openrouter", "poe"],
20
- },
21
- {
22
- pattern: /^deepseek/,
23
- vendor: "deepseek",
24
- defaultProvider: "deepseek",
25
- supportedProviders: ["deepseek", "openrouter", "ollama"],
26
- },
27
- {
28
- pattern: /^grok/,
29
- vendor: "xai",
30
- defaultProvider: "xai",
31
- supportedProviders: ["xai", "openrouter", "poe"],
32
- },
33
- {
34
- pattern: /^doubao/,
35
- vendor: "doubao",
36
- defaultProvider: "doubao",
37
- supportedProviders: ["doubao"],
38
- },
39
- {
40
- pattern: /^llama/,
41
- vendor: "meta",
42
- supportedProviders: ["openrouter", "ollama", "bedrock"],
43
- },
44
- {
45
- pattern: /^mistral|^mixtral/,
46
- vendor: "mistral",
47
- supportedProviders: ["openrouter", "ollama", "bedrock"],
48
- },
49
- {
50
- pattern: /^qwen/,
51
- vendor: "qwen",
52
- supportedProviders: ["openrouter", "ollama", "bedrock"],
53
- },
54
- {
55
- pattern: /^gemma/,
56
- vendor: "google",
57
- supportedProviders: ["openrouter", "ollama", "bedrock"],
58
- },
59
- {
60
- pattern: /^yi/,
61
- vendor: "yi",
62
- supportedProviders: ["openrouter", "ollama", "bedrock"],
63
- },
64
- {
65
- pattern: /^phi/,
66
- vendor: "microsoft",
67
- supportedProviders: ["openrouter", "ollama", "bedrock"],
68
- },
69
- ];
70
- function findModelConfig(model) {
71
- if (!model)
72
- return undefined;
73
- const id = model.toLowerCase();
74
- return MODEL_CONFIGS.find((config) => config.pattern.test(id));
75
- }
76
- export function inferVendorFromModel(model) {
77
- return findModelConfig(model)?.vendor;
78
- }
79
- export function getDefaultProviderForModel(model) {
80
- const config = findModelConfig(model);
81
- if (!config)
82
- return null;
83
- return config.defaultProvider ?? (config.supportedProviders?.[0] || null);
84
- }
85
- export function getSupportedProviders(model) {
86
- const config = findModelConfig(model);
87
- if (!config?.supportedProviders)
88
- return [];
89
- return config.supportedProviders.sort((a, b) => PROVIDER_RANK[a] - PROVIDER_RANK[b]);
90
- }
91
- /**
92
- * Resolve provider-specific model ID based on platform conventions
93
- * @param provider - The provider name (e.g., 'openrouter', 'bedrock', 'google')
94
- * @param canonicalModel - The canonical model name (e.g., 'gemini-2.5-pro', 'claude-3-5-sonnet-20241022')
95
- * @param vendor - Optional vendor hint (e.g., 'google' for gemini models, 'anthropic' for claude)
96
- * @returns Provider-specific model ID
97
- *
98
- * Examples:
99
- * - OpenRouter: 'google/gemini-2.5-pro', 'openai/gpt-4o', 'anthropic/claude-3-5-sonnet'
100
- * - Bedrock: 'anthropic.claude-3-5-sonnet-20241022-v2:0', 'meta.llama3-70b-instruct-v1:0'
101
- * - Direct providers (google, openai, etc.): 'gemini-2.5-pro', 'gpt-4o'
102
- */
103
- export function resolveProviderModelId(provider, canonicalModel, vendor) {
104
- const v = vendor || inferVendorFromModel(canonicalModel);
105
- if (provider === "bedrock" && v) {
106
- if (canonicalModel.includes(".")) {
107
- return canonicalModel;
108
- }
109
- return `${v}.${canonicalModel}`;
110
- }
111
- if (provider === "openrouter" && v && !canonicalModel.startsWith(`${v}/`)) {
112
- return `${v}/${canonicalModel}`;
113
- }
114
- return canonicalModel;
115
- }
@@ -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,27 +0,0 @@
1
- import { fetch } from "@aigne/core/utils/fetch.js";
2
- import { joinURL, withQuery } from "ufo";
3
- import { z } from "zod";
4
- import { getAIGNEHubMountPoint } from "./blocklet.js";
5
- import { AIGNE_HUB_BLOCKLET_DID, aigneHubBaseUrl } from "./constants.js";
6
- const modelsSchema = z.array(z.object({
7
- model: z.string(),
8
- type: z.string(),
9
- provider: z.string(),
10
- input_credits_per_token: z.string(),
11
- output_credits_per_token: z.string(),
12
- modelMetadata: z.record(z.unknown()).nullish(),
13
- providerDisplayName: z.string(),
14
- status: z
15
- .object({
16
- available: z.boolean(),
17
- })
18
- .nullish(),
19
- }));
20
- export async function getModels(options) {
21
- const url = await getAIGNEHubMountPoint(options.baseURL || aigneHubBaseUrl(), AIGNE_HUB_BLOCKLET_DID);
22
- const response = await fetch(withQuery(joinURL(url, "/api/ai/models"), {
23
- type: options.type,
24
- }));
25
- const json = await response.json();
26
- return modelsSchema.parse(json);
27
- }
@@ -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
- };