@aigne/aigne-hub 0.10.4-beta.1 → 0.10.4-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/lib/cjs/aigne-hub-video-model.d.ts +28 -0
- package/lib/cjs/aigne-hub-video-model.js +84 -0
- package/lib/cjs/index.d.ts +38 -2
- package/lib/cjs/index.js +41 -1
- package/lib/cjs/utils/constants.d.ts +1 -0
- package/lib/cjs/utils/constants.js +2 -1
- package/lib/cjs/utils/hub.d.ts +1 -1
- package/lib/cjs/utils/model.d.ts +18 -1
- package/lib/cjs/utils/model.js +37 -2
- package/lib/cjs/utils/type.d.ts +8 -1
- package/lib/dts/aigne-hub-video-model.d.ts +28 -0
- package/lib/dts/index.d.ts +38 -2
- package/lib/dts/utils/constants.d.ts +1 -0
- package/lib/dts/utils/hub.d.ts +1 -1
- package/lib/dts/utils/model.d.ts +18 -1
- package/lib/dts/utils/type.d.ts +8 -1
- package/lib/esm/aigne-hub-video-model.d.ts +28 -0
- package/lib/esm/aigne-hub-video-model.js +80 -0
- package/lib/esm/index.d.ts +38 -2
- package/lib/esm/index.js +41 -2
- package/lib/esm/utils/constants.d.ts +1 -0
- package/lib/esm/utils/constants.js +1 -0
- package/lib/esm/utils/hub.d.ts +1 -1
- package/lib/esm/utils/model.d.ts +18 -1
- package/lib/esm/utils/model.js +37 -4
- package/lib/esm/utils/type.d.ts +8 -1
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.10.4-beta.2](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.10.4-beta.1...aigne-hub-v0.10.4-beta.2) (2025-10-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **model:** support video model ([#647](https://github.com/AIGNE-io/aigne-framework/issues/647)) ([de81742](https://github.com/AIGNE-io/aigne-framework/commit/de817421ef1dd3246d0d8c51ff12f0a855658f9f))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @aigne/anthropic bumped to 0.14.4-beta.1
|
|
16
|
+
* @aigne/bedrock bumped to 0.10.9-beta.1
|
|
17
|
+
* @aigne/core bumped to 1.65.0-beta
|
|
18
|
+
* @aigne/deepseek bumped to 0.7.50-beta.1
|
|
19
|
+
* @aigne/doubao bumped to 1.1.4-beta.1
|
|
20
|
+
* @aigne/gemini bumped to 0.14.4-beta.2
|
|
21
|
+
* @aigne/ideogram bumped to 0.4.4-beta.1
|
|
22
|
+
* @aigne/ollama bumped to 0.7.50-beta.1
|
|
23
|
+
* @aigne/open-router bumped to 0.7.50-beta.1
|
|
24
|
+
* @aigne/openai bumped to 0.16.4-beta.1
|
|
25
|
+
* @aigne/poe bumped to 1.0.30-beta.1
|
|
26
|
+
* @aigne/transport bumped to 0.15.13-beta.1
|
|
27
|
+
* @aigne/xai bumped to 0.7.50-beta.1
|
|
28
|
+
* devDependencies
|
|
29
|
+
* @aigne/test-utils bumped to 0.5.57-beta.1
|
|
30
|
+
|
|
3
31
|
## [0.10.4-beta.1](https://github.com/AIGNE-io/aigne-framework/compare/aigne-hub-v0.10.4-beta...aigne-hub-v0.10.4-beta.1) (2025-10-24)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -0,0 +1,28 @@
|
|
|
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: number;
|
|
12
|
+
output_credits_per_token: number;
|
|
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
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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 response = await (await this.client).__invoke(undefined, {
|
|
60
|
+
...input,
|
|
61
|
+
model: input.model || (await this.credential).model,
|
|
62
|
+
}, {
|
|
63
|
+
...options,
|
|
64
|
+
streaming: false,
|
|
65
|
+
fetchOptions: {
|
|
66
|
+
...options.fetchOptions,
|
|
67
|
+
headers: {
|
|
68
|
+
...options.fetchOptions?.headers,
|
|
69
|
+
"x-aigne-hub-client-did": clientId,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
videos: response.videos,
|
|
75
|
+
usage: {
|
|
76
|
+
inputTokens: response.usage?.inputTokens ?? 0,
|
|
77
|
+
outputTokens: response.usage?.outputTokens ?? 0,
|
|
78
|
+
aigneHubCredits: response.usage?.aigneHubCredits,
|
|
79
|
+
},
|
|
80
|
+
model: response?.model,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.AIGNEHubVideoModel = AIGNEHubVideoModel;
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput, ImageModel, type ImageModelInput, type ImageModelOutput } from "@aigne/core";
|
|
1
|
+
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput, ImageModel, type ImageModelInput, type ImageModelOutput, VideoModel, type VideoModelInput, type VideoModelOutput } from "@aigne/core";
|
|
2
2
|
import type { BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
|
|
3
|
-
import type { AIGNEHubChatModelOptions, AIGNEHubImageModelOptions } from "./utils/type.js";
|
|
3
|
+
import type { AIGNEHubChatModelOptions, AIGNEHubImageModelOptions, AIGNEHubVideoModelOptions } from "./utils/type.js";
|
|
4
4
|
export * from "./utils/blocklet.js";
|
|
5
5
|
export * from "./utils/constants.js";
|
|
6
6
|
export * from "./utils/model.js";
|
|
@@ -76,3 +76,39 @@ export declare class AIGNEHubImageModel extends ImageModel {
|
|
|
76
76
|
}>;
|
|
77
77
|
process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ImageModelOutput>>;
|
|
78
78
|
}
|
|
79
|
+
export declare class AIGNEHubVideoModel extends VideoModel {
|
|
80
|
+
options: AIGNEHubVideoModelOptions;
|
|
81
|
+
static load(options: AIGNEHubVideoModelOptions): Promise<AIGNEHubVideoModel>;
|
|
82
|
+
static models(): Promise<{
|
|
83
|
+
type: string;
|
|
84
|
+
model: string;
|
|
85
|
+
provider: string;
|
|
86
|
+
input_credits_per_token: number;
|
|
87
|
+
output_credits_per_token: number;
|
|
88
|
+
providerDisplayName: string;
|
|
89
|
+
status?: {
|
|
90
|
+
available: boolean;
|
|
91
|
+
} | null | undefined;
|
|
92
|
+
modelMetadata?: Record<string, unknown> | null | undefined;
|
|
93
|
+
}[]>;
|
|
94
|
+
models(): Promise<{
|
|
95
|
+
type: string;
|
|
96
|
+
model: string;
|
|
97
|
+
provider: string;
|
|
98
|
+
input_credits_per_token: number;
|
|
99
|
+
output_credits_per_token: number;
|
|
100
|
+
providerDisplayName: string;
|
|
101
|
+
status?: {
|
|
102
|
+
available: boolean;
|
|
103
|
+
} | null | undefined;
|
|
104
|
+
modelMetadata?: Record<string, unknown> | null | undefined;
|
|
105
|
+
}[]>;
|
|
106
|
+
constructor(options: AIGNEHubVideoModelOptions);
|
|
107
|
+
protected client: VideoModel;
|
|
108
|
+
get credential(): import("@aigne/core/utils/type-utils.js").PromiseOrValue<{
|
|
109
|
+
url?: string;
|
|
110
|
+
apiKey?: string;
|
|
111
|
+
model?: string;
|
|
112
|
+
}>;
|
|
113
|
+
process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<VideoModelOutput>>;
|
|
114
|
+
}
|
package/lib/cjs/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.AIGNEHubImageModel = exports.AIGNEHubChatModel = void 0;
|
|
17
|
+
exports.AIGNEHubVideoModel = exports.AIGNEHubImageModel = exports.AIGNEHubChatModel = void 0;
|
|
18
18
|
const core_1 = require("@aigne/core");
|
|
19
19
|
const hub_js_1 = require("./utils/hub.js");
|
|
20
20
|
const model_js_1 = require("./utils/model.js");
|
|
@@ -101,3 +101,43 @@ class AIGNEHubImageModel extends core_1.ImageModel {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
exports.AIGNEHubImageModel = AIGNEHubImageModel;
|
|
104
|
+
class AIGNEHubVideoModel extends core_1.VideoModel {
|
|
105
|
+
options;
|
|
106
|
+
static async load(options) {
|
|
107
|
+
return new AIGNEHubVideoModel(options);
|
|
108
|
+
}
|
|
109
|
+
static async models() {
|
|
110
|
+
return (0, hub_js_1.getModels)({ type: "video" });
|
|
111
|
+
}
|
|
112
|
+
models() {
|
|
113
|
+
return (0, hub_js_1.getModels)({ type: "video" });
|
|
114
|
+
}
|
|
115
|
+
constructor(options) {
|
|
116
|
+
let provider = process.env.BLOCKLET_AIGNE_API_PROVIDER;
|
|
117
|
+
if (!provider && options.model) {
|
|
118
|
+
const parsed = (0, model_js_1.parseModel)(options.model);
|
|
119
|
+
if (parsed.provider && parsed.model) {
|
|
120
|
+
provider = parsed.provider;
|
|
121
|
+
options.model = parsed.model;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
provider ||= AIGNEHubVideoModel.name;
|
|
125
|
+
const { match, all } = (0, model_js_1.findVideoModel)(provider);
|
|
126
|
+
if (!match) {
|
|
127
|
+
const available = all.map((m) => m.name).join(", ");
|
|
128
|
+
throw new Error(`Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
|
|
129
|
+
}
|
|
130
|
+
const client = match.create(options);
|
|
131
|
+
super({ name: client.name });
|
|
132
|
+
this.options = options;
|
|
133
|
+
this.client = client;
|
|
134
|
+
}
|
|
135
|
+
client;
|
|
136
|
+
get credential() {
|
|
137
|
+
return this.client.credential;
|
|
138
|
+
}
|
|
139
|
+
async process(input, options) {
|
|
140
|
+
return this.client.invoke(input, options);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.AIGNEHubVideoModel = AIGNEHubVideoModel;
|
|
@@ -2,4 +2,5 @@ export declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
|
|
|
2
2
|
export declare const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
|
|
3
3
|
export declare const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
|
|
4
4
|
export declare const AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
|
|
5
|
+
export declare const AIGNE_HUB_VIDEO_MODEL = "openai/sora-2";
|
|
5
6
|
export declare const aigneHubBaseUrl: () => string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.aigneHubBaseUrl = exports.AIGNE_HUB_IMAGE_MODEL = exports.AIGNE_HUB_DEFAULT_MODEL = exports.AIGNE_HUB_BLOCKLET_DID = exports.AIGNE_HUB_URL = void 0;
|
|
3
|
+
exports.aigneHubBaseUrl = 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
4
|
exports.AIGNE_HUB_URL = "https://hub.aigne.io/";
|
|
5
5
|
exports.AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
|
|
6
6
|
exports.AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
|
|
7
7
|
exports.AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
|
|
8
|
+
exports.AIGNE_HUB_VIDEO_MODEL = "openai/sora-2";
|
|
8
9
|
const aigneHubBaseUrl = () => process.env.BLOCKLET_AIGNE_API_URL || process.env.AIGNE_HUB_API_URL || exports.AIGNE_HUB_URL;
|
|
9
10
|
exports.aigneHubBaseUrl = aigneHubBaseUrl;
|
package/lib/cjs/utils/hub.d.ts
CHANGED
package/lib/cjs/utils/model.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatModel, ChatModelInputOptions, ImageModel, ImageModelInputOptions } from "@aigne/core";
|
|
1
|
+
import type { ChatModel, ChatModelInputOptions, ImageModel, ImageModelInputOptions, VideoModel } from "@aigne/core";
|
|
2
2
|
export interface LoadableModel {
|
|
3
3
|
name: string | string[];
|
|
4
4
|
apiKeyEnvName?: string | string[];
|
|
@@ -20,7 +20,20 @@ export interface LoadableImageModel {
|
|
|
20
20
|
modelOptions?: ImageModelInputOptions;
|
|
21
21
|
}) => ImageModel;
|
|
22
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
|
+
}
|
|
23
35
|
export declare function availableImageModels(): LoadableImageModel[];
|
|
36
|
+
export declare function availableVideoModels(): LoadableVideoModel[];
|
|
24
37
|
export declare function findModel(provider: string): {
|
|
25
38
|
all: LoadableModel[];
|
|
26
39
|
match: LoadableModel | undefined;
|
|
@@ -29,6 +42,10 @@ export declare function findImageModel(provider: string): {
|
|
|
29
42
|
all: LoadableImageModel[];
|
|
30
43
|
match: LoadableImageModel | undefined;
|
|
31
44
|
};
|
|
45
|
+
export declare function findVideoModel(provider: string): {
|
|
46
|
+
all: LoadableVideoModel[];
|
|
47
|
+
match: LoadableVideoModel | undefined;
|
|
48
|
+
};
|
|
32
49
|
export declare const parseModel: (model: string) => {
|
|
33
50
|
provider: string | undefined;
|
|
34
51
|
model: string | undefined;
|
package/lib/cjs/utils/model.js
CHANGED
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseModel = void 0;
|
|
4
4
|
exports.availableModels = availableModels;
|
|
5
5
|
exports.availableImageModels = availableImageModels;
|
|
6
|
+
exports.availableVideoModels = availableVideoModels;
|
|
6
7
|
exports.findModel = findModel;
|
|
7
8
|
exports.findImageModel = findImageModel;
|
|
9
|
+
exports.findVideoModel = findVideoModel;
|
|
8
10
|
const anthropic_1 = require("@aigne/anthropic");
|
|
9
11
|
const bedrock_1 = require("@aigne/bedrock");
|
|
10
12
|
const deepseek_1 = require("@aigne/deepseek");
|
|
@@ -20,6 +22,7 @@ const node_http_handler_1 = require("@smithy/node-http-handler");
|
|
|
20
22
|
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
21
23
|
const aigne_hub_image_model_js_1 = require("../aigne-hub-image-model.js");
|
|
22
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");
|
|
23
26
|
const getClientOptions = () => {
|
|
24
27
|
const proxy = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy"]
|
|
25
28
|
.map((i) => process.env[i])
|
|
@@ -36,6 +39,7 @@ const getClientOptions = () => {
|
|
|
36
39
|
httpAgent,
|
|
37
40
|
};
|
|
38
41
|
};
|
|
42
|
+
const GOOGLE = "google";
|
|
39
43
|
function availableModels() {
|
|
40
44
|
const { clientOptions, httpAgent } = getClientOptions();
|
|
41
45
|
return [
|
|
@@ -66,7 +70,7 @@ function availableModels() {
|
|
|
66
70
|
create: (params) => new deepseek_1.DeepSeekChatModel({ ...params, clientOptions }),
|
|
67
71
|
},
|
|
68
72
|
{
|
|
69
|
-
name: [gemini_1.GeminiChatModel.name,
|
|
73
|
+
name: [gemini_1.GeminiChatModel.name, GOOGLE],
|
|
70
74
|
apiKeyEnvName: ["GEMINI_API_KEY", "GOOGLE_API_KEY"],
|
|
71
75
|
create: (params) => new gemini_1.GeminiChatModel({
|
|
72
76
|
...params,
|
|
@@ -114,7 +118,7 @@ function availableImageModels() {
|
|
|
114
118
|
create: (params) => new openai_1.OpenAIImageModel({ ...params, clientOptions }),
|
|
115
119
|
},
|
|
116
120
|
{
|
|
117
|
-
name: [gemini_1.GeminiImageModel.name,
|
|
121
|
+
name: [gemini_1.GeminiImageModel.name, GOOGLE],
|
|
118
122
|
apiKeyEnvName: "GEMINI_API_KEY",
|
|
119
123
|
create: (params) => new gemini_1.GeminiImageModel({ ...params, clientOptions }),
|
|
120
124
|
},
|
|
@@ -135,6 +139,26 @@ function availableImageModels() {
|
|
|
135
139
|
},
|
|
136
140
|
];
|
|
137
141
|
}
|
|
142
|
+
function availableVideoModels() {
|
|
143
|
+
const { clientOptions } = getClientOptions();
|
|
144
|
+
return [
|
|
145
|
+
{
|
|
146
|
+
name: openai_1.OpenAIVideoModel.name,
|
|
147
|
+
apiKeyEnvName: "OPENAI_API_KEY",
|
|
148
|
+
create: (params) => new openai_1.OpenAIVideoModel({ ...params, clientOptions }),
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: [gemini_1.GeminiVideoModel.name, GOOGLE],
|
|
152
|
+
apiKeyEnvName: "GEMINI_API_KEY",
|
|
153
|
+
create: (params) => new gemini_1.GeminiVideoModel({ ...params, clientOptions }),
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: aigne_hub_video_model_js_1.AIGNEHubVideoModel.name,
|
|
157
|
+
apiKeyEnvName: "AIGNE_HUB_API_KEY",
|
|
158
|
+
create: (params) => new aigne_hub_video_model_js_1.AIGNEHubVideoModel({ ...params, clientOptions }),
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
}
|
|
138
162
|
function findModel(provider) {
|
|
139
163
|
provider = provider.toLowerCase().replace(/-/g, "");
|
|
140
164
|
const all = availableModels();
|
|
@@ -157,6 +181,17 @@ function findImageModel(provider) {
|
|
|
157
181
|
});
|
|
158
182
|
return { all, match };
|
|
159
183
|
}
|
|
184
|
+
function findVideoModel(provider) {
|
|
185
|
+
provider = provider.toLowerCase().replace(/-/g, "");
|
|
186
|
+
const all = availableVideoModels();
|
|
187
|
+
const match = all.find((m) => {
|
|
188
|
+
if (typeof m.name === "string") {
|
|
189
|
+
return m.name.toLowerCase().includes(provider);
|
|
190
|
+
}
|
|
191
|
+
return m.name.some((n) => n.toLowerCase().includes(provider));
|
|
192
|
+
});
|
|
193
|
+
return { all, match };
|
|
194
|
+
}
|
|
160
195
|
const parseModel = (model) => {
|
|
161
196
|
// replace first ':' with '/' to compatible with `provider:model-name` format
|
|
162
197
|
model = model.replace(/^(\w+)(:)/, "$1/");
|
package/lib/cjs/utils/type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatModelOptions, ImageModelOptions } from "@aigne/core";
|
|
1
|
+
import type { ChatModelOptions, ImageModelOptions, VideoModelOptions } from "@aigne/core";
|
|
2
2
|
import type { OpenAIChatModelOptions } from "@aigne/openai";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
export declare const aigneHubModelOptionsSchema: z.ZodObject<{
|
|
@@ -69,3 +69,10 @@ export interface AIGNEHubImageModelOptions extends ImageModelOptions {
|
|
|
69
69
|
clientId?: string;
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
+
export interface AIGNEHubVideoModelOptions extends VideoModelOptions {
|
|
73
|
+
baseURL?: string;
|
|
74
|
+
apiKey?: string;
|
|
75
|
+
clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
|
|
76
|
+
clientId?: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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: number;
|
|
12
|
+
output_credits_per_token: number;
|
|
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
|
+
}
|
package/lib/dts/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput, ImageModel, type ImageModelInput, type ImageModelOutput } from "@aigne/core";
|
|
1
|
+
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput, ImageModel, type ImageModelInput, type ImageModelOutput, VideoModel, type VideoModelInput, type VideoModelOutput } from "@aigne/core";
|
|
2
2
|
import type { BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
|
|
3
|
-
import type { AIGNEHubChatModelOptions, AIGNEHubImageModelOptions } from "./utils/type.js";
|
|
3
|
+
import type { AIGNEHubChatModelOptions, AIGNEHubImageModelOptions, AIGNEHubVideoModelOptions } from "./utils/type.js";
|
|
4
4
|
export * from "./utils/blocklet.js";
|
|
5
5
|
export * from "./utils/constants.js";
|
|
6
6
|
export * from "./utils/model.js";
|
|
@@ -76,3 +76,39 @@ export declare class AIGNEHubImageModel extends ImageModel {
|
|
|
76
76
|
}>;
|
|
77
77
|
process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ImageModelOutput>>;
|
|
78
78
|
}
|
|
79
|
+
export declare class AIGNEHubVideoModel extends VideoModel {
|
|
80
|
+
options: AIGNEHubVideoModelOptions;
|
|
81
|
+
static load(options: AIGNEHubVideoModelOptions): Promise<AIGNEHubVideoModel>;
|
|
82
|
+
static models(): Promise<{
|
|
83
|
+
type: string;
|
|
84
|
+
model: string;
|
|
85
|
+
provider: string;
|
|
86
|
+
input_credits_per_token: number;
|
|
87
|
+
output_credits_per_token: number;
|
|
88
|
+
providerDisplayName: string;
|
|
89
|
+
status?: {
|
|
90
|
+
available: boolean;
|
|
91
|
+
} | null | undefined;
|
|
92
|
+
modelMetadata?: Record<string, unknown> | null | undefined;
|
|
93
|
+
}[]>;
|
|
94
|
+
models(): Promise<{
|
|
95
|
+
type: string;
|
|
96
|
+
model: string;
|
|
97
|
+
provider: string;
|
|
98
|
+
input_credits_per_token: number;
|
|
99
|
+
output_credits_per_token: number;
|
|
100
|
+
providerDisplayName: string;
|
|
101
|
+
status?: {
|
|
102
|
+
available: boolean;
|
|
103
|
+
} | null | undefined;
|
|
104
|
+
modelMetadata?: Record<string, unknown> | null | undefined;
|
|
105
|
+
}[]>;
|
|
106
|
+
constructor(options: AIGNEHubVideoModelOptions);
|
|
107
|
+
protected client: VideoModel;
|
|
108
|
+
get credential(): import("@aigne/core/utils/type-utils.js").PromiseOrValue<{
|
|
109
|
+
url?: string;
|
|
110
|
+
apiKey?: string;
|
|
111
|
+
model?: string;
|
|
112
|
+
}>;
|
|
113
|
+
process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<VideoModelOutput>>;
|
|
114
|
+
}
|
|
@@ -2,4 +2,5 @@ export declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
|
|
|
2
2
|
export declare const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
|
|
3
3
|
export declare const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
|
|
4
4
|
export declare const AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
|
|
5
|
+
export declare const AIGNE_HUB_VIDEO_MODEL = "openai/sora-2";
|
|
5
6
|
export declare const aigneHubBaseUrl: () => string;
|
package/lib/dts/utils/hub.d.ts
CHANGED
package/lib/dts/utils/model.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatModel, ChatModelInputOptions, ImageModel, ImageModelInputOptions } from "@aigne/core";
|
|
1
|
+
import type { ChatModel, ChatModelInputOptions, ImageModel, ImageModelInputOptions, VideoModel } from "@aigne/core";
|
|
2
2
|
export interface LoadableModel {
|
|
3
3
|
name: string | string[];
|
|
4
4
|
apiKeyEnvName?: string | string[];
|
|
@@ -20,7 +20,20 @@ export interface LoadableImageModel {
|
|
|
20
20
|
modelOptions?: ImageModelInputOptions;
|
|
21
21
|
}) => ImageModel;
|
|
22
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
|
+
}
|
|
23
35
|
export declare function availableImageModels(): LoadableImageModel[];
|
|
36
|
+
export declare function availableVideoModels(): LoadableVideoModel[];
|
|
24
37
|
export declare function findModel(provider: string): {
|
|
25
38
|
all: LoadableModel[];
|
|
26
39
|
match: LoadableModel | undefined;
|
|
@@ -29,6 +42,10 @@ export declare function findImageModel(provider: string): {
|
|
|
29
42
|
all: LoadableImageModel[];
|
|
30
43
|
match: LoadableImageModel | undefined;
|
|
31
44
|
};
|
|
45
|
+
export declare function findVideoModel(provider: string): {
|
|
46
|
+
all: LoadableVideoModel[];
|
|
47
|
+
match: LoadableVideoModel | undefined;
|
|
48
|
+
};
|
|
32
49
|
export declare const parseModel: (model: string) => {
|
|
33
50
|
provider: string | undefined;
|
|
34
51
|
model: string | undefined;
|
package/lib/dts/utils/type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatModelOptions, ImageModelOptions } from "@aigne/core";
|
|
1
|
+
import type { ChatModelOptions, ImageModelOptions, VideoModelOptions } from "@aigne/core";
|
|
2
2
|
import type { OpenAIChatModelOptions } from "@aigne/openai";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
export declare const aigneHubModelOptionsSchema: z.ZodObject<{
|
|
@@ -69,3 +69,10 @@ export interface AIGNEHubImageModelOptions extends ImageModelOptions {
|
|
|
69
69
|
clientId?: string;
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
+
export interface AIGNEHubVideoModelOptions extends VideoModelOptions {
|
|
73
|
+
baseURL?: string;
|
|
74
|
+
apiKey?: string;
|
|
75
|
+
clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
|
|
76
|
+
clientId?: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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: number;
|
|
12
|
+
output_credits_per_token: number;
|
|
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
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 response = await (await this.client).__invoke(undefined, {
|
|
57
|
+
...input,
|
|
58
|
+
model: input.model || (await this.credential).model,
|
|
59
|
+
}, {
|
|
60
|
+
...options,
|
|
61
|
+
streaming: false,
|
|
62
|
+
fetchOptions: {
|
|
63
|
+
...options.fetchOptions,
|
|
64
|
+
headers: {
|
|
65
|
+
...options.fetchOptions?.headers,
|
|
66
|
+
"x-aigne-hub-client-did": clientId,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
videos: response.videos,
|
|
72
|
+
usage: {
|
|
73
|
+
inputTokens: response.usage?.inputTokens ?? 0,
|
|
74
|
+
outputTokens: response.usage?.outputTokens ?? 0,
|
|
75
|
+
aigneHubCredits: response.usage?.aigneHubCredits,
|
|
76
|
+
},
|
|
77
|
+
model: response?.model,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput, ImageModel, type ImageModelInput, type ImageModelOutput } from "@aigne/core";
|
|
1
|
+
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput, ImageModel, type ImageModelInput, type ImageModelOutput, VideoModel, type VideoModelInput, type VideoModelOutput } from "@aigne/core";
|
|
2
2
|
import type { BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
|
|
3
|
-
import type { AIGNEHubChatModelOptions, AIGNEHubImageModelOptions } from "./utils/type.js";
|
|
3
|
+
import type { AIGNEHubChatModelOptions, AIGNEHubImageModelOptions, AIGNEHubVideoModelOptions } from "./utils/type.js";
|
|
4
4
|
export * from "./utils/blocklet.js";
|
|
5
5
|
export * from "./utils/constants.js";
|
|
6
6
|
export * from "./utils/model.js";
|
|
@@ -76,3 +76,39 @@ export declare class AIGNEHubImageModel extends ImageModel {
|
|
|
76
76
|
}>;
|
|
77
77
|
process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ImageModelOutput>>;
|
|
78
78
|
}
|
|
79
|
+
export declare class AIGNEHubVideoModel extends VideoModel {
|
|
80
|
+
options: AIGNEHubVideoModelOptions;
|
|
81
|
+
static load(options: AIGNEHubVideoModelOptions): Promise<AIGNEHubVideoModel>;
|
|
82
|
+
static models(): Promise<{
|
|
83
|
+
type: string;
|
|
84
|
+
model: string;
|
|
85
|
+
provider: string;
|
|
86
|
+
input_credits_per_token: number;
|
|
87
|
+
output_credits_per_token: number;
|
|
88
|
+
providerDisplayName: string;
|
|
89
|
+
status?: {
|
|
90
|
+
available: boolean;
|
|
91
|
+
} | null | undefined;
|
|
92
|
+
modelMetadata?: Record<string, unknown> | null | undefined;
|
|
93
|
+
}[]>;
|
|
94
|
+
models(): Promise<{
|
|
95
|
+
type: string;
|
|
96
|
+
model: string;
|
|
97
|
+
provider: string;
|
|
98
|
+
input_credits_per_token: number;
|
|
99
|
+
output_credits_per_token: number;
|
|
100
|
+
providerDisplayName: string;
|
|
101
|
+
status?: {
|
|
102
|
+
available: boolean;
|
|
103
|
+
} | null | undefined;
|
|
104
|
+
modelMetadata?: Record<string, unknown> | null | undefined;
|
|
105
|
+
}[]>;
|
|
106
|
+
constructor(options: AIGNEHubVideoModelOptions);
|
|
107
|
+
protected client: VideoModel;
|
|
108
|
+
get credential(): import("@aigne/core/utils/type-utils.js").PromiseOrValue<{
|
|
109
|
+
url?: string;
|
|
110
|
+
apiKey?: string;
|
|
111
|
+
model?: string;
|
|
112
|
+
}>;
|
|
113
|
+
process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<VideoModelOutput>>;
|
|
114
|
+
}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ChatModel, ImageModel, } from "@aigne/core";
|
|
1
|
+
import { ChatModel, ImageModel, VideoModel, } from "@aigne/core";
|
|
2
2
|
import { getModels } from "./utils/hub.js";
|
|
3
|
-
import { findImageModel, findModel, parseModel } from "./utils/model.js";
|
|
3
|
+
import { findImageModel, findModel, findVideoModel, parseModel } from "./utils/model.js";
|
|
4
4
|
export * from "./utils/blocklet.js";
|
|
5
5
|
export * from "./utils/constants.js";
|
|
6
6
|
export * from "./utils/model.js";
|
|
@@ -82,3 +82,42 @@ export class AIGNEHubImageModel extends ImageModel {
|
|
|
82
82
|
return this.client.invoke(input, options);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
export class AIGNEHubVideoModel extends VideoModel {
|
|
86
|
+
options;
|
|
87
|
+
static async load(options) {
|
|
88
|
+
return new AIGNEHubVideoModel(options);
|
|
89
|
+
}
|
|
90
|
+
static async models() {
|
|
91
|
+
return getModels({ type: "video" });
|
|
92
|
+
}
|
|
93
|
+
models() {
|
|
94
|
+
return getModels({ type: "video" });
|
|
95
|
+
}
|
|
96
|
+
constructor(options) {
|
|
97
|
+
let provider = process.env.BLOCKLET_AIGNE_API_PROVIDER;
|
|
98
|
+
if (!provider && options.model) {
|
|
99
|
+
const parsed = parseModel(options.model);
|
|
100
|
+
if (parsed.provider && parsed.model) {
|
|
101
|
+
provider = parsed.provider;
|
|
102
|
+
options.model = parsed.model;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
provider ||= AIGNEHubVideoModel.name;
|
|
106
|
+
const { match, all } = findVideoModel(provider);
|
|
107
|
+
if (!match) {
|
|
108
|
+
const available = all.map((m) => m.name).join(", ");
|
|
109
|
+
throw new Error(`Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
|
|
110
|
+
}
|
|
111
|
+
const client = match.create(options);
|
|
112
|
+
super({ name: client.name });
|
|
113
|
+
this.options = options;
|
|
114
|
+
this.client = client;
|
|
115
|
+
}
|
|
116
|
+
client;
|
|
117
|
+
get credential() {
|
|
118
|
+
return this.client.credential;
|
|
119
|
+
}
|
|
120
|
+
async process(input, options) {
|
|
121
|
+
return this.client.invoke(input, options);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -2,4 +2,5 @@ export declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
|
|
|
2
2
|
export declare const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
|
|
3
3
|
export declare const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
|
|
4
4
|
export declare const AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
|
|
5
|
+
export declare const AIGNE_HUB_VIDEO_MODEL = "openai/sora-2";
|
|
5
6
|
export declare const aigneHubBaseUrl: () => string;
|
|
@@ -2,4 +2,5 @@ export const AIGNE_HUB_URL = "https://hub.aigne.io/";
|
|
|
2
2
|
export const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
|
|
3
3
|
export const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
|
|
4
4
|
export const AIGNE_HUB_IMAGE_MODEL = "openai/gpt-image-1";
|
|
5
|
+
export const AIGNE_HUB_VIDEO_MODEL = "openai/sora-2";
|
|
5
6
|
export const aigneHubBaseUrl = () => process.env.BLOCKLET_AIGNE_API_URL || process.env.AIGNE_HUB_API_URL || AIGNE_HUB_URL;
|
package/lib/esm/utils/hub.d.ts
CHANGED
package/lib/esm/utils/model.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatModel, ChatModelInputOptions, ImageModel, ImageModelInputOptions } from "@aigne/core";
|
|
1
|
+
import type { ChatModel, ChatModelInputOptions, ImageModel, ImageModelInputOptions, VideoModel } from "@aigne/core";
|
|
2
2
|
export interface LoadableModel {
|
|
3
3
|
name: string | string[];
|
|
4
4
|
apiKeyEnvName?: string | string[];
|
|
@@ -20,7 +20,20 @@ export interface LoadableImageModel {
|
|
|
20
20
|
modelOptions?: ImageModelInputOptions;
|
|
21
21
|
}) => ImageModel;
|
|
22
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
|
+
}
|
|
23
35
|
export declare function availableImageModels(): LoadableImageModel[];
|
|
36
|
+
export declare function availableVideoModels(): LoadableVideoModel[];
|
|
24
37
|
export declare function findModel(provider: string): {
|
|
25
38
|
all: LoadableModel[];
|
|
26
39
|
match: LoadableModel | undefined;
|
|
@@ -29,6 +42,10 @@ export declare function findImageModel(provider: string): {
|
|
|
29
42
|
all: LoadableImageModel[];
|
|
30
43
|
match: LoadableImageModel | undefined;
|
|
31
44
|
};
|
|
45
|
+
export declare function findVideoModel(provider: string): {
|
|
46
|
+
all: LoadableVideoModel[];
|
|
47
|
+
match: LoadableVideoModel | undefined;
|
|
48
|
+
};
|
|
32
49
|
export declare const parseModel: (model: string) => {
|
|
33
50
|
provider: string | undefined;
|
|
34
51
|
model: string | undefined;
|
package/lib/esm/utils/model.js
CHANGED
|
@@ -2,17 +2,18 @@ import { AnthropicChatModel } from "@aigne/anthropic";
|
|
|
2
2
|
import { BedrockChatModel } from "@aigne/bedrock";
|
|
3
3
|
import { DeepSeekChatModel } from "@aigne/deepseek";
|
|
4
4
|
import { DoubaoChatModel, DoubaoImageModel } from "@aigne/doubao";
|
|
5
|
-
import { GeminiChatModel, GeminiImageModel } from "@aigne/gemini";
|
|
5
|
+
import { GeminiChatModel, GeminiImageModel, GeminiVideoModel } from "@aigne/gemini";
|
|
6
6
|
import { IdeogramImageModel } from "@aigne/ideogram";
|
|
7
7
|
import { OllamaChatModel } from "@aigne/ollama";
|
|
8
8
|
import { OpenRouterChatModel } from "@aigne/open-router";
|
|
9
|
-
import { OpenAIChatModel, OpenAIImageModel } from "@aigne/openai";
|
|
9
|
+
import { OpenAIChatModel, OpenAIImageModel, OpenAIVideoModel, } from "@aigne/openai";
|
|
10
10
|
import { PoeChatModel } from "@aigne/poe";
|
|
11
11
|
import { XAIChatModel } from "@aigne/xai";
|
|
12
12
|
import { NodeHttpHandler, streamCollector } from "@smithy/node-http-handler";
|
|
13
13
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
14
14
|
import { AIGNEHubImageModel } from "../aigne-hub-image-model.js";
|
|
15
15
|
import { AIGNEHubChatModel } from "../aigne-hub-model.js";
|
|
16
|
+
import { AIGNEHubVideoModel } from "../aigne-hub-video-model.js";
|
|
16
17
|
const getClientOptions = () => {
|
|
17
18
|
const proxy = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy"]
|
|
18
19
|
.map((i) => process.env[i])
|
|
@@ -29,6 +30,7 @@ const getClientOptions = () => {
|
|
|
29
30
|
httpAgent,
|
|
30
31
|
};
|
|
31
32
|
};
|
|
33
|
+
const GOOGLE = "google";
|
|
32
34
|
export function availableModels() {
|
|
33
35
|
const { clientOptions, httpAgent } = getClientOptions();
|
|
34
36
|
return [
|
|
@@ -59,7 +61,7 @@ export function availableModels() {
|
|
|
59
61
|
create: (params) => new DeepSeekChatModel({ ...params, clientOptions }),
|
|
60
62
|
},
|
|
61
63
|
{
|
|
62
|
-
name: [GeminiChatModel.name,
|
|
64
|
+
name: [GeminiChatModel.name, GOOGLE],
|
|
63
65
|
apiKeyEnvName: ["GEMINI_API_KEY", "GOOGLE_API_KEY"],
|
|
64
66
|
create: (params) => new GeminiChatModel({
|
|
65
67
|
...params,
|
|
@@ -107,7 +109,7 @@ export function availableImageModels() {
|
|
|
107
109
|
create: (params) => new OpenAIImageModel({ ...params, clientOptions }),
|
|
108
110
|
},
|
|
109
111
|
{
|
|
110
|
-
name: [GeminiImageModel.name,
|
|
112
|
+
name: [GeminiImageModel.name, GOOGLE],
|
|
111
113
|
apiKeyEnvName: "GEMINI_API_KEY",
|
|
112
114
|
create: (params) => new GeminiImageModel({ ...params, clientOptions }),
|
|
113
115
|
},
|
|
@@ -128,6 +130,26 @@ export function availableImageModels() {
|
|
|
128
130
|
},
|
|
129
131
|
];
|
|
130
132
|
}
|
|
133
|
+
export function availableVideoModels() {
|
|
134
|
+
const { clientOptions } = getClientOptions();
|
|
135
|
+
return [
|
|
136
|
+
{
|
|
137
|
+
name: OpenAIVideoModel.name,
|
|
138
|
+
apiKeyEnvName: "OPENAI_API_KEY",
|
|
139
|
+
create: (params) => new OpenAIVideoModel({ ...params, clientOptions }),
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: [GeminiVideoModel.name, GOOGLE],
|
|
143
|
+
apiKeyEnvName: "GEMINI_API_KEY",
|
|
144
|
+
create: (params) => new GeminiVideoModel({ ...params, clientOptions }),
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: AIGNEHubVideoModel.name,
|
|
148
|
+
apiKeyEnvName: "AIGNE_HUB_API_KEY",
|
|
149
|
+
create: (params) => new AIGNEHubVideoModel({ ...params, clientOptions }),
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
}
|
|
131
153
|
export function findModel(provider) {
|
|
132
154
|
provider = provider.toLowerCase().replace(/-/g, "");
|
|
133
155
|
const all = availableModels();
|
|
@@ -150,6 +172,17 @@ export function findImageModel(provider) {
|
|
|
150
172
|
});
|
|
151
173
|
return { all, match };
|
|
152
174
|
}
|
|
175
|
+
export function findVideoModel(provider) {
|
|
176
|
+
provider = provider.toLowerCase().replace(/-/g, "");
|
|
177
|
+
const all = availableVideoModels();
|
|
178
|
+
const match = all.find((m) => {
|
|
179
|
+
if (typeof m.name === "string") {
|
|
180
|
+
return m.name.toLowerCase().includes(provider);
|
|
181
|
+
}
|
|
182
|
+
return m.name.some((n) => n.toLowerCase().includes(provider));
|
|
183
|
+
});
|
|
184
|
+
return { all, match };
|
|
185
|
+
}
|
|
153
186
|
export const parseModel = (model) => {
|
|
154
187
|
// replace first ':' with '/' to compatible with `provider:model-name` format
|
|
155
188
|
model = model.replace(/^(\w+)(:)/, "$1/");
|
package/lib/esm/utils/type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatModelOptions, ImageModelOptions } from "@aigne/core";
|
|
1
|
+
import type { ChatModelOptions, ImageModelOptions, VideoModelOptions } from "@aigne/core";
|
|
2
2
|
import type { OpenAIChatModelOptions } from "@aigne/openai";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
export declare const aigneHubModelOptionsSchema: z.ZodObject<{
|
|
@@ -69,3 +69,10 @@ export interface AIGNEHubImageModelOptions extends ImageModelOptions {
|
|
|
69
69
|
clientId?: string;
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
+
export interface AIGNEHubVideoModelOptions extends VideoModelOptions {
|
|
73
|
+
baseURL?: string;
|
|
74
|
+
apiKey?: string;
|
|
75
|
+
clientOptions?: OpenAIChatModelOptions["clientOptions"] & {
|
|
76
|
+
clientId?: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/aigne-hub",
|
|
3
|
-
"version": "0.10.4-beta.
|
|
3
|
+
"version": "0.10.4-beta.2",
|
|
4
4
|
"description": "AIGNE Hub SDK for integrating with Hub AI models",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -39,20 +39,20 @@
|
|
|
39
39
|
"https-proxy-agent": "^7.0.6",
|
|
40
40
|
"ufo": "^1.6.1",
|
|
41
41
|
"zod": "^3.25.67",
|
|
42
|
-
"@aigne/anthropic": "^0.14.4-beta",
|
|
43
|
-
"@aigne/
|
|
44
|
-
"@aigne/deepseek": "^0.7.50-beta",
|
|
45
|
-
"@aigne/doubao": "^1.1.4-beta",
|
|
46
|
-
"@aigne/
|
|
47
|
-
"@aigne/gemini": "^0.14.4-beta.
|
|
48
|
-
"@aigne/ideogram": "^0.4.4-beta",
|
|
49
|
-
"@aigne/ollama": "^0.7.50-beta",
|
|
50
|
-
"@aigne/open-router": "^0.7.50-beta",
|
|
51
|
-
"@aigne/openai": "^0.16.4-beta",
|
|
52
|
-
"@aigne/
|
|
53
|
-
"@aigne/
|
|
54
|
-
"@aigne/
|
|
55
|
-
"@aigne/
|
|
42
|
+
"@aigne/anthropic": "^0.14.4-beta.1",
|
|
43
|
+
"@aigne/bedrock": "^0.10.9-beta.1",
|
|
44
|
+
"@aigne/deepseek": "^0.7.50-beta.1",
|
|
45
|
+
"@aigne/doubao": "^1.1.4-beta.1",
|
|
46
|
+
"@aigne/core": "^1.65.0-beta",
|
|
47
|
+
"@aigne/gemini": "^0.14.4-beta.2",
|
|
48
|
+
"@aigne/ideogram": "^0.4.4-beta.1",
|
|
49
|
+
"@aigne/ollama": "^0.7.50-beta.1",
|
|
50
|
+
"@aigne/open-router": "^0.7.50-beta.1",
|
|
51
|
+
"@aigne/openai": "^0.16.4-beta.1",
|
|
52
|
+
"@aigne/platform-helpers": "^0.6.3",
|
|
53
|
+
"@aigne/poe": "^1.0.30-beta.1",
|
|
54
|
+
"@aigne/xai": "^0.7.50-beta.1",
|
|
55
|
+
"@aigne/transport": "^0.15.13-beta.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/bun": "^1.2.22",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"npm-run-all": "^4.1.5",
|
|
62
62
|
"rimraf": "^6.0.1",
|
|
63
63
|
"typescript": "^5.9.2",
|
|
64
|
-
"@aigne/test-utils": "^0.5.57-beta"
|
|
64
|
+
"@aigne/test-utils": "^0.5.57-beta.1"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"lint": "tsc --noEmit",
|