@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.
- package/README.md +11 -11
- package/dist/aigne-hub-image-model.cjs +91 -0
- package/dist/aigne-hub-image-model.mjs +92 -0
- package/dist/aigne-hub-image-model.mjs.map +1 -0
- package/dist/aigne-hub-model.cjs +80 -0
- package/dist/aigne-hub-model.mjs +81 -0
- package/dist/aigne-hub-model.mjs.map +1 -0
- package/dist/aigne-hub-video-model.cjs +95 -0
- package/dist/aigne-hub-video-model.mjs +96 -0
- package/dist/aigne-hub-video-model.mjs.map +1 -0
- package/dist/index.cjs +139 -0
- package/dist/index.d.cts +118 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +118 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +117 -0
- package/dist/index.mjs.map +1 -0
- package/dist/utils/blocklet.cjs +13 -0
- package/dist/utils/blocklet.d.cts +5 -0
- package/dist/utils/blocklet.d.cts.map +1 -0
- package/dist/utils/blocklet.d.mts +5 -0
- package/dist/utils/blocklet.d.mts.map +1 -0
- package/dist/utils/blocklet.mjs +14 -0
- package/dist/utils/blocklet.mjs.map +1 -0
- package/dist/utils/constants.cjs +46 -0
- package/dist/utils/constants.d.cts +26 -0
- package/dist/utils/constants.d.cts.map +1 -0
- package/dist/utils/constants.d.mts +26 -0
- package/dist/utils/constants.d.mts.map +1 -0
- package/dist/utils/constants.mjs +38 -0
- package/dist/utils/constants.mjs.map +1 -0
- package/dist/utils/find-provider.cjs +161 -0
- package/{lib/cjs/utils/find-provider.d.ts → dist/utils/find-provider.d.cts} +10 -5
- package/dist/utils/find-provider.d.cts.map +1 -0
- package/{lib/esm/utils/find-provider.d.ts → dist/utils/find-provider.d.mts} +10 -5
- package/dist/utils/find-provider.d.mts.map +1 -0
- package/dist/utils/find-provider.mjs +159 -0
- package/dist/utils/find-provider.mjs.map +1 -0
- package/dist/utils/hub.cjs +24 -0
- package/dist/utils/hub.mjs +25 -0
- package/dist/utils/hub.mjs.map +1 -0
- package/dist/utils/model.cjs +260 -0
- package/dist/utils/model.d.cts +57 -0
- package/dist/utils/model.d.cts.map +1 -0
- package/dist/utils/model.d.mts +57 -0
- package/dist/utils/model.d.mts.map +1 -0
- package/dist/utils/model.mjs +255 -0
- package/dist/utils/model.mjs.map +1 -0
- package/dist/utils/type.cjs +20 -0
- package/dist/utils/type.d.cts +28 -0
- package/dist/utils/type.d.cts.map +1 -0
- package/dist/utils/type.d.mts +29 -0
- package/dist/utils/type.d.mts.map +1 -0
- package/dist/utils/type.mjs +21 -0
- package/dist/utils/type.mjs.map +1 -0
- package/package.json +40 -41
- package/CHANGELOG.md +0 -4238
- package/lib/cjs/aigne-hub-image-model.d.ts +0 -28
- package/lib/cjs/aigne-hub-image-model.js +0 -90
- package/lib/cjs/aigne-hub-model.d.ts +0 -28
- package/lib/cjs/aigne-hub-model.js +0 -80
- package/lib/cjs/aigne-hub-video-model.d.ts +0 -28
- package/lib/cjs/aigne-hub-video-model.js +0 -89
- package/lib/cjs/index.d.ts +0 -112
- package/lib/cjs/index.js +0 -135
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/utils/blocklet.d.ts +0 -1
- package/lib/cjs/utils/blocklet.js +0 -15
- package/lib/cjs/utils/constants.d.ts +0 -22
- package/lib/cjs/utils/constants.js +0 -37
- package/lib/cjs/utils/find-provider.js +0 -121
- package/lib/cjs/utils/hub.d.ts +0 -16
- package/lib/cjs/utils/hub.js +0 -30
- package/lib/cjs/utils/model.d.ts +0 -52
- package/lib/cjs/utils/model.js +0 -207
- package/lib/cjs/utils/type.d.ts +0 -78
- package/lib/cjs/utils/type.js +0 -20
- package/lib/dts/aigne-hub-image-model.d.ts +0 -28
- package/lib/dts/aigne-hub-model.d.ts +0 -28
- package/lib/dts/aigne-hub-video-model.d.ts +0 -28
- package/lib/dts/index.d.ts +0 -112
- package/lib/dts/utils/blocklet.d.ts +0 -1
- package/lib/dts/utils/constants.d.ts +0 -22
- package/lib/dts/utils/find-provider.d.ts +0 -17
- package/lib/dts/utils/hub.d.ts +0 -16
- package/lib/dts/utils/model.d.ts +0 -52
- package/lib/dts/utils/type.d.ts +0 -78
- package/lib/esm/aigne-hub-image-model.d.ts +0 -28
- package/lib/esm/aigne-hub-image-model.js +0 -86
- package/lib/esm/aigne-hub-model.d.ts +0 -28
- package/lib/esm/aigne-hub-model.js +0 -76
- package/lib/esm/aigne-hub-video-model.d.ts +0 -28
- package/lib/esm/aigne-hub-video-model.js +0 -85
- package/lib/esm/index.d.ts +0 -112
- package/lib/esm/index.js +0 -115
- package/lib/esm/package.json +0 -3
- package/lib/esm/utils/blocklet.d.ts +0 -1
- package/lib/esm/utils/blocklet.js +0 -12
- package/lib/esm/utils/constants.d.ts +0 -22
- package/lib/esm/utils/constants.js +0 -33
- package/lib/esm/utils/find-provider.js +0 -115
- package/lib/esm/utils/hub.d.ts +0 -16
- package/lib/esm/utils/hub.js +0 -27
- package/lib/esm/utils/model.d.ts +0 -52
- package/lib/esm/utils/model.js +0 -197
- package/lib/esm/utils/type.d.ts +0 -78
- package/lib/esm/utils/type.js +0 -17
package/lib/dts/index.d.ts
DELETED
|
@@ -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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getAIGNEHubMountPoint(url: string, component: string): Promise<string>;
|
|
@@ -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,17 +0,0 @@
|
|
|
1
|
-
import type { AIProviderType } from "./constants.js";
|
|
2
|
-
export declare function inferVendorFromModel(model: string): string | undefined;
|
|
3
|
-
export declare function getDefaultProviderForModel(model: string): AIProviderType | null;
|
|
4
|
-
export declare function getSupportedProviders(model: string): AIProviderType[];
|
|
5
|
-
/**
|
|
6
|
-
* Resolve provider-specific model ID based on platform conventions
|
|
7
|
-
* @param provider - The provider name (e.g., 'openrouter', 'bedrock', 'google')
|
|
8
|
-
* @param canonicalModel - The canonical model name (e.g., 'gemini-2.5-pro', 'claude-3-5-sonnet-20241022')
|
|
9
|
-
* @param vendor - Optional vendor hint (e.g., 'google' for gemini models, 'anthropic' for claude)
|
|
10
|
-
* @returns Provider-specific model ID
|
|
11
|
-
*
|
|
12
|
-
* Examples:
|
|
13
|
-
* - OpenRouter: 'google/gemini-2.5-pro', 'openai/gpt-4o', 'anthropic/claude-3-5-sonnet'
|
|
14
|
-
* - Bedrock: 'anthropic.claude-3-5-sonnet-20241022-v2:0', 'meta.llama3-70b-instruct-v1:0'
|
|
15
|
-
* - Direct providers (google, openai, etc.): 'gemini-2.5-pro', 'gpt-4o'
|
|
16
|
-
*/
|
|
17
|
-
export declare function resolveProviderModelId(provider: AIProviderType, canonicalModel: string, vendor?: string): string;
|
package/lib/dts/utils/hub.d.ts
DELETED
|
@@ -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
|
-
}[]>;
|
package/lib/dts/utils/model.d.ts
DELETED
|
@@ -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
|
-
};
|
package/lib/dts/utils/type.d.ts
DELETED
|
@@ -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,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,86 +0,0 @@
|
|
|
1
|
-
import { ImageModel, } from "@aigne/core";
|
|
2
|
-
import { checkArguments } from "@aigne/core/utils/type-utils.js";
|
|
3
|
-
import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
|
|
4
|
-
import { BaseClient, } from "@aigne/transport/http-client/base-client.js";
|
|
5
|
-
import { joinURL } from "ufo";
|
|
6
|
-
import { getAIGNEHubMountPoint } from "./utils/blocklet.js";
|
|
7
|
-
import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_IMAGE_MODEL, aigneHubBaseUrl, } from "./utils/constants.js";
|
|
8
|
-
import { getModels } from "./utils/hub.js";
|
|
9
|
-
import { aigneHubModelOptionsSchema } from "./utils/type.js";
|
|
10
|
-
export class AIGNEHubImageModel extends ImageModel {
|
|
11
|
-
options;
|
|
12
|
-
constructor(options) {
|
|
13
|
-
checkArguments("AIGNEHubImageModel", aigneHubModelOptionsSchema, options);
|
|
14
|
-
super();
|
|
15
|
-
this.options = options;
|
|
16
|
-
}
|
|
17
|
-
async models() {
|
|
18
|
-
return getModels({ baseURL: (await this.credential).url, type: "image" });
|
|
19
|
-
}
|
|
20
|
-
_client;
|
|
21
|
-
get client() {
|
|
22
|
-
this._client ??= this.credential.then(({ url, apiKey, model }) => {
|
|
23
|
-
const options = { ...this.options, url, apiKey, model };
|
|
24
|
-
return new BaseClient(options);
|
|
25
|
-
});
|
|
26
|
-
return this._client;
|
|
27
|
-
}
|
|
28
|
-
_credential;
|
|
29
|
-
get credential() {
|
|
30
|
-
this._credential ??= getAIGNEHubMountPoint(this.options.baseURL || aigneHubBaseUrl(), AIGNE_HUB_BLOCKLET_DID).then((url) => {
|
|
31
|
-
const path = "/api/v2/image";
|
|
32
|
-
const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
|
|
33
|
-
let credentialOptions = {};
|
|
34
|
-
try {
|
|
35
|
-
credentialOptions =
|
|
36
|
-
typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
console.error(err);
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
...credentialOptions,
|
|
43
|
-
url: url.endsWith(path) ? url : joinURL(url, path),
|
|
44
|
-
apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY || credentialOptions.apiKey,
|
|
45
|
-
model: this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL || AIGNE_HUB_IMAGE_MODEL,
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
return this._credential;
|
|
49
|
-
}
|
|
50
|
-
async process(input, options) {
|
|
51
|
-
const { BLOCKLET_APP_PID, ABT_NODE_DID } = nodejs.env;
|
|
52
|
-
const clientId = this.options?.clientOptions?.clientId ||
|
|
53
|
-
BLOCKLET_APP_PID ||
|
|
54
|
-
ABT_NODE_DID ||
|
|
55
|
-
`@aigne/aigne-hub:${typeof process !== "undefined" ? nodejs.os.hostname() : "unknown"}`;
|
|
56
|
-
const response = await (await this.client).__invoke(undefined, {
|
|
57
|
-
...input,
|
|
58
|
-
modelOptions: {
|
|
59
|
-
...input.modelOptions,
|
|
60
|
-
model: input.modelOptions?.model || (await this.credential).model,
|
|
61
|
-
},
|
|
62
|
-
// Shouldn't use `local` output type for remote AIGNE Hub call, client can not access the remote filesystem
|
|
63
|
-
outputFileType: "url",
|
|
64
|
-
}, {
|
|
65
|
-
...options,
|
|
66
|
-
streaming: false,
|
|
67
|
-
fetchOptions: {
|
|
68
|
-
...options.fetchOptions,
|
|
69
|
-
headers: {
|
|
70
|
-
...options.fetchOptions?.headers,
|
|
71
|
-
"x-aigne-hub-client-did": clientId,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
return {
|
|
76
|
-
...response,
|
|
77
|
-
images: response.images,
|
|
78
|
-
usage: {
|
|
79
|
-
inputTokens: response.usage?.inputTokens ?? 0,
|
|
80
|
-
outputTokens: response.usage?.outputTokens ?? 0,
|
|
81
|
-
...response.usage,
|
|
82
|
-
},
|
|
83
|
-
model: response?.model,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -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,76 +0,0 @@
|
|
|
1
|
-
import { ChatModel, } from "@aigne/core";
|
|
2
|
-
import { checkArguments } from "@aigne/core/utils/type-utils.js";
|
|
3
|
-
import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
|
|
4
|
-
import { BaseClient, } from "@aigne/transport/http-client/base-client.js";
|
|
5
|
-
import { joinURL } from "ufo";
|
|
6
|
-
import { getAIGNEHubMountPoint } from "./utils/blocklet.js";
|
|
7
|
-
import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_DEFAULT_MODEL, aigneHubBaseUrl, } from "./utils/constants.js";
|
|
8
|
-
import { getModels } from "./utils/hub.js";
|
|
9
|
-
import { aigneHubModelOptionsSchema } from "./utils/type.js";
|
|
10
|
-
export class AIGNEHubChatModel extends ChatModel {
|
|
11
|
-
options;
|
|
12
|
-
constructor(options) {
|
|
13
|
-
checkArguments("AIGNEHubChatModel", aigneHubModelOptionsSchema, options);
|
|
14
|
-
super();
|
|
15
|
-
this.options = options;
|
|
16
|
-
}
|
|
17
|
-
async models() {
|
|
18
|
-
return getModels({ baseURL: (await this.credential).url, type: "chat" });
|
|
19
|
-
}
|
|
20
|
-
_client;
|
|
21
|
-
get client() {
|
|
22
|
-
this._client ??= this.credential.then(({ url, apiKey, model }) => {
|
|
23
|
-
const options = { ...this.options, url, apiKey, model };
|
|
24
|
-
return new BaseClient(options);
|
|
25
|
-
});
|
|
26
|
-
return this._client;
|
|
27
|
-
}
|
|
28
|
-
_credential;
|
|
29
|
-
get credential() {
|
|
30
|
-
this._credential ??= getAIGNEHubMountPoint(this.options.baseURL || aigneHubBaseUrl(), AIGNE_HUB_BLOCKLET_DID).then((url) => {
|
|
31
|
-
const path = "/api/v2/chat";
|
|
32
|
-
const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
|
|
33
|
-
let credentialOptions = {};
|
|
34
|
-
try {
|
|
35
|
-
credentialOptions =
|
|
36
|
-
typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
console.error(err);
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
...credentialOptions,
|
|
43
|
-
url: url.endsWith(path) ? url : joinURL(url, path),
|
|
44
|
-
apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY || credentialOptions.apiKey,
|
|
45
|
-
model: this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL || AIGNE_HUB_DEFAULT_MODEL,
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
return this._credential;
|
|
49
|
-
}
|
|
50
|
-
async process(input, options) {
|
|
51
|
-
const { BLOCKLET_APP_PID, ABT_NODE_DID } = nodejs.env;
|
|
52
|
-
const clientId = this.options?.clientOptions?.clientId ||
|
|
53
|
-
BLOCKLET_APP_PID ||
|
|
54
|
-
ABT_NODE_DID ||
|
|
55
|
-
`@aigne/aigne-hub:${typeof process !== "undefined" ? nodejs.os.hostname() : "unknown"}`;
|
|
56
|
-
const response = await (await this.client).__invoke(undefined, {
|
|
57
|
-
...input,
|
|
58
|
-
modelOptions: {
|
|
59
|
-
...input.modelOptions,
|
|
60
|
-
model: input.modelOptions?.model || (await this.credential).model,
|
|
61
|
-
},
|
|
62
|
-
// Shouldn't use `local` output type for remote AIGNE Hub call, client can not access the remote filesystem
|
|
63
|
-
outputFileType: "url",
|
|
64
|
-
}, {
|
|
65
|
-
...options,
|
|
66
|
-
fetchOptions: {
|
|
67
|
-
...options.fetchOptions,
|
|
68
|
-
headers: {
|
|
69
|
-
...options.fetchOptions?.headers,
|
|
70
|
-
"x-aigne-hub-client-did": clientId,
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
return response;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -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
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { VideoModel, } from "@aigne/core";
|
|
2
|
-
import { checkArguments } from "@aigne/core/utils/type-utils.js";
|
|
3
|
-
import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
|
|
4
|
-
import { BaseClient, } from "@aigne/transport/http-client/base-client.js";
|
|
5
|
-
import { joinURL } from "ufo";
|
|
6
|
-
import { getAIGNEHubMountPoint } from "./utils/blocklet.js";
|
|
7
|
-
import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_VIDEO_MODEL, aigneHubBaseUrl, } from "./utils/constants.js";
|
|
8
|
-
import { getModels } from "./utils/hub.js";
|
|
9
|
-
import { aigneHubModelOptionsSchema } from "./utils/type.js";
|
|
10
|
-
export class AIGNEHubVideoModel extends VideoModel {
|
|
11
|
-
options;
|
|
12
|
-
constructor(options) {
|
|
13
|
-
checkArguments("AIGNEHubVideoModel", aigneHubModelOptionsSchema, options);
|
|
14
|
-
super();
|
|
15
|
-
this.options = options;
|
|
16
|
-
}
|
|
17
|
-
async models() {
|
|
18
|
-
return getModels({ baseURL: (await this.credential).url, type: "video" });
|
|
19
|
-
}
|
|
20
|
-
_client;
|
|
21
|
-
get client() {
|
|
22
|
-
this._client ??= this.credential.then(({ url, apiKey, model }) => {
|
|
23
|
-
const options = { ...this.options, url, apiKey, model };
|
|
24
|
-
return new BaseClient(options);
|
|
25
|
-
});
|
|
26
|
-
return this._client;
|
|
27
|
-
}
|
|
28
|
-
_credential;
|
|
29
|
-
get credential() {
|
|
30
|
-
this._credential ??= getAIGNEHubMountPoint(this.options.baseURL || aigneHubBaseUrl(), AIGNE_HUB_BLOCKLET_DID).then((url) => {
|
|
31
|
-
const path = "/api/v2/video";
|
|
32
|
-
const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
|
|
33
|
-
let credentialOptions = {};
|
|
34
|
-
try {
|
|
35
|
-
credentialOptions =
|
|
36
|
-
typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
console.error(err);
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
...credentialOptions,
|
|
43
|
-
url: url.endsWith(path) ? url : joinURL(url, path),
|
|
44
|
-
apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY || credentialOptions.apiKey,
|
|
45
|
-
model: this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL || AIGNE_HUB_VIDEO_MODEL,
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
return this._credential;
|
|
49
|
-
}
|
|
50
|
-
async process(input, options) {
|
|
51
|
-
const { BLOCKLET_APP_PID, ABT_NODE_DID } = nodejs.env;
|
|
52
|
-
const clientId = this.options?.clientOptions?.clientId ||
|
|
53
|
-
BLOCKLET_APP_PID ||
|
|
54
|
-
ABT_NODE_DID ||
|
|
55
|
-
`@aigne/aigne-hub:${typeof process !== "undefined" ? nodejs.os.hostname() : "unknown"}`;
|
|
56
|
-
const model = input.model || input.modelOptions?.model || (await this.credential).model;
|
|
57
|
-
const response = await (await this.client).__invoke(undefined, {
|
|
58
|
-
...input,
|
|
59
|
-
model: model,
|
|
60
|
-
modelOptions: { ...this.options.modelOptions, ...input.modelOptions, model: model },
|
|
61
|
-
outputFileType: "url",
|
|
62
|
-
}, {
|
|
63
|
-
...options,
|
|
64
|
-
streaming: false,
|
|
65
|
-
fetchOptions: {
|
|
66
|
-
...options.fetchOptions,
|
|
67
|
-
timeout: 60e3 * 3,
|
|
68
|
-
headers: {
|
|
69
|
-
...options.fetchOptions?.headers,
|
|
70
|
-
"x-aigne-hub-client-did": clientId,
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
return {
|
|
75
|
-
...response,
|
|
76
|
-
videos: response.videos,
|
|
77
|
-
usage: {
|
|
78
|
-
inputTokens: response.usage?.inputTokens ?? 0,
|
|
79
|
-
outputTokens: response.usage?.outputTokens ?? 0,
|
|
80
|
-
...response.usage,
|
|
81
|
-
},
|
|
82
|
-
model: response?.model,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|