@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
|
@@ -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,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AIGNEHubImageModel = void 0;
|
|
4
|
-
const core_1 = require("@aigne/core");
|
|
5
|
-
const type_utils_js_1 = require("@aigne/core/utils/type-utils.js");
|
|
6
|
-
const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
|
|
7
|
-
const base_client_js_1 = require("@aigne/transport/http-client/base-client.js");
|
|
8
|
-
const ufo_1 = require("ufo");
|
|
9
|
-
const blocklet_js_1 = require("./utils/blocklet.js");
|
|
10
|
-
const constants_js_1 = require("./utils/constants.js");
|
|
11
|
-
const hub_js_1 = require("./utils/hub.js");
|
|
12
|
-
const type_js_1 = require("./utils/type.js");
|
|
13
|
-
class AIGNEHubImageModel extends core_1.ImageModel {
|
|
14
|
-
options;
|
|
15
|
-
constructor(options) {
|
|
16
|
-
(0, type_utils_js_1.checkArguments)("AIGNEHubImageModel", type_js_1.aigneHubModelOptionsSchema, options);
|
|
17
|
-
super();
|
|
18
|
-
this.options = options;
|
|
19
|
-
}
|
|
20
|
-
async models() {
|
|
21
|
-
return (0, hub_js_1.getModels)({ baseURL: (await this.credential).url, type: "image" });
|
|
22
|
-
}
|
|
23
|
-
_client;
|
|
24
|
-
get client() {
|
|
25
|
-
this._client ??= this.credential.then(({ url, apiKey, model }) => {
|
|
26
|
-
const options = { ...this.options, url, apiKey, model };
|
|
27
|
-
return new base_client_js_1.BaseClient(options);
|
|
28
|
-
});
|
|
29
|
-
return this._client;
|
|
30
|
-
}
|
|
31
|
-
_credential;
|
|
32
|
-
get credential() {
|
|
33
|
-
this._credential ??= (0, blocklet_js_1.getAIGNEHubMountPoint)(this.options.baseURL || (0, constants_js_1.aigneHubBaseUrl)(), constants_js_1.AIGNE_HUB_BLOCKLET_DID).then((url) => {
|
|
34
|
-
const path = "/api/v2/image";
|
|
35
|
-
const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
|
|
36
|
-
let credentialOptions = {};
|
|
37
|
-
try {
|
|
38
|
-
credentialOptions =
|
|
39
|
-
typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
console.error(err);
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
...credentialOptions,
|
|
46
|
-
url: url.endsWith(path) ? url : (0, ufo_1.joinURL)(url, path),
|
|
47
|
-
apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY || credentialOptions.apiKey,
|
|
48
|
-
model: this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL || constants_js_1.AIGNE_HUB_IMAGE_MODEL,
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
return this._credential;
|
|
52
|
-
}
|
|
53
|
-
async process(input, options) {
|
|
54
|
-
const { BLOCKLET_APP_PID, ABT_NODE_DID } = index_js_1.nodejs.env;
|
|
55
|
-
const clientId = this.options?.clientOptions?.clientId ||
|
|
56
|
-
BLOCKLET_APP_PID ||
|
|
57
|
-
ABT_NODE_DID ||
|
|
58
|
-
`@aigne/aigne-hub:${typeof process !== "undefined" ? index_js_1.nodejs.os.hostname() : "unknown"}`;
|
|
59
|
-
const response = await (await this.client).__invoke(undefined, {
|
|
60
|
-
...input,
|
|
61
|
-
modelOptions: {
|
|
62
|
-
...input.modelOptions,
|
|
63
|
-
model: input.modelOptions?.model || (await this.credential).model,
|
|
64
|
-
},
|
|
65
|
-
// Shouldn't use `local` output type for remote AIGNE Hub call, client can not access the remote filesystem
|
|
66
|
-
outputFileType: "url",
|
|
67
|
-
}, {
|
|
68
|
-
...options,
|
|
69
|
-
streaming: false,
|
|
70
|
-
fetchOptions: {
|
|
71
|
-
...options.fetchOptions,
|
|
72
|
-
headers: {
|
|
73
|
-
...options.fetchOptions?.headers,
|
|
74
|
-
"x-aigne-hub-client-did": clientId,
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
return {
|
|
79
|
-
...response,
|
|
80
|
-
images: response.images,
|
|
81
|
-
usage: {
|
|
82
|
-
inputTokens: response.usage?.inputTokens ?? 0,
|
|
83
|
-
outputTokens: response.usage?.outputTokens ?? 0,
|
|
84
|
-
...response.usage,
|
|
85
|
-
},
|
|
86
|
-
model: response?.model,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.AIGNEHubImageModel = AIGNEHubImageModel;
|
|
@@ -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,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AIGNEHubChatModel = void 0;
|
|
4
|
-
const core_1 = require("@aigne/core");
|
|
5
|
-
const type_utils_js_1 = require("@aigne/core/utils/type-utils.js");
|
|
6
|
-
const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
|
|
7
|
-
const base_client_js_1 = require("@aigne/transport/http-client/base-client.js");
|
|
8
|
-
const ufo_1 = require("ufo");
|
|
9
|
-
const blocklet_js_1 = require("./utils/blocklet.js");
|
|
10
|
-
const constants_js_1 = require("./utils/constants.js");
|
|
11
|
-
const hub_js_1 = require("./utils/hub.js");
|
|
12
|
-
const type_js_1 = require("./utils/type.js");
|
|
13
|
-
class AIGNEHubChatModel extends core_1.ChatModel {
|
|
14
|
-
options;
|
|
15
|
-
constructor(options) {
|
|
16
|
-
(0, type_utils_js_1.checkArguments)("AIGNEHubChatModel", type_js_1.aigneHubModelOptionsSchema, options);
|
|
17
|
-
super();
|
|
18
|
-
this.options = options;
|
|
19
|
-
}
|
|
20
|
-
async models() {
|
|
21
|
-
return (0, hub_js_1.getModels)({ baseURL: (await this.credential).url, type: "chat" });
|
|
22
|
-
}
|
|
23
|
-
_client;
|
|
24
|
-
get client() {
|
|
25
|
-
this._client ??= this.credential.then(({ url, apiKey, model }) => {
|
|
26
|
-
const options = { ...this.options, url, apiKey, model };
|
|
27
|
-
return new base_client_js_1.BaseClient(options);
|
|
28
|
-
});
|
|
29
|
-
return this._client;
|
|
30
|
-
}
|
|
31
|
-
_credential;
|
|
32
|
-
get credential() {
|
|
33
|
-
this._credential ??= (0, blocklet_js_1.getAIGNEHubMountPoint)(this.options.baseURL || (0, constants_js_1.aigneHubBaseUrl)(), constants_js_1.AIGNE_HUB_BLOCKLET_DID).then((url) => {
|
|
34
|
-
const path = "/api/v2/chat";
|
|
35
|
-
const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
|
|
36
|
-
let credentialOptions = {};
|
|
37
|
-
try {
|
|
38
|
-
credentialOptions =
|
|
39
|
-
typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
console.error(err);
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
...credentialOptions,
|
|
46
|
-
url: url.endsWith(path) ? url : (0, ufo_1.joinURL)(url, path),
|
|
47
|
-
apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY || credentialOptions.apiKey,
|
|
48
|
-
model: this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL || constants_js_1.AIGNE_HUB_DEFAULT_MODEL,
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
return this._credential;
|
|
52
|
-
}
|
|
53
|
-
async process(input, options) {
|
|
54
|
-
const { BLOCKLET_APP_PID, ABT_NODE_DID } = index_js_1.nodejs.env;
|
|
55
|
-
const clientId = this.options?.clientOptions?.clientId ||
|
|
56
|
-
BLOCKLET_APP_PID ||
|
|
57
|
-
ABT_NODE_DID ||
|
|
58
|
-
`@aigne/aigne-hub:${typeof process !== "undefined" ? index_js_1.nodejs.os.hostname() : "unknown"}`;
|
|
59
|
-
const response = await (await this.client).__invoke(undefined, {
|
|
60
|
-
...input,
|
|
61
|
-
modelOptions: {
|
|
62
|
-
...input.modelOptions,
|
|
63
|
-
model: input.modelOptions?.model || (await this.credential).model,
|
|
64
|
-
},
|
|
65
|
-
// Shouldn't use `local` output type for remote AIGNE Hub call, client can not access the remote filesystem
|
|
66
|
-
outputFileType: "url",
|
|
67
|
-
}, {
|
|
68
|
-
...options,
|
|
69
|
-
fetchOptions: {
|
|
70
|
-
...options.fetchOptions,
|
|
71
|
-
headers: {
|
|
72
|
-
...options.fetchOptions?.headers,
|
|
73
|
-
"x-aigne-hub-client-did": clientId,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
return response;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.AIGNEHubChatModel = AIGNEHubChatModel;
|
|
@@ -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,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AIGNEHubVideoModel = void 0;
|
|
4
|
-
const core_1 = require("@aigne/core");
|
|
5
|
-
const type_utils_js_1 = require("@aigne/core/utils/type-utils.js");
|
|
6
|
-
const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
|
|
7
|
-
const base_client_js_1 = require("@aigne/transport/http-client/base-client.js");
|
|
8
|
-
const ufo_1 = require("ufo");
|
|
9
|
-
const blocklet_js_1 = require("./utils/blocklet.js");
|
|
10
|
-
const constants_js_1 = require("./utils/constants.js");
|
|
11
|
-
const hub_js_1 = require("./utils/hub.js");
|
|
12
|
-
const type_js_1 = require("./utils/type.js");
|
|
13
|
-
class AIGNEHubVideoModel extends core_1.VideoModel {
|
|
14
|
-
options;
|
|
15
|
-
constructor(options) {
|
|
16
|
-
(0, type_utils_js_1.checkArguments)("AIGNEHubVideoModel", type_js_1.aigneHubModelOptionsSchema, options);
|
|
17
|
-
super();
|
|
18
|
-
this.options = options;
|
|
19
|
-
}
|
|
20
|
-
async models() {
|
|
21
|
-
return (0, hub_js_1.getModels)({ baseURL: (await this.credential).url, type: "video" });
|
|
22
|
-
}
|
|
23
|
-
_client;
|
|
24
|
-
get client() {
|
|
25
|
-
this._client ??= this.credential.then(({ url, apiKey, model }) => {
|
|
26
|
-
const options = { ...this.options, url, apiKey, model };
|
|
27
|
-
return new base_client_js_1.BaseClient(options);
|
|
28
|
-
});
|
|
29
|
-
return this._client;
|
|
30
|
-
}
|
|
31
|
-
_credential;
|
|
32
|
-
get credential() {
|
|
33
|
-
this._credential ??= (0, blocklet_js_1.getAIGNEHubMountPoint)(this.options.baseURL || (0, constants_js_1.aigneHubBaseUrl)(), constants_js_1.AIGNE_HUB_BLOCKLET_DID).then((url) => {
|
|
34
|
-
const path = "/api/v2/video";
|
|
35
|
-
const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
|
|
36
|
-
let credentialOptions = {};
|
|
37
|
-
try {
|
|
38
|
-
credentialOptions =
|
|
39
|
-
typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
console.error(err);
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
...credentialOptions,
|
|
46
|
-
url: url.endsWith(path) ? url : (0, ufo_1.joinURL)(url, path),
|
|
47
|
-
apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY || credentialOptions.apiKey,
|
|
48
|
-
model: this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL || constants_js_1.AIGNE_HUB_VIDEO_MODEL,
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
return this._credential;
|
|
52
|
-
}
|
|
53
|
-
async process(input, options) {
|
|
54
|
-
const { BLOCKLET_APP_PID, ABT_NODE_DID } = index_js_1.nodejs.env;
|
|
55
|
-
const clientId = this.options?.clientOptions?.clientId ||
|
|
56
|
-
BLOCKLET_APP_PID ||
|
|
57
|
-
ABT_NODE_DID ||
|
|
58
|
-
`@aigne/aigne-hub:${typeof process !== "undefined" ? index_js_1.nodejs.os.hostname() : "unknown"}`;
|
|
59
|
-
const model = input.model || input.modelOptions?.model || (await this.credential).model;
|
|
60
|
-
const response = await (await this.client).__invoke(undefined, {
|
|
61
|
-
...input,
|
|
62
|
-
model: model,
|
|
63
|
-
modelOptions: { ...this.options.modelOptions, ...input.modelOptions, model: model },
|
|
64
|
-
outputFileType: "url",
|
|
65
|
-
}, {
|
|
66
|
-
...options,
|
|
67
|
-
streaming: false,
|
|
68
|
-
fetchOptions: {
|
|
69
|
-
...options.fetchOptions,
|
|
70
|
-
timeout: 60e3 * 3,
|
|
71
|
-
headers: {
|
|
72
|
-
...options.fetchOptions?.headers,
|
|
73
|
-
"x-aigne-hub-client-did": clientId,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
return {
|
|
78
|
-
...response,
|
|
79
|
-
videos: response.videos,
|
|
80
|
-
usage: {
|
|
81
|
-
inputTokens: response.usage?.inputTokens ?? 0,
|
|
82
|
-
outputTokens: response.usage?.outputTokens ?? 0,
|
|
83
|
-
...response.usage,
|
|
84
|
-
},
|
|
85
|
-
model: response?.model,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.AIGNEHubVideoModel = AIGNEHubVideoModel;
|
package/lib/cjs/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
|
-
}
|
package/lib/cjs/index.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.AIGNEHubVideoModel = exports.AIGNEHubImageModel = exports.AIGNEHubChatModel = void 0;
|
|
18
|
-
const core_1 = require("@aigne/core");
|
|
19
|
-
const hub_js_1 = require("./utils/hub.js");
|
|
20
|
-
const model_js_1 = require("./utils/model.js");
|
|
21
|
-
__exportStar(require("./utils/blocklet.js"), exports);
|
|
22
|
-
__exportStar(require("./utils/constants.js"), exports);
|
|
23
|
-
__exportStar(require("./utils/find-provider.js"), exports);
|
|
24
|
-
__exportStar(require("./utils/model.js"), exports);
|
|
25
|
-
class AIGNEHubChatModel extends core_1.ChatModel {
|
|
26
|
-
options;
|
|
27
|
-
static async models() {
|
|
28
|
-
return (0, hub_js_1.getModels)({ type: "chat" });
|
|
29
|
-
}
|
|
30
|
-
models() {
|
|
31
|
-
return (0, hub_js_1.getModels)({ type: "chat" });
|
|
32
|
-
}
|
|
33
|
-
constructor(options) {
|
|
34
|
-
let provider = process.env.BLOCKLET_AIGNE_API_PROVIDER;
|
|
35
|
-
if (!provider && options.model) {
|
|
36
|
-
const parsed = (0, model_js_1.parseModel)(options.model);
|
|
37
|
-
if (parsed.provider && parsed.model) {
|
|
38
|
-
provider = parsed.provider;
|
|
39
|
-
options.model = parsed.model;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
provider ||= AIGNEHubChatModel.name;
|
|
43
|
-
const { match, all } = (0, model_js_1.findModel)(provider);
|
|
44
|
-
if (!match) {
|
|
45
|
-
const available = all.map((m) => m.name).join(", ");
|
|
46
|
-
throw new Error(`Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
|
|
47
|
-
}
|
|
48
|
-
const client = match.create(options);
|
|
49
|
-
super({ name: client.name });
|
|
50
|
-
this.options = options;
|
|
51
|
-
this.client = client;
|
|
52
|
-
}
|
|
53
|
-
client;
|
|
54
|
-
get credential() {
|
|
55
|
-
return this.client.credential;
|
|
56
|
-
}
|
|
57
|
-
async process(input, options) {
|
|
58
|
-
return this.client.invoke(input, options);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.AIGNEHubChatModel = AIGNEHubChatModel;
|
|
62
|
-
class AIGNEHubImageModel extends core_1.ImageModel {
|
|
63
|
-
options;
|
|
64
|
-
static async models() {
|
|
65
|
-
return (0, hub_js_1.getModels)({ type: "image" });
|
|
66
|
-
}
|
|
67
|
-
models() {
|
|
68
|
-
return (0, hub_js_1.getModels)({ type: "image" });
|
|
69
|
-
}
|
|
70
|
-
constructor(options) {
|
|
71
|
-
let provider = process.env.BLOCKLET_AIGNE_API_PROVIDER;
|
|
72
|
-
if (!provider && options.model) {
|
|
73
|
-
const parsed = (0, model_js_1.parseModel)(options.model);
|
|
74
|
-
if (parsed.provider && parsed.model) {
|
|
75
|
-
provider = parsed.provider;
|
|
76
|
-
options.model = parsed.model;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
provider ||= AIGNEHubImageModel.name;
|
|
80
|
-
const { match, all } = (0, model_js_1.findImageModel)(provider);
|
|
81
|
-
if (!match) {
|
|
82
|
-
const available = all.map((m) => m.name).join(", ");
|
|
83
|
-
throw new Error(`Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
|
|
84
|
-
}
|
|
85
|
-
const client = match.create(options);
|
|
86
|
-
super({ name: client.name });
|
|
87
|
-
this.options = options;
|
|
88
|
-
this.client = client;
|
|
89
|
-
}
|
|
90
|
-
client;
|
|
91
|
-
get credential() {
|
|
92
|
-
return this.client.credential;
|
|
93
|
-
}
|
|
94
|
-
async process(input, options) {
|
|
95
|
-
return this.client.invoke(input, options);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
exports.AIGNEHubImageModel = AIGNEHubImageModel;
|
|
99
|
-
class AIGNEHubVideoModel extends core_1.VideoModel {
|
|
100
|
-
options;
|
|
101
|
-
static async models() {
|
|
102
|
-
return (0, hub_js_1.getModels)({ type: "video" });
|
|
103
|
-
}
|
|
104
|
-
models() {
|
|
105
|
-
return (0, hub_js_1.getModels)({ type: "video" });
|
|
106
|
-
}
|
|
107
|
-
constructor(options) {
|
|
108
|
-
let provider = process.env.BLOCKLET_AIGNE_API_PROVIDER;
|
|
109
|
-
if (!provider && options.model) {
|
|
110
|
-
const parsed = (0, model_js_1.parseModel)(options.model);
|
|
111
|
-
if (parsed.provider && parsed.model) {
|
|
112
|
-
provider = parsed.provider;
|
|
113
|
-
options.model = parsed.model;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
provider ||= AIGNEHubVideoModel.name;
|
|
117
|
-
const { match, all } = (0, model_js_1.findVideoModel)(provider);
|
|
118
|
-
if (!match) {
|
|
119
|
-
const available = all.map((m) => m.name).join(", ");
|
|
120
|
-
throw new Error(`Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
|
|
121
|
-
}
|
|
122
|
-
const client = match.create(options);
|
|
123
|
-
super({ name: client.name });
|
|
124
|
-
this.options = options;
|
|
125
|
-
this.client = client;
|
|
126
|
-
}
|
|
127
|
-
client;
|
|
128
|
-
get credential() {
|
|
129
|
-
return this.client.credential;
|
|
130
|
-
}
|
|
131
|
-
async process(input, options) {
|
|
132
|
-
return this.client.invoke(input, options);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
exports.AIGNEHubVideoModel = AIGNEHubVideoModel;
|
package/lib/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getAIGNEHubMountPoint(url: string, component: string): Promise<string>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAIGNEHubMountPoint = getAIGNEHubMountPoint;
|
|
4
|
-
const fetch_js_1 = require("@aigne/core/utils/fetch.js");
|
|
5
|
-
const ufo_1 = require("ufo");
|
|
6
|
-
async function getAIGNEHubMountPoint(url, component) {
|
|
7
|
-
const { origin } = new URL(url);
|
|
8
|
-
const BLOCKLET_JSON_PATH = "__blocklet__.js?type=json";
|
|
9
|
-
const blockletInfo = await (0, fetch_js_1.fetch)((0, ufo_1.joinURL)(origin, BLOCKLET_JSON_PATH));
|
|
10
|
-
const blocklet = await blockletInfo.json();
|
|
11
|
-
const comp = (blocklet?.componentMountPoints || []).find((m) => m.did === component);
|
|
12
|
-
if (!comp)
|
|
13
|
-
throw new Error(`Component ${component} not found in blocklet ${url}`);
|
|
14
|
-
return (0, ufo_1.joinURL)(origin, comp.mountPoint);
|
|
15
|
-
}
|
|
@@ -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>;
|