@aigne/aigne-hub 1.74.0-beta.3 → 1.74.0-beta.5
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/dist/aigne-hub-chat-model.cjs +9 -9
- package/dist/aigne-hub-chat-model.d.cts +3 -3
- package/dist/aigne-hub-chat-model.d.cts.map +1 -1
- package/dist/aigne-hub-chat-model.d.mts +3 -3
- package/dist/aigne-hub-chat-model.d.mts.map +1 -1
- package/dist/aigne-hub-chat-model.mjs +4 -4
- package/dist/aigne-hub-chat-model.mjs.map +1 -1
- package/dist/aigne-hub-image-model.cjs +9 -9
- package/dist/aigne-hub-image-model.d.cts +3 -3
- package/dist/aigne-hub-image-model.d.cts.map +1 -1
- package/dist/aigne-hub-image-model.d.mts +3 -3
- package/dist/aigne-hub-image-model.d.mts.map +1 -1
- package/dist/aigne-hub-image-model.mjs +4 -4
- package/dist/aigne-hub-image-model.mjs.map +1 -1
- package/dist/aigne-hub-video-model.cjs +9 -9
- package/dist/aigne-hub-video-model.d.cts +3 -3
- package/dist/aigne-hub-video-model.d.cts.map +1 -1
- package/dist/aigne-hub-video-model.d.mts +3 -3
- package/dist/aigne-hub-video-model.d.mts.map +1 -1
- package/dist/aigne-hub-video-model.mjs +4 -4
- package/dist/aigne-hub-video-model.mjs.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +9 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +9 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/utils/blocklet.cjs +21 -3
- package/dist/utils/blocklet.d.cts.map +1 -1
- package/dist/utils/blocklet.d.mts.map +1 -1
- package/dist/utils/blocklet.mjs +20 -2
- package/dist/utils/blocklet.mjs.map +1 -1
- package/dist/utils/constants.d.cts.map +1 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/find-provider.d.cts.map +1 -1
- package/dist/utils/find-provider.d.mts.map +1 -1
- package/dist/utils/hub.cjs +2 -2
- package/dist/utils/hub.mjs +1 -1
- package/dist/utils/hub.mjs.map +1 -1
- package/dist/utils/model.d.cts +3 -3
- package/dist/utils/model.d.cts.map +1 -1
- package/dist/utils/model.d.mts +3 -3
- package/dist/utils/model.d.mts.map +1 -1
- package/dist/utils/model.mjs.map +1 -1
- package/dist/utils/type.d.cts +1 -1
- package/dist/utils/type.d.cts.map +1 -1
- package/dist/utils/type.d.mts +1 -1
- package/dist/utils/type.d.mts.map +1 -1
- package/dist/utils/type.mjs.map +1 -1
- package/package.json +13 -16
- package/LICENSE.md +0 -93
|
@@ -2,16 +2,16 @@ const require_blocklet = require('./utils/blocklet.cjs');
|
|
|
2
2
|
const require_constants = require('./utils/constants.cjs');
|
|
3
3
|
const require_hub = require('./utils/hub.cjs');
|
|
4
4
|
const require_type = require('./utils/type.cjs');
|
|
5
|
-
let
|
|
6
|
-
let
|
|
7
|
-
let
|
|
8
|
-
let
|
|
5
|
+
let _aigne_model_base = require("@aigne/model-base");
|
|
6
|
+
let _aigne_model_base_transport_base_client = require("@aigne/model-base/transport/base-client");
|
|
7
|
+
let _aigne_model_base_utils_nodejs = require("@aigne/model-base/utils/nodejs");
|
|
8
|
+
let _aigne_model_base_utils_type_utils = require("@aigne/model-base/utils/type-utils");
|
|
9
9
|
let ufo = require("ufo");
|
|
10
10
|
|
|
11
11
|
//#region src/aigne-hub-chat-model.ts
|
|
12
|
-
var AIGNEHubChatModel = class extends
|
|
12
|
+
var AIGNEHubChatModel = class extends _aigne_model_base.ChatModel {
|
|
13
13
|
constructor(options) {
|
|
14
|
-
(0,
|
|
14
|
+
(0, _aigne_model_base_utils_type_utils.checkArguments)("AIGNEHubChatModel", require_type.aigneHubModelOptionsSchema, options);
|
|
15
15
|
super();
|
|
16
16
|
this.options = options;
|
|
17
17
|
}
|
|
@@ -24,7 +24,7 @@ var AIGNEHubChatModel = class extends _aigne_core.ChatModel {
|
|
|
24
24
|
_client;
|
|
25
25
|
get client() {
|
|
26
26
|
this._client ??= this.credential.then(({ url, apiKey, model }) => {
|
|
27
|
-
return new
|
|
27
|
+
return new _aigne_model_base_transport_base_client.BaseClient({
|
|
28
28
|
...this.options,
|
|
29
29
|
url,
|
|
30
30
|
apiKey,
|
|
@@ -54,8 +54,8 @@ var AIGNEHubChatModel = class extends _aigne_core.ChatModel {
|
|
|
54
54
|
return this._credential;
|
|
55
55
|
}
|
|
56
56
|
async process(input, options) {
|
|
57
|
-
const { BLOCKLET_APP_PID, ABT_NODE_DID } =
|
|
58
|
-
const clientId = this.options?.clientOptions?.clientId || BLOCKLET_APP_PID || ABT_NODE_DID || `@aigne/aigne-hub:${typeof process !== "undefined" ?
|
|
57
|
+
const { BLOCKLET_APP_PID, ABT_NODE_DID } = _aigne_model_base_utils_nodejs.nodejs.env;
|
|
58
|
+
const clientId = this.options?.clientOptions?.clientId || BLOCKLET_APP_PID || ABT_NODE_DID || `@aigne/aigne-hub:${typeof process !== "undefined" ? _aigne_model_base_utils_nodejs.nodejs.os.hostname() : "unknown"}`;
|
|
59
59
|
return await (await this.client).__invoke(void 0, {
|
|
60
60
|
...input,
|
|
61
61
|
modelOptions: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AIGNEHubChatModelOptions } from "./utils/type.cjs";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseClient, BaseClientInvokeOptions } from "@aigne/transport/
|
|
2
|
+
import { ChatModel, ChatModelInput, ChatModelOutput, ModelInvokeOptions, ModelProcessResult } from "@aigne/model-base";
|
|
3
|
+
import { BaseClient, BaseClientInvokeOptions } from "@aigne/model-base/transport/base-client";
|
|
4
4
|
|
|
5
5
|
//#region src/aigne-hub-chat-model.d.ts
|
|
6
6
|
declare class AIGNEHubChatModel extends ChatModel {
|
|
@@ -26,7 +26,7 @@ declare class AIGNEHubChatModel extends ChatModel {
|
|
|
26
26
|
apiKey?: string;
|
|
27
27
|
model: string;
|
|
28
28
|
}>;
|
|
29
|
-
process(input: ChatModelInput, options: BaseClientInvokeOptions &
|
|
29
|
+
process(input: ChatModelInput, options: BaseClientInvokeOptions & ModelInvokeOptions): Promise<ModelProcessResult<ChatModelOutput>>;
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
export { AIGNEHubChatModel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aigne-hub-chat-model.d.cts","names":[],"sources":["../src/aigne-hub-chat-model.ts"],"mappings":";;;;;cAoBa,iBAAA,SAA0B,SAAA;
|
|
1
|
+
{"version":3,"file":"aigne-hub-chat-model.d.cts","names":[],"sources":["../src/aigne-hub-chat-model.ts"],"mappings":";;;;;cAoBa,iBAAA,SAA0B,SAAA;EACT,OAAA,EAAS,wBAAA;cAAT,OAAA,EAAS,wBAAA;EAK/B,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;YAIF,OAAA,GAAU,OAAA,CAAQ,UAAA;EAAA,IAExB,MAAA,CAAA,GAAM,OAAA,CAAA,UAAA;EAAA,QAQF,WAAA;EAAA,IAMK,UAAA,CAAA,GAAU,OAAA;;;;;EA4BR,OAAA,CACb,KAAA,EAAO,cAAA,EACP,OAAA,EAAS,uBAAA,GAA0B,kBAAA,GAClC,OAAA,CAAQ,kBAAA,CAAmB,eAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AIGNEHubChatModelOptions } from "./utils/type.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseClient, BaseClientInvokeOptions } from "@aigne/transport/
|
|
2
|
+
import { ChatModel, ChatModelInput, ChatModelOutput, ModelInvokeOptions, ModelProcessResult } from "@aigne/model-base";
|
|
3
|
+
import { BaseClient, BaseClientInvokeOptions } from "@aigne/model-base/transport/base-client";
|
|
4
4
|
|
|
5
5
|
//#region src/aigne-hub-chat-model.d.ts
|
|
6
6
|
declare class AIGNEHubChatModel extends ChatModel {
|
|
@@ -26,7 +26,7 @@ declare class AIGNEHubChatModel extends ChatModel {
|
|
|
26
26
|
apiKey?: string;
|
|
27
27
|
model: string;
|
|
28
28
|
}>;
|
|
29
|
-
process(input: ChatModelInput, options: BaseClientInvokeOptions &
|
|
29
|
+
process(input: ChatModelInput, options: BaseClientInvokeOptions & ModelInvokeOptions): Promise<ModelProcessResult<ChatModelOutput>>;
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
export { AIGNEHubChatModel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aigne-hub-chat-model.d.mts","names":[],"sources":["../src/aigne-hub-chat-model.ts"],"mappings":";;;;;cAoBa,iBAAA,SAA0B,SAAA;
|
|
1
|
+
{"version":3,"file":"aigne-hub-chat-model.d.mts","names":[],"sources":["../src/aigne-hub-chat-model.ts"],"mappings":";;;;;cAoBa,iBAAA,SAA0B,SAAA;EACT,OAAA,EAAS,wBAAA;cAAT,OAAA,EAAS,wBAAA;EAK/B,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;YAIF,OAAA,GAAU,OAAA,CAAQ,UAAA;EAAA,IAExB,MAAA,CAAA,GAAM,OAAA,CAAA,UAAA;EAAA,QAQF,WAAA;EAAA,IAMK,UAAA,CAAA,GAAU,OAAA;;;;;EA4BR,OAAA,CACb,KAAA,EAAO,cAAA,EACP,OAAA,EAAS,uBAAA,GAA0B,kBAAA,GAClC,OAAA,CAAQ,kBAAA,CAAmB,eAAA;AAAA"}
|
|
@@ -2,10 +2,10 @@ import { getAIGNEHubMountPoint } from "./utils/blocklet.mjs";
|
|
|
2
2
|
import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_DEFAULT_MODEL, aigneHubBaseUrl } from "./utils/constants.mjs";
|
|
3
3
|
import { getModels } from "./utils/hub.mjs";
|
|
4
4
|
import { aigneHubModelOptionsSchema } from "./utils/type.mjs";
|
|
5
|
-
import { ChatModel } from "@aigne/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { ChatModel } from "@aigne/model-base";
|
|
6
|
+
import { BaseClient } from "@aigne/model-base/transport/base-client";
|
|
7
|
+
import { nodejs } from "@aigne/model-base/utils/nodejs";
|
|
8
|
+
import { checkArguments } from "@aigne/model-base/utils/type-utils";
|
|
9
9
|
import { joinURL } from "ufo";
|
|
10
10
|
|
|
11
11
|
//#region src/aigne-hub-chat-model.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aigne-hub-chat-model.mjs","names":[],"sources":["../src/aigne-hub-chat-model.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"aigne-hub-chat-model.mjs","names":[],"sources":["../src/aigne-hub-chat-model.ts"],"sourcesContent":["import {\n ChatModel,\n type ChatModelInput,\n type ChatModelOutput,\n type ModelInvokeOptions,\n type ModelProcessResult,\n} from \"@aigne/model-base\";\nimport { BaseClient, type BaseClientInvokeOptions } from \"@aigne/model-base/transport/base-client\";\nimport { nodejs } from \"@aigne/model-base/utils/nodejs\";\nimport { checkArguments } from \"@aigne/model-base/utils/type-utils\";\nimport { joinURL } from \"ufo\";\nimport { getAIGNEHubMountPoint } from \"./utils/blocklet.js\";\nimport {\n AIGNE_HUB_BLOCKLET_DID,\n AIGNE_HUB_DEFAULT_MODEL,\n aigneHubBaseUrl,\n} from \"./utils/constants.js\";\nimport { getModels } from \"./utils/hub.js\";\nimport { type AIGNEHubChatModelOptions, aigneHubModelOptionsSchema } from \"./utils/type.js\";\n\nexport class AIGNEHubChatModel extends ChatModel {\n constructor(public override options: AIGNEHubChatModelOptions) {\n checkArguments(\"AIGNEHubChatModel\", aigneHubModelOptionsSchema, options);\n super();\n }\n\n async models() {\n return getModels({ baseURL: (await this.credential).url, type: \"chat\" });\n }\n\n protected _client?: Promise<BaseClient>;\n\n get client() {\n this._client ??= this.credential.then(({ url, apiKey, model }) => {\n const options = { ...this.options, url, apiKey, model };\n return new BaseClient(options);\n });\n return this._client;\n }\n\n private _credential?: Promise<{\n url: string;\n apiKey?: string;\n model: string;\n }>;\n\n override get credential() {\n this._credential ??= getAIGNEHubMountPoint(\n this.options.baseURL || aigneHubBaseUrl(),\n AIGNE_HUB_BLOCKLET_DID,\n ).then((url) => {\n const path = \"/api/v2/chat\";\n\n const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;\n let credentialOptions: Record<string, any> = {};\n try {\n credentialOptions =\n typeof rawCredential === \"string\" ? JSON.parse(rawCredential) : (rawCredential ?? {});\n } catch (err) {\n console.error(err);\n }\n\n return {\n ...credentialOptions,\n url: url.endsWith(path) ? url : joinURL(url, path),\n apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY || credentialOptions.apiKey,\n model:\n this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL || AIGNE_HUB_DEFAULT_MODEL,\n };\n });\n\n return this._credential;\n }\n\n override async process(\n input: ChatModelInput,\n options: BaseClientInvokeOptions & ModelInvokeOptions,\n ): Promise<ModelProcessResult<ChatModelOutput>> {\n const { BLOCKLET_APP_PID, ABT_NODE_DID } = nodejs.env;\n const clientId =\n this.options?.clientOptions?.clientId ||\n BLOCKLET_APP_PID ||\n ABT_NODE_DID ||\n `@aigne/aigne-hub:${typeof process !== \"undefined\" ? nodejs.os.hostname() : \"unknown\"}`;\n\n const response = await (await this.client).__invoke<ChatModelInput, ChatModelOutput>(\n undefined,\n {\n ...input,\n modelOptions: {\n ...input.modelOptions,\n model: input.modelOptions?.model || (await this.credential).model,\n },\n // Shouldn't use `local` output type for remote AIGNE Hub call, client can not access the remote filesystem\n outputFileType: \"url\",\n },\n {\n ...options,\n fetchOptions: {\n ...options.fetchOptions,\n headers: {\n ...options.fetchOptions?.headers,\n \"x-aigne-hub-client-did\": clientId,\n },\n },\n },\n );\n\n return response;\n }\n}\n"],"mappings":";;;;;;;;;;;AAoBA,IAAa,oBAAb,cAAuC,UAAU;CAC/C,YAAY,AAAgB,SAAmC;AAC7D,iBAAe,qBAAqB,4BAA4B,QAAQ;AACxE,SAAO;EAFmB;;CAK5B,MAAM,S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cAAc;KACzB,0BAA0B;KAC3B;IACF;GACF,CACF"}
|
|
@@ -2,16 +2,16 @@ const require_blocklet = require('./utils/blocklet.cjs');
|
|
|
2
2
|
const require_constants = require('./utils/constants.cjs');
|
|
3
3
|
const require_hub = require('./utils/hub.cjs');
|
|
4
4
|
const require_type = require('./utils/type.cjs');
|
|
5
|
-
let
|
|
6
|
-
let
|
|
7
|
-
let
|
|
8
|
-
let
|
|
5
|
+
let _aigne_model_base = require("@aigne/model-base");
|
|
6
|
+
let _aigne_model_base_transport_base_client = require("@aigne/model-base/transport/base-client");
|
|
7
|
+
let _aigne_model_base_utils_nodejs = require("@aigne/model-base/utils/nodejs");
|
|
8
|
+
let _aigne_model_base_utils_type_utils = require("@aigne/model-base/utils/type-utils");
|
|
9
9
|
let ufo = require("ufo");
|
|
10
10
|
|
|
11
11
|
//#region src/aigne-hub-image-model.ts
|
|
12
|
-
var AIGNEHubImageModel = class extends
|
|
12
|
+
var AIGNEHubImageModel = class extends _aigne_model_base.ImageModel {
|
|
13
13
|
constructor(options) {
|
|
14
|
-
(0,
|
|
14
|
+
(0, _aigne_model_base_utils_type_utils.checkArguments)("AIGNEHubImageModel", require_type.aigneHubModelOptionsSchema, options);
|
|
15
15
|
super();
|
|
16
16
|
this.options = options;
|
|
17
17
|
}
|
|
@@ -24,7 +24,7 @@ var AIGNEHubImageModel = class extends _aigne_core.ImageModel {
|
|
|
24
24
|
_client;
|
|
25
25
|
get client() {
|
|
26
26
|
this._client ??= this.credential.then(({ url, apiKey, model }) => {
|
|
27
|
-
return new
|
|
27
|
+
return new _aigne_model_base_transport_base_client.BaseClient({
|
|
28
28
|
...this.options,
|
|
29
29
|
url,
|
|
30
30
|
apiKey,
|
|
@@ -54,8 +54,8 @@ var AIGNEHubImageModel = class extends _aigne_core.ImageModel {
|
|
|
54
54
|
return this._credential;
|
|
55
55
|
}
|
|
56
56
|
async process(input, options) {
|
|
57
|
-
const { BLOCKLET_APP_PID, ABT_NODE_DID } =
|
|
58
|
-
const clientId = this.options?.clientOptions?.clientId || BLOCKLET_APP_PID || ABT_NODE_DID || `@aigne/aigne-hub:${typeof process !== "undefined" ?
|
|
57
|
+
const { BLOCKLET_APP_PID, ABT_NODE_DID } = _aigne_model_base_utils_nodejs.nodejs.env;
|
|
58
|
+
const clientId = this.options?.clientOptions?.clientId || BLOCKLET_APP_PID || ABT_NODE_DID || `@aigne/aigne-hub:${typeof process !== "undefined" ? _aigne_model_base_utils_nodejs.nodejs.os.hostname() : "unknown"}`;
|
|
59
59
|
const response = await (await this.client).__invoke(void 0, {
|
|
60
60
|
...input,
|
|
61
61
|
modelOptions: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AIGNEHubImageModelOptions } from "./utils/type.cjs";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseClient, BaseClientInvokeOptions } from "@aigne/transport/
|
|
2
|
+
import { ImageModel, ImageModelInput, ImageModelOutput, ModelProcessResult } from "@aigne/model-base";
|
|
3
|
+
import { BaseClient, BaseClientInvokeOptions } from "@aigne/model-base/transport/base-client";
|
|
4
4
|
|
|
5
5
|
//#region src/aigne-hub-image-model.d.ts
|
|
6
6
|
declare class AIGNEHubImageModel extends ImageModel {
|
|
@@ -26,7 +26,7 @@ declare class AIGNEHubImageModel extends ImageModel {
|
|
|
26
26
|
apiKey?: string;
|
|
27
27
|
model: string;
|
|
28
28
|
}>;
|
|
29
|
-
process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<
|
|
29
|
+
process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<ModelProcessResult<ImageModelOutput>>;
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
export { AIGNEHubImageModel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aigne-hub-image-model.d.cts","names":[],"sources":["../src/aigne-hub-image-model.ts"],"mappings":";;;;;cAmBa,kBAAA,SAA2B,UAAA;
|
|
1
|
+
{"version":3,"file":"aigne-hub-image-model.d.cts","names":[],"sources":["../src/aigne-hub-image-model.ts"],"mappings":";;;;;cAmBa,kBAAA,SAA2B,UAAA;EACV,OAAA,EAAS,yBAAA;cAAT,OAAA,EAAS,yBAAA;EAK/B,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;YAIF,OAAA,GAAU,OAAA,CAAQ,UAAA;EAAA,IAExB,MAAA,CAAA,GAAM,OAAA,CAAA,UAAA;EAAA,QAQF,WAAA;EAAA,IAMK,UAAA,CAAA,GAAU,OAAA;;;;;EA2BR,OAAA,CACb,KAAA,EAAO,eAAA,EACP,OAAA,EAAS,uBAAA,GACR,OAAA,CAAQ,kBAAA,CAAmB,gBAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AIGNEHubImageModelOptions } from "./utils/type.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseClient, BaseClientInvokeOptions } from "@aigne/transport/
|
|
2
|
+
import { ImageModel, ImageModelInput, ImageModelOutput, ModelProcessResult } from "@aigne/model-base";
|
|
3
|
+
import { BaseClient, BaseClientInvokeOptions } from "@aigne/model-base/transport/base-client";
|
|
4
4
|
|
|
5
5
|
//#region src/aigne-hub-image-model.d.ts
|
|
6
6
|
declare class AIGNEHubImageModel extends ImageModel {
|
|
@@ -26,7 +26,7 @@ declare class AIGNEHubImageModel extends ImageModel {
|
|
|
26
26
|
apiKey?: string;
|
|
27
27
|
model: string;
|
|
28
28
|
}>;
|
|
29
|
-
process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<
|
|
29
|
+
process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<ModelProcessResult<ImageModelOutput>>;
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
export { AIGNEHubImageModel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aigne-hub-image-model.d.mts","names":[],"sources":["../src/aigne-hub-image-model.ts"],"mappings":";;;;;cAmBa,kBAAA,SAA2B,UAAA;
|
|
1
|
+
{"version":3,"file":"aigne-hub-image-model.d.mts","names":[],"sources":["../src/aigne-hub-image-model.ts"],"mappings":";;;;;cAmBa,kBAAA,SAA2B,UAAA;EACV,OAAA,EAAS,yBAAA;cAAT,OAAA,EAAS,yBAAA;EAK/B,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;YAIF,OAAA,GAAU,OAAA,CAAQ,UAAA;EAAA,IAExB,MAAA,CAAA,GAAM,OAAA,CAAA,UAAA;EAAA,QAQF,WAAA;EAAA,IAMK,UAAA,CAAA,GAAU,OAAA;;;;;EA2BR,OAAA,CACb,KAAA,EAAO,eAAA,EACP,OAAA,EAAS,uBAAA,GACR,OAAA,CAAQ,kBAAA,CAAmB,gBAAA;AAAA"}
|
|
@@ -2,10 +2,10 @@ import { getAIGNEHubMountPoint } from "./utils/blocklet.mjs";
|
|
|
2
2
|
import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_IMAGE_MODEL, aigneHubBaseUrl } from "./utils/constants.mjs";
|
|
3
3
|
import { getModels } from "./utils/hub.mjs";
|
|
4
4
|
import { aigneHubModelOptionsSchema } from "./utils/type.mjs";
|
|
5
|
-
import { ImageModel } from "@aigne/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { ImageModel } from "@aigne/model-base";
|
|
6
|
+
import { BaseClient } from "@aigne/model-base/transport/base-client";
|
|
7
|
+
import { nodejs } from "@aigne/model-base/utils/nodejs";
|
|
8
|
+
import { checkArguments } from "@aigne/model-base/utils/type-utils";
|
|
9
9
|
import { joinURL } from "ufo";
|
|
10
10
|
|
|
11
11
|
//#region src/aigne-hub-image-model.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aigne-hub-image-model.mjs","names":[],"sources":["../src/aigne-hub-image-model.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"aigne-hub-image-model.mjs","names":[],"sources":["../src/aigne-hub-image-model.ts"],"sourcesContent":["import {\n ImageModel,\n type ImageModelInput,\n type ImageModelOutput,\n type ModelProcessResult,\n} from \"@aigne/model-base\";\nimport { BaseClient, type BaseClientInvokeOptions } from \"@aigne/model-base/transport/base-client\";\nimport { nodejs } from \"@aigne/model-base/utils/nodejs\";\nimport { checkArguments } from \"@aigne/model-base/utils/type-utils\";\nimport { joinURL } from \"ufo\";\nimport { getAIGNEHubMountPoint } from \"./utils/blocklet.js\";\nimport {\n AIGNE_HUB_BLOCKLET_DID,\n AIGNE_HUB_IMAGE_MODEL,\n aigneHubBaseUrl,\n} from \"./utils/constants.js\";\nimport { getModels } from \"./utils/hub.js\";\nimport { type AIGNEHubImageModelOptions, aigneHubModelOptionsSchema } from \"./utils/type.js\";\n\nexport class AIGNEHubImageModel extends ImageModel {\n constructor(public override options: AIGNEHubImageModelOptions) {\n checkArguments(\"AIGNEHubImageModel\", aigneHubModelOptionsSchema, options);\n super();\n }\n\n async models() {\n return getModels({ baseURL: (await this.credential).url, type: \"image\" });\n }\n\n protected _client?: Promise<BaseClient>;\n\n get client() {\n this._client ??= this.credential.then(({ url, apiKey, model }) => {\n const options = { ...this.options, url, apiKey, model };\n return new BaseClient(options);\n });\n return this._client;\n }\n\n private _credential?: Promise<{\n url: string;\n apiKey?: string;\n model: string;\n }>;\n\n override get credential() {\n this._credential ??= getAIGNEHubMountPoint(\n this.options.baseURL || aigneHubBaseUrl(),\n AIGNE_HUB_BLOCKLET_DID,\n ).then((url) => {\n const path = \"/api/v2/image\";\n\n const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;\n let credentialOptions: Record<string, any> = {};\n try {\n credentialOptions =\n typeof rawCredential === \"string\" ? JSON.parse(rawCredential) : (rawCredential ?? {});\n } catch (err) {\n console.error(err);\n }\n\n return {\n ...credentialOptions,\n url: url.endsWith(path) ? url : joinURL(url, path),\n apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY || credentialOptions.apiKey,\n model: this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL || AIGNE_HUB_IMAGE_MODEL,\n };\n });\n\n return this._credential;\n }\n\n override async process(\n input: ImageModelInput,\n options: BaseClientInvokeOptions,\n ): Promise<ModelProcessResult<ImageModelOutput>> {\n const { BLOCKLET_APP_PID, ABT_NODE_DID } = nodejs.env;\n const clientId =\n this.options?.clientOptions?.clientId ||\n BLOCKLET_APP_PID ||\n ABT_NODE_DID ||\n `@aigne/aigne-hub:${typeof process !== \"undefined\" ? nodejs.os.hostname() : \"unknown\"}`;\n\n const response = await (await this.client).__invoke<ImageModelInput, ImageModelOutput>(\n undefined,\n {\n ...input,\n modelOptions: {\n ...input.modelOptions,\n model: input.modelOptions?.model || (await this.credential).model,\n },\n // Shouldn't use `local` output type for remote AIGNE Hub call, client can not access the remote filesystem\n outputFileType: \"url\",\n },\n {\n ...options,\n streaming: false,\n fetchOptions: {\n ...options.fetchOptions,\n headers: {\n ...options.fetchOptions?.headers,\n \"x-aigne-hub-client-did\": clientId,\n },\n },\n },\n );\n\n return {\n ...response,\n images: response.images,\n usage: {\n inputTokens: response.usage?.inputTokens ?? 0,\n outputTokens: response.usage?.outputTokens ?? 0,\n ...response.usage,\n },\n model: response?.model,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AAmBA,IAAa,qBAAb,cAAwC,WAAW;CACjD,YAAY,AAAgB,SAAoC;AAC9D,iBAAe,sBAAsB,4BAA4B,QAAQ;AACzE,SAAO;EAFmB;;CAK5B,MAAM,SAAS;AACb,SAAO,UAAU;GAAE,UAAU,MAAM,KAAK,YAAY;GAAK,MAAM;GAAS,CAAC;;CAG3E,AAAU;CAEV,IAAI,SAAS;AACX,OAAK,YAAY,KAAK,WAAW,MAAM,EAAE,KAAK,QAAQ,YAAY;AAEhE,UAAO,IAAI,WADK;IAAE,GAAG,KAAK;IAAS;IAAK;IAAQ;IAAO,CACzB;IAC9B;AACF,SAAO,KAAK;;CAGd,AAAQ;CAMR,IAAa,aAAa;AACxB,OAAK,gBAAgB,sBACnB,KAAK,QAAQ,WAAW,iBAAiB,EACzC,uBACD,CAAC,MAAM,QAAQ;GACd,MAAM,OAAO;GAEb,MAAM,gBAAgB,QAAQ,IAAI;GAClC,IAAI,oBAAyC,EAAE;AAC/C,OAAI;AACF,wBACE,OAAO,kBAAkB,WAAW,KAAK,MAAM,cAAc,GAAI,iBAAiB,EAAE;YAC/E,KAAK;AACZ,YAAQ,MAAM,IAAI;;AAGpB,UAAO;IACL,GAAG;IACH,KAAK,IAAI,SAAS,KAAK,GAAG,MAAM,QAAQ,KAAK,KAAK;IAClD,QAAQ,KAAK,QAAQ,UAAU,QAAQ,IAAI,qBAAqB,kBAAkB;IAClF,OAAO,KAAK,QAAQ,SAAS,QAAQ,IAAI,4BAA4B;IACtE;IACD;AAEF,SAAO,KAAK;;CAGd,MAAe,QACb,OACA,SAC+C;EAC/C,MAAM,EAAE,kBAAkB,iBAAiB,OAAO;EAClD,MAAM,WACJ,KAAK,SAAS,eAAe,YAC7B,oBACA,gBACA,oBAAoB,OAAO,YAAY,cAAc,OAAO,GAAG,UAAU,GAAG;EAE9E,MAAM,WAAW,OAAO,MAAM,KAAK,QAAQ,SACzC,QACA;GACE,GAAG;GACH,cAAc;IACZ,GAAG,MAAM;IACT,OAAO,MAAM,cAAc,UAAU,MAAM,KAAK,YAAY;IAC7D;GAED,gBAAgB;GACjB,EACD;GACE,GAAG;GACH,WAAW;GACX,cAAc;IACZ,GAAG,QAAQ;IACX,SAAS;KACP,GAAG,QAAQ,cAAc;KACzB,0BAA0B;KAC3B;IACF;GACF,CACF;AAED,SAAO;GACL,GAAG;GACH,QAAQ,SAAS;GACjB,OAAO;IACL,aAAa,SAAS,OAAO,eAAe;IAC5C,cAAc,SAAS,OAAO,gBAAgB;IAC9C,GAAG,SAAS;IACb;GACD,OAAO,UAAU;GAClB"}
|
|
@@ -2,16 +2,16 @@ const require_blocklet = require('./utils/blocklet.cjs');
|
|
|
2
2
|
const require_constants = require('./utils/constants.cjs');
|
|
3
3
|
const require_hub = require('./utils/hub.cjs');
|
|
4
4
|
const require_type = require('./utils/type.cjs');
|
|
5
|
-
let
|
|
6
|
-
let
|
|
7
|
-
let
|
|
8
|
-
let
|
|
5
|
+
let _aigne_model_base = require("@aigne/model-base");
|
|
6
|
+
let _aigne_model_base_transport_base_client = require("@aigne/model-base/transport/base-client");
|
|
7
|
+
let _aigne_model_base_utils_nodejs = require("@aigne/model-base/utils/nodejs");
|
|
8
|
+
let _aigne_model_base_utils_type_utils = require("@aigne/model-base/utils/type-utils");
|
|
9
9
|
let ufo = require("ufo");
|
|
10
10
|
|
|
11
11
|
//#region src/aigne-hub-video-model.ts
|
|
12
|
-
var AIGNEHubVideoModel = class extends
|
|
12
|
+
var AIGNEHubVideoModel = class extends _aigne_model_base.VideoModel {
|
|
13
13
|
constructor(options) {
|
|
14
|
-
(0,
|
|
14
|
+
(0, _aigne_model_base_utils_type_utils.checkArguments)("AIGNEHubVideoModel", require_type.aigneHubModelOptionsSchema, options);
|
|
15
15
|
super();
|
|
16
16
|
this.options = options;
|
|
17
17
|
}
|
|
@@ -24,7 +24,7 @@ var AIGNEHubVideoModel = class extends _aigne_core.VideoModel {
|
|
|
24
24
|
_client;
|
|
25
25
|
get client() {
|
|
26
26
|
this._client ??= this.credential.then(({ url, apiKey, model }) => {
|
|
27
|
-
return new
|
|
27
|
+
return new _aigne_model_base_transport_base_client.BaseClient({
|
|
28
28
|
...this.options,
|
|
29
29
|
url,
|
|
30
30
|
apiKey,
|
|
@@ -54,8 +54,8 @@ var AIGNEHubVideoModel = class extends _aigne_core.VideoModel {
|
|
|
54
54
|
return this._credential;
|
|
55
55
|
}
|
|
56
56
|
async process(input, options) {
|
|
57
|
-
const { BLOCKLET_APP_PID, ABT_NODE_DID } =
|
|
58
|
-
const clientId = this.options?.clientOptions?.clientId || BLOCKLET_APP_PID || ABT_NODE_DID || `@aigne/aigne-hub:${typeof process !== "undefined" ?
|
|
57
|
+
const { BLOCKLET_APP_PID, ABT_NODE_DID } = _aigne_model_base_utils_nodejs.nodejs.env;
|
|
58
|
+
const clientId = this.options?.clientOptions?.clientId || BLOCKLET_APP_PID || ABT_NODE_DID || `@aigne/aigne-hub:${typeof process !== "undefined" ? _aigne_model_base_utils_nodejs.nodejs.os.hostname() : "unknown"}`;
|
|
59
59
|
const model = input.model || input.modelOptions?.model || (await this.credential).model;
|
|
60
60
|
const response = await (await this.client).__invoke(void 0, {
|
|
61
61
|
...input,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AIGNEHubVideoModelOptions } from "./utils/type.cjs";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseClient, BaseClientInvokeOptions } from "@aigne/transport/
|
|
2
|
+
import { ModelProcessResult, VideoModel, VideoModelInput, VideoModelOutput } from "@aigne/model-base";
|
|
3
|
+
import { BaseClient, BaseClientInvokeOptions } from "@aigne/model-base/transport/base-client";
|
|
4
4
|
|
|
5
5
|
//#region src/aigne-hub-video-model.d.ts
|
|
6
6
|
declare class AIGNEHubVideoModel extends VideoModel {
|
|
@@ -26,7 +26,7 @@ declare class AIGNEHubVideoModel extends VideoModel {
|
|
|
26
26
|
apiKey?: string;
|
|
27
27
|
model: string;
|
|
28
28
|
}>;
|
|
29
|
-
process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<
|
|
29
|
+
process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<ModelProcessResult<VideoModelOutput>>;
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
export { AIGNEHubVideoModel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aigne-hub-video-model.d.cts","names":[],"sources":["../src/aigne-hub-video-model.ts"],"mappings":";;;;;cAmBa,kBAAA,SAA2B,UAAA;
|
|
1
|
+
{"version":3,"file":"aigne-hub-video-model.d.cts","names":[],"sources":["../src/aigne-hub-video-model.ts"],"mappings":";;;;;cAmBa,kBAAA,SAA2B,UAAA;EACV,OAAA,EAAS,yBAAA;cAAT,OAAA,EAAS,yBAAA;EAK/B,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;YAIF,OAAA,GAAU,OAAA,CAAQ,UAAA;EAAA,IAExB,MAAA,CAAA,GAAM,OAAA,CAAA,UAAA;EAAA,QAQF,WAAA;EAAA,IAMK,UAAA,CAAA,GAAU,OAAA;;;;;EA2BR,OAAA,CACb,KAAA,EAAO,eAAA,EACP,OAAA,EAAS,uBAAA,GACR,OAAA,CAAQ,kBAAA,CAAmB,gBAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AIGNEHubVideoModelOptions } from "./utils/type.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseClient, BaseClientInvokeOptions } from "@aigne/transport/
|
|
2
|
+
import { ModelProcessResult, VideoModel, VideoModelInput, VideoModelOutput } from "@aigne/model-base";
|
|
3
|
+
import { BaseClient, BaseClientInvokeOptions } from "@aigne/model-base/transport/base-client";
|
|
4
4
|
|
|
5
5
|
//#region src/aigne-hub-video-model.d.ts
|
|
6
6
|
declare class AIGNEHubVideoModel extends VideoModel {
|
|
@@ -26,7 +26,7 @@ declare class AIGNEHubVideoModel extends VideoModel {
|
|
|
26
26
|
apiKey?: string;
|
|
27
27
|
model: string;
|
|
28
28
|
}>;
|
|
29
|
-
process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<
|
|
29
|
+
process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<ModelProcessResult<VideoModelOutput>>;
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
export { AIGNEHubVideoModel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aigne-hub-video-model.d.mts","names":[],"sources":["../src/aigne-hub-video-model.ts"],"mappings":";;;;;cAmBa,kBAAA,SAA2B,UAAA;
|
|
1
|
+
{"version":3,"file":"aigne-hub-video-model.d.mts","names":[],"sources":["../src/aigne-hub-video-model.ts"],"mappings":";;;;;cAmBa,kBAAA,SAA2B,UAAA;EACV,OAAA,EAAS,yBAAA;cAAT,OAAA,EAAS,yBAAA;EAK/B,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;YAIF,OAAA,GAAU,OAAA,CAAQ,UAAA;EAAA,IAExB,MAAA,CAAA,GAAM,OAAA,CAAA,UAAA;EAAA,QAQF,WAAA;EAAA,IAMK,UAAA,CAAA,GAAU,OAAA;;;;;EA2BR,OAAA,CACb,KAAA,EAAO,eAAA,EACP,OAAA,EAAS,uBAAA,GACR,OAAA,CAAQ,kBAAA,CAAmB,gBAAA;AAAA"}
|
|
@@ -2,10 +2,10 @@ import { getAIGNEHubMountPoint } from "./utils/blocklet.mjs";
|
|
|
2
2
|
import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_VIDEO_MODEL, aigneHubBaseUrl } from "./utils/constants.mjs";
|
|
3
3
|
import { getModels } from "./utils/hub.mjs";
|
|
4
4
|
import { aigneHubModelOptionsSchema } from "./utils/type.mjs";
|
|
5
|
-
import { VideoModel } from "@aigne/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { VideoModel } from "@aigne/model-base";
|
|
6
|
+
import { BaseClient } from "@aigne/model-base/transport/base-client";
|
|
7
|
+
import { nodejs } from "@aigne/model-base/utils/nodejs";
|
|
8
|
+
import { checkArguments } from "@aigne/model-base/utils/type-utils";
|
|
9
9
|
import { joinURL } from "ufo";
|
|
10
10
|
|
|
11
11
|
//#region src/aigne-hub-video-model.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aigne-hub-video-model.mjs","names":[],"sources":["../src/aigne-hub-video-model.ts"],"sourcesContent":["import {\n type
|
|
1
|
+
{"version":3,"file":"aigne-hub-video-model.mjs","names":[],"sources":["../src/aigne-hub-video-model.ts"],"sourcesContent":["import {\n type ModelProcessResult,\n VideoModel,\n type VideoModelInput,\n type VideoModelOutput,\n} from \"@aigne/model-base\";\nimport { BaseClient, type BaseClientInvokeOptions } from \"@aigne/model-base/transport/base-client\";\nimport { nodejs } from \"@aigne/model-base/utils/nodejs\";\nimport { checkArguments } from \"@aigne/model-base/utils/type-utils\";\nimport { joinURL } from \"ufo\";\nimport { getAIGNEHubMountPoint } from \"./utils/blocklet.js\";\nimport {\n AIGNE_HUB_BLOCKLET_DID,\n AIGNE_HUB_VIDEO_MODEL,\n aigneHubBaseUrl,\n} from \"./utils/constants.js\";\nimport { getModels } from \"./utils/hub.js\";\nimport { type AIGNEHubVideoModelOptions, aigneHubModelOptionsSchema } from \"./utils/type.js\";\n\nexport class AIGNEHubVideoModel extends VideoModel {\n constructor(public override options: AIGNEHubVideoModelOptions) {\n checkArguments(\"AIGNEHubVideoModel\", aigneHubModelOptionsSchema, options);\n super();\n }\n\n async models() {\n return getModels({ baseURL: (await this.credential).url, type: \"video\" });\n }\n\n protected _client?: Promise<BaseClient>;\n\n get client() {\n this._client ??= this.credential.then(({ url, apiKey, model }) => {\n const options = { ...this.options, url, apiKey, model };\n return new BaseClient(options);\n });\n return this._client;\n }\n\n private _credential?: Promise<{\n url: string;\n apiKey?: string;\n model: string;\n }>;\n\n override get credential() {\n this._credential ??= getAIGNEHubMountPoint(\n this.options.baseURL || aigneHubBaseUrl(),\n AIGNE_HUB_BLOCKLET_DID,\n ).then((url) => {\n const path = \"/api/v2/video\";\n\n const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;\n let credentialOptions: Record<string, any> = {};\n try {\n credentialOptions =\n typeof rawCredential === \"string\" ? JSON.parse(rawCredential) : (rawCredential ?? {});\n } catch (err) {\n console.error(err);\n }\n\n return {\n ...credentialOptions,\n url: url.endsWith(path) ? url : joinURL(url, path),\n apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY || credentialOptions.apiKey,\n model: this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL || AIGNE_HUB_VIDEO_MODEL,\n };\n });\n\n return this._credential;\n }\n\n override async process(\n input: VideoModelInput,\n options: BaseClientInvokeOptions,\n ): Promise<ModelProcessResult<VideoModelOutput>> {\n const { BLOCKLET_APP_PID, ABT_NODE_DID } = nodejs.env;\n const clientId =\n this.options?.clientOptions?.clientId ||\n BLOCKLET_APP_PID ||\n ABT_NODE_DID ||\n `@aigne/aigne-hub:${typeof process !== \"undefined\" ? nodejs.os.hostname() : \"unknown\"}`;\n const model = input.model || input.modelOptions?.model || (await this.credential).model;\n\n const response = await (await this.client).__invoke<VideoModelInput, VideoModelOutput>(\n undefined,\n {\n ...input,\n model: model,\n modelOptions: { ...this.options.modelOptions, ...input.modelOptions, model: model },\n outputFileType: \"url\",\n },\n {\n ...options,\n streaming: false,\n fetchOptions: {\n ...options.fetchOptions,\n timeout: 60e3 * 3,\n headers: {\n ...options.fetchOptions?.headers,\n \"x-aigne-hub-client-did\": clientId,\n },\n },\n },\n );\n\n return {\n ...response,\n videos: response.videos,\n usage: {\n inputTokens: response.usage?.inputTokens ?? 0,\n outputTokens: response.usage?.outputTokens ?? 0,\n ...response.usage,\n },\n model: response?.model,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AAmBA,IAAa,qBAAb,cAAwC,WAAW;CACjD,YAAY,AAAgB,SAAoC;AAC9D,iBAAe,sBAAsB,4BAA4B,QAAQ;AACzE,SAAO;EAFmB;;CAK5B,MAAM,SAAS;AACb,SAAO,UAAU;GAAE,UAAU,MAAM,KAAK,YAAY;GAAK,MAAM;GAAS,CAAC;;CAG3E,AAAU;CAEV,IAAI,SAAS;AACX,OAAK,YAAY,KAAK,WAAW,MAAM,EAAE,KAAK,QAAQ,YAAY;AAEhE,UAAO,IAAI,WADK;IAAE,GAAG,KAAK;IAAS;IAAK;IAAQ;IAAO,CACzB;IAC9B;AACF,SAAO,KAAK;;CAGd,AAAQ;CAMR,IAAa,aAAa;AACxB,OAAK,gBAAgB,sBACnB,KAAK,QAAQ,WAAW,iBAAiB,EACzC,uBACD,CAAC,MAAM,QAAQ;GACd,MAAM,OAAO;GAEb,MAAM,gBAAgB,QAAQ,IAAI;GAClC,IAAI,oBAAyC,EAAE;AAC/C,OAAI;AACF,wBACE,OAAO,kBAAkB,WAAW,KAAK,MAAM,cAAc,GAAI,iBAAiB,EAAE;YAC/E,KAAK;AACZ,YAAQ,MAAM,IAAI;;AAGpB,UAAO;IACL,GAAG;IACH,KAAK,IAAI,SAAS,KAAK,GAAG,MAAM,QAAQ,KAAK,KAAK;IAClD,QAAQ,KAAK,QAAQ,UAAU,QAAQ,IAAI,qBAAqB,kBAAkB;IAClF,OAAO,KAAK,QAAQ,SAAS,QAAQ,IAAI,4BAA4B;IACtE;IACD;AAEF,SAAO,KAAK;;CAGd,MAAe,QACb,OACA,SAC+C;EAC/C,MAAM,EAAE,kBAAkB,iBAAiB,OAAO;EAClD,MAAM,WACJ,KAAK,SAAS,eAAe,YAC7B,oBACA,gBACA,oBAAoB,OAAO,YAAY,cAAc,OAAO,GAAG,UAAU,GAAG;EAC9E,MAAM,QAAQ,MAAM,SAAS,MAAM,cAAc,UAAU,MAAM,KAAK,YAAY;EAElF,MAAM,WAAW,OAAO,MAAM,KAAK,QAAQ,SACzC,QACA;GACE,GAAG;GACI;GACP,cAAc;IAAE,GAAG,KAAK,QAAQ;IAAc,GAAG,MAAM;IAAqB;IAAO;GACnF,gBAAgB;GACjB,EACD;GACE,GAAG;GACH,WAAW;GACX,cAAc;IACZ,GAAG,QAAQ;IACX,SAAS,MAAO;IAChB,SAAS;KACP,GAAG,QAAQ,cAAc;KACzB,0BAA0B;KAC3B;IACF;GACF,CACF;AAED,SAAO;GACL,GAAG;GACH,QAAQ,SAAS;GACjB,OAAO;IACL,aAAa,SAAS,OAAO,eAAe;IAC5C,cAAc,SAAS,OAAO,gBAAgB;IAC9C,GAAG,SAAS;IACb;GACD,OAAO,UAAU;GAClB"}
|
package/dist/index.cjs
CHANGED
|
@@ -3,10 +3,10 @@ const require_constants = require('./utils/constants.cjs');
|
|
|
3
3
|
const require_hub = require('./utils/hub.cjs');
|
|
4
4
|
const require_model = require('./utils/model.cjs');
|
|
5
5
|
const require_find_provider = require('./utils/find-provider.cjs');
|
|
6
|
-
let
|
|
6
|
+
let _aigne_model_base = require("@aigne/model-base");
|
|
7
7
|
|
|
8
8
|
//#region src/index.ts
|
|
9
|
-
var AIGNEHubChatModel = class AIGNEHubChatModel extends
|
|
9
|
+
var AIGNEHubChatModel = class AIGNEHubChatModel extends _aigne_model_base.ChatModel {
|
|
10
10
|
static async models() {
|
|
11
11
|
return require_hub.getModels({ type: "chat" });
|
|
12
12
|
}
|
|
@@ -41,7 +41,7 @@ var AIGNEHubChatModel = class AIGNEHubChatModel extends _aigne_core.ChatModel {
|
|
|
41
41
|
return this.client.invoke(input, options);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
var AIGNEHubImageModel = class AIGNEHubImageModel extends
|
|
44
|
+
var AIGNEHubImageModel = class AIGNEHubImageModel extends _aigne_model_base.ImageModel {
|
|
45
45
|
static async models() {
|
|
46
46
|
return require_hub.getModels({ type: "image" });
|
|
47
47
|
}
|
|
@@ -76,7 +76,7 @@ var AIGNEHubImageModel = class AIGNEHubImageModel extends _aigne_core.ImageModel
|
|
|
76
76
|
return this.client.invoke(input, options);
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
var AIGNEHubVideoModel = class AIGNEHubVideoModel extends
|
|
79
|
+
var AIGNEHubVideoModel = class AIGNEHubVideoModel extends _aigne_model_base.VideoModel {
|
|
80
80
|
static async models() {
|
|
81
81
|
return require_hub.getModels({ type: "video" });
|
|
82
82
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -3,9 +3,9 @@ import { getAIGNEHubMountPoint } from "./utils/blocklet.cjs";
|
|
|
3
3
|
import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_DEFAULT_MODEL, AIGNE_HUB_IMAGE_MODEL, AIGNE_HUB_PROVIDER, AIGNE_HUB_URL, AIGNE_HUB_VIDEO_MODEL, AIProviderType, AI_PROVIDERS, PROVIDER_RANK, aigneHubBaseUrl } from "./utils/constants.cjs";
|
|
4
4
|
import { getDefaultProviderForModel, getSupportedProviders, inferVendorFromModel, resolveProviderModelId } from "./utils/find-provider.cjs";
|
|
5
5
|
import { LoadableImageModel, LoadableModel, LoadableVideoModel, availableImageModels, availableModels, availableVideoModels, findImageModel, findModel, findVideoModel, parseModel } from "./utils/model.cjs";
|
|
6
|
-
import {
|
|
7
|
-
import { BaseClientInvokeOptions } from "@aigne/transport/
|
|
8
|
-
import * as
|
|
6
|
+
import { ChatModel, ChatModelInput, ChatModelOutput, ImageModel, ImageModelInput, ImageModelOutput, ModelProcessResult, VideoModel, VideoModelInput, VideoModelOutput } from "@aigne/model-base";
|
|
7
|
+
import { BaseClientInvokeOptions } from "@aigne/model-base/transport/base-client";
|
|
8
|
+
import * as _aigne_model_base_utils_type_utils0 from "@aigne/model-base/utils/type-utils";
|
|
9
9
|
|
|
10
10
|
//#region src/index.d.ts
|
|
11
11
|
declare class AIGNEHubChatModel extends ChatModel {
|
|
@@ -36,12 +36,12 @@ declare class AIGNEHubChatModel extends ChatModel {
|
|
|
36
36
|
}[]>;
|
|
37
37
|
constructor(options: AIGNEHubChatModelOptions);
|
|
38
38
|
protected client: ChatModel;
|
|
39
|
-
get credential():
|
|
39
|
+
get credential(): _aigne_model_base_utils_type_utils0.PromiseOrValue<{
|
|
40
40
|
url?: string;
|
|
41
41
|
apiKey?: string;
|
|
42
42
|
model?: string;
|
|
43
43
|
}>;
|
|
44
|
-
process(input: ChatModelInput, options: BaseClientInvokeOptions): Promise<
|
|
44
|
+
process(input: ChatModelInput, options: BaseClientInvokeOptions): Promise<ModelProcessResult<ChatModelOutput>>;
|
|
45
45
|
}
|
|
46
46
|
declare class AIGNEHubImageModel extends ImageModel {
|
|
47
47
|
options: AIGNEHubImageModelOptions;
|
|
@@ -71,12 +71,12 @@ declare class AIGNEHubImageModel extends ImageModel {
|
|
|
71
71
|
}[]>;
|
|
72
72
|
constructor(options: AIGNEHubImageModelOptions);
|
|
73
73
|
protected client: ImageModel;
|
|
74
|
-
get credential():
|
|
74
|
+
get credential(): _aigne_model_base_utils_type_utils0.PromiseOrValue<{
|
|
75
75
|
url?: string;
|
|
76
76
|
apiKey?: string;
|
|
77
77
|
model?: string;
|
|
78
78
|
}>;
|
|
79
|
-
process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<
|
|
79
|
+
process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<ModelProcessResult<ImageModelOutput>>;
|
|
80
80
|
}
|
|
81
81
|
declare class AIGNEHubVideoModel extends VideoModel {
|
|
82
82
|
options: AIGNEHubVideoModelOptions;
|
|
@@ -106,12 +106,12 @@ declare class AIGNEHubVideoModel extends VideoModel {
|
|
|
106
106
|
}[]>;
|
|
107
107
|
constructor(options: AIGNEHubVideoModelOptions);
|
|
108
108
|
protected client: VideoModel;
|
|
109
|
-
get credential():
|
|
109
|
+
get credential(): _aigne_model_base_utils_type_utils0.PromiseOrValue<{
|
|
110
110
|
url?: string;
|
|
111
111
|
apiKey?: string;
|
|
112
112
|
model?: string;
|
|
113
113
|
}>;
|
|
114
|
-
process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<
|
|
114
|
+
process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<ModelProcessResult<VideoModelOutput>>;
|
|
115
115
|
}
|
|
116
116
|
//#endregion
|
|
117
117
|
export { AIGNEHubChatModel, AIGNEHubImageModel, AIGNEHubVideoModel, AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_DEFAULT_MODEL, AIGNE_HUB_IMAGE_MODEL, AIGNE_HUB_PROVIDER, AIGNE_HUB_URL, AIGNE_HUB_VIDEO_MODEL, AIProviderType, AI_PROVIDERS, LoadableImageModel, LoadableModel, LoadableVideoModel, PROVIDER_RANK, aigneHubBaseUrl, availableImageModels, availableModels, availableVideoModels, findImageModel, findModel, findVideoModel, getAIGNEHubMountPoint, getDefaultProviderForModel, getSupportedProviders, inferVendorFromModel, parseModel, resolveProviderModelId };
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"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;AAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -3,9 +3,9 @@ import { getAIGNEHubMountPoint } from "./utils/blocklet.mjs";
|
|
|
3
3
|
import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_DEFAULT_MODEL, AIGNE_HUB_IMAGE_MODEL, AIGNE_HUB_PROVIDER, AIGNE_HUB_URL, AIGNE_HUB_VIDEO_MODEL, AIProviderType, AI_PROVIDERS, PROVIDER_RANK, aigneHubBaseUrl } from "./utils/constants.mjs";
|
|
4
4
|
import { getDefaultProviderForModel, getSupportedProviders, inferVendorFromModel, resolveProviderModelId } from "./utils/find-provider.mjs";
|
|
5
5
|
import { LoadableImageModel, LoadableModel, LoadableVideoModel, availableImageModels, availableModels, availableVideoModels, findImageModel, findModel, findVideoModel, parseModel } from "./utils/model.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import { ChatModel, ChatModelInput, ChatModelOutput, ImageModel, ImageModelInput, ImageModelOutput, ModelProcessResult, VideoModel, VideoModelInput, VideoModelOutput } from "@aigne/model-base";
|
|
7
|
+
import { BaseClientInvokeOptions } from "@aigne/model-base/transport/base-client";
|
|
8
|
+
import * as _aigne_model_base_utils_type_utils0 from "@aigne/model-base/utils/type-utils";
|
|
9
9
|
|
|
10
10
|
//#region src/index.d.ts
|
|
11
11
|
declare class AIGNEHubChatModel extends ChatModel {
|
|
@@ -36,12 +36,12 @@ declare class AIGNEHubChatModel extends ChatModel {
|
|
|
36
36
|
}[]>;
|
|
37
37
|
constructor(options: AIGNEHubChatModelOptions);
|
|
38
38
|
protected client: ChatModel;
|
|
39
|
-
get credential():
|
|
39
|
+
get credential(): _aigne_model_base_utils_type_utils0.PromiseOrValue<{
|
|
40
40
|
url?: string;
|
|
41
41
|
apiKey?: string;
|
|
42
42
|
model?: string;
|
|
43
43
|
}>;
|
|
44
|
-
process(input: ChatModelInput, options: BaseClientInvokeOptions): Promise<
|
|
44
|
+
process(input: ChatModelInput, options: BaseClientInvokeOptions): Promise<ModelProcessResult<ChatModelOutput>>;
|
|
45
45
|
}
|
|
46
46
|
declare class AIGNEHubImageModel extends ImageModel {
|
|
47
47
|
options: AIGNEHubImageModelOptions;
|
|
@@ -71,12 +71,12 @@ declare class AIGNEHubImageModel extends ImageModel {
|
|
|
71
71
|
}[]>;
|
|
72
72
|
constructor(options: AIGNEHubImageModelOptions);
|
|
73
73
|
protected client: ImageModel;
|
|
74
|
-
get credential():
|
|
74
|
+
get credential(): _aigne_model_base_utils_type_utils0.PromiseOrValue<{
|
|
75
75
|
url?: string;
|
|
76
76
|
apiKey?: string;
|
|
77
77
|
model?: string;
|
|
78
78
|
}>;
|
|
79
|
-
process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<
|
|
79
|
+
process(input: ImageModelInput, options: BaseClientInvokeOptions): Promise<ModelProcessResult<ImageModelOutput>>;
|
|
80
80
|
}
|
|
81
81
|
declare class AIGNEHubVideoModel extends VideoModel {
|
|
82
82
|
options: AIGNEHubVideoModelOptions;
|
|
@@ -106,12 +106,12 @@ declare class AIGNEHubVideoModel extends VideoModel {
|
|
|
106
106
|
}[]>;
|
|
107
107
|
constructor(options: AIGNEHubVideoModelOptions);
|
|
108
108
|
protected client: VideoModel;
|
|
109
|
-
get credential():
|
|
109
|
+
get credential(): _aigne_model_base_utils_type_utils0.PromiseOrValue<{
|
|
110
110
|
url?: string;
|
|
111
111
|
apiKey?: string;
|
|
112
112
|
model?: string;
|
|
113
113
|
}>;
|
|
114
|
-
process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<
|
|
114
|
+
process(input: VideoModelInput, options: BaseClientInvokeOptions): Promise<ModelProcessResult<VideoModelOutput>>;
|
|
115
115
|
}
|
|
116
116
|
//#endregion
|
|
117
117
|
export { AIGNEHubChatModel, AIGNEHubImageModel, AIGNEHubVideoModel, AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_DEFAULT_MODEL, AIGNE_HUB_IMAGE_MODEL, AIGNE_HUB_PROVIDER, AIGNE_HUB_URL, AIGNE_HUB_VIDEO_MODEL, AIProviderType, AI_PROVIDERS, LoadableImageModel, LoadableModel, LoadableVideoModel, PROVIDER_RANK, aigneHubBaseUrl, availableImageModels, availableModels, availableVideoModels, findImageModel, findModel, findVideoModel, getAIGNEHubMountPoint, getDefaultProviderForModel, getSupportedProviders, inferVendorFromModel, parseModel, resolveProviderModelId };
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;cA2Ba,iBAAA,SAA0B,SAAA;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;cA2Ba,iBAAA,SAA0B,SAAA;EAST,OAAA,EAAS,wBAAA;EAAA,OARxB,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;EAInB,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;cAIsB,OAAA,EAAS,wBAAA;EAAA,UA6B3B,MAAA,EAAQ,SAAA;EAAA,IAEL,UAAA,CAAA,GAFc,mCAAA,CAEJ,cAAA;;;;;EAIR,OAAA,CACb,KAAA,EAAO,cAAA,EACP,OAAA,EAAS,uBAAA,GACR,OAAA,CAAQ,kBAAA,CAAmB,eAAA;AAAA;AAAA,cAKnB,kBAAA,SAA2B,UAAA;EASV,OAAA,EAAS,yBAAA;EAAA,OARxB,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;EAInB,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;cAIsB,OAAA,EAAS,yBAAA;EAAA,UA6B3B,MAAA,EAAQ,UAAA;EAAA,IAEL,UAAA,CAAA,GAFe,mCAAA,CAEL,cAAA;;;;;EAIR,OAAA,CACb,KAAA,EAAO,eAAA,EACP,OAAA,EAAS,uBAAA,GACR,OAAA,CAAQ,kBAAA,CAAmB,gBAAA;AAAA;AAAA,cAKnB,kBAAA,SAA2B,UAAA;EASV,OAAA,EAAS,yBAAA;EAAA,OARxB,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;EAInB,MAAA,CAAA,GAAM,OAAA;;;;;;;;;;;;cAIsB,OAAA,EAAS,yBAAA;EAAA,UA6B3B,MAAA,EAAQ,UAAA;EAAA,IAEL,UAAA,CAAA,GAFe,mCAAA,CAEL,cAAA;;;;;EAIR,OAAA,CACb,KAAA,EAAO,eAAA,EACP,OAAA,EAAS,uBAAA,GACR,OAAA,CAAQ,kBAAA,CAAmB,gBAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { AIGNE_HUB_BLOCKLET_DID, AIGNE_HUB_DEFAULT_MODEL, AIGNE_HUB_IMAGE_MODEL,
|
|
|
3
3
|
import { getModels } from "./utils/hub.mjs";
|
|
4
4
|
import { availableImageModels, availableModels, availableVideoModels, findImageModel, findModel, findVideoModel, parseModel } from "./utils/model.mjs";
|
|
5
5
|
import { getDefaultProviderForModel, getSupportedProviders, inferVendorFromModel, resolveProviderModelId } from "./utils/find-provider.mjs";
|
|
6
|
-
import { ChatModel, ImageModel, VideoModel } from "@aigne/
|
|
6
|
+
import { ChatModel, ImageModel, VideoModel } from "@aigne/model-base";
|
|
7
7
|
|
|
8
8
|
//#region src/index.ts
|
|
9
9
|
var AIGNEHubChatModel = class AIGNEHubChatModel extends ChatModel {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n ChatModel,\n type ChatModelInput,\n type ChatModelOutput,\n ImageModel,\n type ImageModelInput,\n type ImageModelOutput,\n type ModelProcessResult,\n VideoModel,\n type VideoModelInput,\n type VideoModelOutput,\n} from \"@aigne/model-base\";\nimport type { BaseClientInvokeOptions } from \"@aigne/model-base/transport/base-client\";\nimport { getModels } from \"./utils/hub.js\";\nimport { findImageModel, findModel, findVideoModel, parseModel } from \"./utils/model.js\";\n\nimport type {\n AIGNEHubChatModelOptions,\n AIGNEHubImageModelOptions,\n AIGNEHubVideoModelOptions,\n} from \"./utils/type.js\";\n\nexport * from \"./utils/blocklet.js\";\nexport * from \"./utils/constants.js\";\nexport * from \"./utils/find-provider.js\";\nexport * from \"./utils/model.js\";\n\nexport class AIGNEHubChatModel extends ChatModel {\n static async models() {\n return getModels({ type: \"chat\" });\n }\n\n models() {\n return getModels({ type: \"chat\" });\n }\n\n constructor(public override options: AIGNEHubChatModelOptions) {\n let provider = process.env.BLOCKLET_AIGNE_API_PROVIDER;\n\n if (!provider && options.model) {\n const parsed = parseModel(options.model);\n if (parsed.provider && parsed.model) {\n provider = parsed.provider;\n options.model = parsed.model;\n }\n }\n\n provider ||= AIGNEHubChatModel.name;\n\n const { match, all } = findModel(provider);\n\n if (!match) {\n const available = all.map((m) => m.name).join(\", \");\n throw new Error(\n `Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`,\n );\n }\n\n const client = match.create(options);\n\n super({ name: client.name });\n\n this.client = client;\n }\n\n protected client: ChatModel;\n\n override get credential() {\n return this.client.credential;\n }\n\n override async process(\n input: ChatModelInput,\n options: BaseClientInvokeOptions,\n ): Promise<ModelProcessResult<ChatModelOutput>> {\n return this.client.invoke(input, options);\n }\n}\n\nexport class AIGNEHubImageModel extends ImageModel {\n static async models() {\n return getModels({ type: \"image\" });\n }\n\n models() {\n return getModels({ type: \"image\" });\n }\n\n constructor(public override options: AIGNEHubImageModelOptions) {\n let provider = process.env.BLOCKLET_AIGNE_API_PROVIDER;\n\n if (!provider && options.model) {\n const parsed = parseModel(options.model);\n if (parsed.provider && parsed.model) {\n provider = parsed.provider;\n options.model = parsed.model;\n }\n }\n\n provider ||= AIGNEHubImageModel.name;\n\n const { match, all } = findImageModel(provider);\n\n if (!match) {\n const available = all.map((m) => m.name).join(\", \");\n throw new Error(\n `Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`,\n );\n }\n\n const client = match.create(options);\n\n super({ name: client.name });\n\n this.client = client;\n }\n\n protected client: ImageModel;\n\n override get credential() {\n return this.client.credential;\n }\n\n override async process(\n input: ImageModelInput,\n options: BaseClientInvokeOptions,\n ): Promise<ModelProcessResult<ImageModelOutput>> {\n return this.client.invoke(input, options);\n }\n}\n\nexport class AIGNEHubVideoModel extends VideoModel {\n static async models() {\n return getModels({ type: \"video\" });\n }\n\n models() {\n return getModels({ type: \"video\" });\n }\n\n constructor(public override options: AIGNEHubVideoModelOptions) {\n let provider = process.env.BLOCKLET_AIGNE_API_PROVIDER;\n\n if (!provider && options.model) {\n const parsed = parseModel(options.model);\n if (parsed.provider && parsed.model) {\n provider = parsed.provider;\n options.model = parsed.model;\n }\n }\n\n provider ||= AIGNEHubVideoModel.name;\n\n const { match, all } = findVideoModel(provider);\n\n if (!match) {\n const available = all.map((m) => m.name).join(\", \");\n throw new Error(\n `Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`,\n );\n }\n\n const client = match.create(options);\n\n super({ name: client.name });\n\n this.client = client;\n }\n\n protected client: VideoModel;\n\n override get credential() {\n return this.client.credential;\n }\n\n override async process(\n input: VideoModelInput,\n options: BaseClientInvokeOptions,\n ): Promise<ModelProcessResult<VideoModelOutput>> {\n return this.client.invoke(input, options);\n }\n}\n"],"mappings":";;;;;;;;AA2BA,IAAa,oBAAb,MAAa,0BAA0B,UAAU;CAC/C,aAAa,SAAS;AACpB,SAAO,UAAU,EAAE,MAAM,QAAQ,CAAC;;CAGpC,SAAS;AACP,SAAO,UAAU,EAAE,MAAM,QAAQ,CAAC;;CAGpC,YAAY,AAAgB,SAAmC;EAC7D,IAAI,WAAW,QAAQ,IAAI;AAE3B,MAAI,CAAC,YAAY,QAAQ,OAAO;GAC9B,MAAM,SAAS,WAAW,QAAQ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
//#region src/utils/blocklet.ts
|
|
5
|
+
const cache = /* @__PURE__ */ new Map();
|
|
6
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
5
7
|
async function getAIGNEHubMountPoint(url, component) {
|
|
6
8
|
const { origin } = new URL(url);
|
|
7
|
-
const
|
|
9
|
+
const cacheKey = `${origin}#${component}`;
|
|
10
|
+
const cached = cache.get(cacheKey);
|
|
11
|
+
if (cached) return cached;
|
|
12
|
+
const pending = inflight.get(cacheKey);
|
|
13
|
+
if (pending) return pending;
|
|
14
|
+
const promise = _fetchMountPoint(origin, url, component, cacheKey);
|
|
15
|
+
inflight.set(cacheKey, promise);
|
|
16
|
+
try {
|
|
17
|
+
return await promise;
|
|
18
|
+
} finally {
|
|
19
|
+
inflight.delete(cacheKey);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function _fetchMountPoint(origin, url, component, cacheKey) {
|
|
23
|
+
const comp = ((await (await (0, _aigne_model_base_utils_fetch.fetch)((0, ufo.joinURL)(origin, "__blocklet__.js?type=json"))).json())?.componentMountPoints || []).find((m) => m.did === component);
|
|
8
24
|
if (!comp) throw new Error(`Component ${component} not found in blocklet ${url}`);
|
|
9
|
-
|
|
25
|
+
const result = (0, ufo.joinURL)(origin, comp.mountPoint);
|
|
26
|
+
cache.set(cacheKey, result);
|
|
27
|
+
return result;
|
|
10
28
|
}
|
|
11
29
|
|
|
12
30
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocklet.d.cts","names":[],"sources":["../../src/utils/blocklet.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"blocklet.d.cts","names":[],"sources":["../../src/utils/blocklet.ts"],"mappings":";iBAMsB,qBAAA,CAAsB,GAAA,UAAa,SAAA,WAAiB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocklet.d.mts","names":[],"sources":["../../src/utils/blocklet.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"blocklet.d.mts","names":[],"sources":["../../src/utils/blocklet.ts"],"mappings":";iBAMsB,qBAAA,CAAsB,GAAA,UAAa,SAAA,WAAiB,OAAA"}
|
package/dist/utils/blocklet.mjs
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import { joinURL } from "ufo";
|
|
2
|
-
import { fetch } from "@aigne/
|
|
2
|
+
import { fetch } from "@aigne/model-base/utils/fetch";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/blocklet.ts
|
|
5
|
+
const cache = /* @__PURE__ */ new Map();
|
|
6
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
5
7
|
async function getAIGNEHubMountPoint(url, component) {
|
|
6
8
|
const { origin } = new URL(url);
|
|
9
|
+
const cacheKey = `${origin}#${component}`;
|
|
10
|
+
const cached = cache.get(cacheKey);
|
|
11
|
+
if (cached) return cached;
|
|
12
|
+
const pending = inflight.get(cacheKey);
|
|
13
|
+
if (pending) return pending;
|
|
14
|
+
const promise = _fetchMountPoint(origin, url, component, cacheKey);
|
|
15
|
+
inflight.set(cacheKey, promise);
|
|
16
|
+
try {
|
|
17
|
+
return await promise;
|
|
18
|
+
} finally {
|
|
19
|
+
inflight.delete(cacheKey);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function _fetchMountPoint(origin, url, component, cacheKey) {
|
|
7
23
|
const comp = ((await (await fetch(joinURL(origin, "__blocklet__.js?type=json"))).json())?.componentMountPoints || []).find((m) => m.did === component);
|
|
8
24
|
if (!comp) throw new Error(`Component ${component} not found in blocklet ${url}`);
|
|
9
|
-
|
|
25
|
+
const result = joinURL(origin, comp.mountPoint);
|
|
26
|
+
cache.set(cacheKey, result);
|
|
27
|
+
return result;
|
|
10
28
|
}
|
|
11
29
|
|
|
12
30
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocklet.mjs","names":[],"sources":["../../src/utils/blocklet.ts"],"sourcesContent":["import { fetch } from \"@aigne/
|
|
1
|
+
{"version":3,"file":"blocklet.mjs","names":[],"sources":["../../src/utils/blocklet.ts"],"sourcesContent":["import { fetch } from \"@aigne/model-base/utils/fetch\";\nimport { joinURL } from \"ufo\";\n\nconst cache = new Map<string, string>();\nconst inflight = new Map<string, Promise<string>>();\n\nexport async function getAIGNEHubMountPoint(url: string, component: string) {\n const { origin } = new URL(url);\n const cacheKey = `${origin}#${component}`;\n const cached = cache.get(cacheKey);\n if (cached) return cached;\n\n const pending = inflight.get(cacheKey);\n if (pending) return pending;\n\n const promise = _fetchMountPoint(origin, url, component, cacheKey);\n inflight.set(cacheKey, promise);\n try {\n return await promise;\n } finally {\n inflight.delete(cacheKey);\n }\n}\n\nasync function _fetchMountPoint(origin: string, url: string, component: string, cacheKey: string) {\n const BLOCKLET_JSON_PATH = \"__blocklet__.js?type=json\";\n const blockletInfo = await fetch(joinURL(origin, BLOCKLET_JSON_PATH));\n const blocklet = await blockletInfo.json();\n const comp = (blocklet?.componentMountPoints || []).find(\n (m: { did: string }) => m.did === component,\n );\n if (!comp) throw new Error(`Component ${component} not found in blocklet ${url}`);\n\n const result = joinURL(origin, comp.mountPoint);\n cache.set(cacheKey, result);\n return result;\n}\n"],"mappings":";;;;AAGA,MAAM,wBAAQ,IAAI,KAAqB;AACvC,MAAM,2BAAW,IAAI,KAA8B;AAEnD,eAAsB,sBAAsB,KAAa,WAAmB;CAC1E,MAAM,EAAE,WAAW,IAAI,IAAI,IAAI;CAC/B,MAAM,WAAW,GAAG,OAAO,GAAG;CAC9B,MAAM,SAAS,MAAM,IAAI,SAAS;AAClC,KAAI,OAAQ,QAAO;CAEnB,MAAM,UAAU,SAAS,IAAI,SAAS;AACtC,KAAI,QAAS,QAAO;CAEpB,MAAM,UAAU,iBAAiB,QAAQ,KAAK,WAAW,SAAS;AAClE,UAAS,IAAI,UAAU,QAAQ;AAC/B,KAAI;AACF,SAAO,MAAM;WACL;AACR,WAAS,OAAO,SAAS;;;AAI7B,eAAe,iBAAiB,QAAgB,KAAa,WAAmB,UAAkB;CAIhG,MAAM,SADW,OADI,MAAM,MAAM,QAAQ,QADd,4BACyC,CAAC,EACjC,MAAM,GAClB,wBAAwB,EAAE,EAAE,MACjD,MAAuB,EAAE,QAAQ,UACnC;AACD,KAAI,CAAC,KAAM,OAAM,IAAI,MAAM,aAAa,UAAU,yBAAyB,MAAM;CAEjF,MAAM,SAAS,QAAQ,QAAQ,KAAK,WAAW;AAC/C,OAAM,IAAI,UAAU,OAAO;AAC3B,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.cts","names":[],"sources":["../../src/utils/constants.ts"],"mappings":";cAAa,aAAA;AAAA,cAEA,sBAAA;AAAA,cAEA,uBAAA;AAAA,cAEA,qBAAA;AAAA,cAEA,qBAAA;AAAA,cAEA,kBAAA;AAAA,cAEA,eAAA;AAAA,cAGA,YAAA;EAAA
|
|
1
|
+
{"version":3,"file":"constants.d.cts","names":[],"sources":["../../src/utils/constants.ts"],"mappings":";cAAa,aAAA;AAAA,cAEA,sBAAA;AAAA,cAEA,uBAAA;AAAA,cAEA,qBAAA;AAAA,cAEA,qBAAA;AAAA,cAEA,kBAAA;AAAA,cAEA,eAAA;AAAA,cAGA,YAAA;EAAA;;;;;;;;;;;;KAcD,cAAA,WAAyB,YAAA,eAA2B,YAAA;AAAA,cAEnD,aAAA,EAAe,MAAA,CAAO,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","names":[],"sources":["../../src/utils/constants.ts"],"mappings":";cAAa,aAAA;AAAA,cAEA,sBAAA;AAAA,cAEA,uBAAA;AAAA,cAEA,qBAAA;AAAA,cAEA,qBAAA;AAAA,cAEA,kBAAA;AAAA,cAEA,eAAA;AAAA,cAGA,YAAA;EAAA
|
|
1
|
+
{"version":3,"file":"constants.d.mts","names":[],"sources":["../../src/utils/constants.ts"],"mappings":";cAAa,aAAA;AAAA,cAEA,sBAAA;AAAA,cAEA,uBAAA;AAAA,cAEA,qBAAA;AAAA,cAEA,qBAAA;AAAA,cAEA,kBAAA;AAAA,cAEA,eAAA;AAAA,cAGA,YAAA;EAAA;;;;;;;;;;;;KAcD,cAAA,WAAyB,YAAA,eAA2B,YAAA;AAAA,cAEnD,aAAA,EAAe,MAAA,CAAO,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-provider.d.cts","names":[],"sources":["../../src/utils/find-provider.ts"],"mappings":";;;iBAqFgB,oBAAA,
|
|
1
|
+
{"version":3,"file":"find-provider.d.cts","names":[],"sources":["../../src/utils/find-provider.ts"],"mappings":";;;iBAqFgB,oBAAA,CAAqB,KAAA;AAAA,iBAIrB,0BAAA,CAA2B,KAAA,WAAgB,cAAA;AAAA,iBAM3C,qBAAA,CAAsB,KAAA,WAAgB,cAAA;;;;;AANtD;;;;;AAMA;;;iBAmBgB,sBAAA,CACd,QAAA,EAAU,cAAA,EACV,cAAA,UACA,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-provider.d.mts","names":[],"sources":["../../src/utils/find-provider.ts"],"mappings":";;;iBAqFgB,oBAAA,
|
|
1
|
+
{"version":3,"file":"find-provider.d.mts","names":[],"sources":["../../src/utils/find-provider.ts"],"mappings":";;;iBAqFgB,oBAAA,CAAqB,KAAA;AAAA,iBAIrB,0BAAA,CAA2B,KAAA,WAAgB,cAAA;AAAA,iBAM3C,qBAAA,CAAsB,KAAA,WAAgB,cAAA;;;;;AANtD;;;;;AAMA;;;iBAmBgB,sBAAA,CACd,QAAA,EAAU,cAAA,EACV,cAAA,UACA,MAAA"}
|
package/dist/utils/hub.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_blocklet = require('./blocklet.cjs');
|
|
2
2
|
const require_constants = require('./constants.cjs');
|
|
3
3
|
let ufo = require("ufo");
|
|
4
|
-
let
|
|
4
|
+
let _aigne_model_base_utils_fetch = require("@aigne/model-base/utils/fetch");
|
|
5
5
|
let zod = require("zod");
|
|
6
6
|
|
|
7
7
|
//#region src/utils/hub.ts
|
|
@@ -16,7 +16,7 @@ const modelsSchema = zod.z.array(zod.z.object({
|
|
|
16
16
|
status: zod.z.object({ available: zod.z.boolean() }).nullish()
|
|
17
17
|
}));
|
|
18
18
|
async function getModels(options) {
|
|
19
|
-
const json = await (await (0,
|
|
19
|
+
const json = await (await (0, _aigne_model_base_utils_fetch.fetch)((0, ufo.withQuery)((0, ufo.joinURL)(await require_blocklet.getAIGNEHubMountPoint(options.baseURL || require_constants.aigneHubBaseUrl(), require_constants.AIGNE_HUB_BLOCKLET_DID), "/api/ai/models"), { type: options.type }))).json();
|
|
20
20
|
return modelsSchema.parse(json);
|
|
21
21
|
}
|
|
22
22
|
|
package/dist/utils/hub.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getAIGNEHubMountPoint } from "./blocklet.mjs";
|
|
2
2
|
import { AIGNE_HUB_BLOCKLET_DID, aigneHubBaseUrl } from "./constants.mjs";
|
|
3
3
|
import { joinURL, withQuery } from "ufo";
|
|
4
|
-
import { fetch } from "@aigne/
|
|
4
|
+
import { fetch } from "@aigne/model-base/utils/fetch";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
//#region src/utils/hub.ts
|
package/dist/utils/hub.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub.mjs","names":[],"sources":["../../src/utils/hub.ts"],"sourcesContent":["import { fetch } from \"@aigne/
|
|
1
|
+
{"version":3,"file":"hub.mjs","names":[],"sources":["../../src/utils/hub.ts"],"sourcesContent":["import { fetch } from \"@aigne/model-base/utils/fetch\";\nimport { joinURL, withQuery } from \"ufo\";\nimport { z } from \"zod\";\nimport { getAIGNEHubMountPoint } from \"./blocklet.js\";\nimport { AIGNE_HUB_BLOCKLET_DID, aigneHubBaseUrl } from \"./constants.js\";\n\nexport interface GetModelsOptions {\n baseURL?: string;\n type?: \"image\" | \"chat\" | \"embedding\" | \"video\";\n}\n\nconst modelsSchema = z.array(\n z.object({\n model: z.string(),\n type: z.string(),\n provider: z.string(),\n input_credits_per_token: z.string(),\n output_credits_per_token: z.string(),\n modelMetadata: z.record(z.unknown()).nullish(),\n providerDisplayName: z.string(),\n status: z\n .object({\n available: z.boolean(),\n })\n .nullish(),\n }),\n);\n\nexport async function getModels(options: GetModelsOptions) {\n const url = await getAIGNEHubMountPoint(\n options.baseURL || aigneHubBaseUrl(),\n AIGNE_HUB_BLOCKLET_DID,\n );\n\n const response = await fetch(\n withQuery(joinURL(url, \"/api/ai/models\"), {\n type: options.type,\n }),\n );\n\n const json = await response.json();\n\n return modelsSchema.parse(json);\n}\n"],"mappings":";;;;;;;AAWA,MAAM,eAAe,EAAE,MACrB,EAAE,OAAO;CACP,OAAO,EAAE,QAAQ;CACjB,MAAM,EAAE,QAAQ;CAChB,UAAU,EAAE,QAAQ;CACpB,yBAAyB,EAAE,QAAQ;CACnC,0BAA0B,EAAE,QAAQ;CACpC,eAAe,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,SAAS;CAC9C,qBAAqB,EAAE,QAAQ;CAC/B,QAAQ,EACL,OAAO,EACN,WAAW,EAAE,SAAS,EACvB,CAAC,CACD,SAAS;CACb,CAAC,CACH;AAED,eAAsB,UAAU,SAA2B;CAYzD,MAAM,OAAO,OANI,MAAM,MACrB,UAAU,QANA,MAAM,sBAChB,QAAQ,WAAW,iBAAiB,EACpC,uBACD,EAGwB,iBAAiB,EAAE,EACxC,MAAM,QAAQ,MACf,CAAC,CACH,EAE2B,MAAM;AAElC,QAAO,aAAa,MAAM,KAAK"}
|
package/dist/utils/model.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChatModel,
|
|
1
|
+
import { ChatModel, ChatModelInputOptions, ImageModel, ImageModelInputOptions, VideoModel } from "@aigne/model-base";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/model.d.ts
|
|
4
4
|
interface LoadableModel {
|
|
@@ -6,7 +6,7 @@ interface LoadableModel {
|
|
|
6
6
|
apiKeyEnvName?: string | string[];
|
|
7
7
|
create: (options: {
|
|
8
8
|
model?: string;
|
|
9
|
-
modelOptions?:
|
|
9
|
+
modelOptions?: ChatModelInputOptions;
|
|
10
10
|
apiKey?: string;
|
|
11
11
|
baseURL?: string;
|
|
12
12
|
}) => ChatModel;
|
|
@@ -19,7 +19,7 @@ interface LoadableImageModel {
|
|
|
19
19
|
apiKey?: string;
|
|
20
20
|
baseURL?: string;
|
|
21
21
|
model?: string;
|
|
22
|
-
modelOptions?:
|
|
22
|
+
modelOptions?: ImageModelInputOptions;
|
|
23
23
|
}) => ImageModel;
|
|
24
24
|
}
|
|
25
25
|
interface LoadableVideoModel {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.cts","names":[],"sources":["../../src/utils/model.ts"],"mappings":";;;UAuDiB,aAAA;
|
|
1
|
+
{"version":3,"file":"model.d.cts","names":[],"sources":["../../src/utils/model.ts"],"mappings":";;;UAuDiB,aAAA;EACf,IAAA;EACA,aAAA;EACA,MAAA,GAAS,OAAA;IACP,KAAA;IACA,YAAA,GAAe,qBAAA;IACf,MAAA;IACA,OAAA;EAAA,MACI,SAAA;AAAA;AAAA,iBAGQ,eAAA,CAAA,GAAmB,aAAA;AAAA,UAyElB,kBAAA;EACf,IAAA;EACA,aAAA;EACA,MAAA,GAAS,OAAA;IACP,MAAA;IACA,OAAA;IACA,KAAA;IACA,YAAA,GAAe,sBAAA;EAAA,MACX,UAAA;AAAA;AAAA,UAGS,kBAAA;EACf,IAAA;EACA,aAAA;EACA,MAAA,GAAS,OAAA;IACP,MAAA;IACA,OAAA;IACA,KAAA;IACA,YAAA;MAAA,CAAkB,GAAA;IAAA;EAAA,MACd,UAAA;AAAA;AAAA,iBAGQ,oBAAA,CAAA,GAAwB,kBAAA;AAAA,iBAgCxB,oBAAA,CAAA,GAAwB,kBAAA;AAAA,iBAsBxB,SAAA,CAAU,QAAA;EACxB,GAAA,EAAK,aAAA;EACL,KAAA,EAAO,aAAA;AAAA;AAAA,iBAiBO,cAAA,CAAe,QAAA;EAC7B,GAAA,EAAK,kBAAA;EACL,KAAA,EAAO,kBAAA;AAAA;AAAA,iBAiBO,cAAA,CAAe,QAAA;EAC7B,GAAA,EAAK,kBAAA;EACL,KAAA,EAAO,kBAAA;AAAA;AAAA,cAiBI,UAAA,GAAc,KAAA"}
|
package/dist/utils/model.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChatModel,
|
|
1
|
+
import { ChatModel, ChatModelInputOptions, ImageModel, ImageModelInputOptions, VideoModel } from "@aigne/model-base";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/model.d.ts
|
|
4
4
|
interface LoadableModel {
|
|
@@ -6,7 +6,7 @@ interface LoadableModel {
|
|
|
6
6
|
apiKeyEnvName?: string | string[];
|
|
7
7
|
create: (options: {
|
|
8
8
|
model?: string;
|
|
9
|
-
modelOptions?:
|
|
9
|
+
modelOptions?: ChatModelInputOptions;
|
|
10
10
|
apiKey?: string;
|
|
11
11
|
baseURL?: string;
|
|
12
12
|
}) => ChatModel;
|
|
@@ -19,7 +19,7 @@ interface LoadableImageModel {
|
|
|
19
19
|
apiKey?: string;
|
|
20
20
|
baseURL?: string;
|
|
21
21
|
model?: string;
|
|
22
|
-
modelOptions?:
|
|
22
|
+
modelOptions?: ImageModelInputOptions;
|
|
23
23
|
}) => ImageModel;
|
|
24
24
|
}
|
|
25
25
|
interface LoadableVideoModel {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.mts","names":[],"sources":["../../src/utils/model.ts"],"mappings":";;;UAuDiB,aAAA;
|
|
1
|
+
{"version":3,"file":"model.d.mts","names":[],"sources":["../../src/utils/model.ts"],"mappings":";;;UAuDiB,aAAA;EACf,IAAA;EACA,aAAA;EACA,MAAA,GAAS,OAAA;IACP,KAAA;IACA,YAAA,GAAe,qBAAA;IACf,MAAA;IACA,OAAA;EAAA,MACI,SAAA;AAAA;AAAA,iBAGQ,eAAA,CAAA,GAAmB,aAAA;AAAA,UAyElB,kBAAA;EACf,IAAA;EACA,aAAA;EACA,MAAA,GAAS,OAAA;IACP,MAAA;IACA,OAAA;IACA,KAAA;IACA,YAAA,GAAe,sBAAA;EAAA,MACX,UAAA;AAAA;AAAA,UAGS,kBAAA;EACf,IAAA;EACA,aAAA;EACA,MAAA,GAAS,OAAA;IACP,MAAA;IACA,OAAA;IACA,KAAA;IACA,YAAA;MAAA,CAAkB,GAAA;IAAA;EAAA,MACd,UAAA;AAAA;AAAA,iBAGQ,oBAAA,CAAA,GAAwB,kBAAA;AAAA,iBAgCxB,oBAAA,CAAA,GAAwB,kBAAA;AAAA,iBAsBxB,SAAA,CAAU,QAAA;EACxB,GAAA,EAAK,aAAA;EACL,KAAA,EAAO,aAAA;AAAA;AAAA,iBAiBO,cAAA,CAAe,QAAA;EAC7B,GAAA,EAAK,kBAAA;EACL,KAAA,EAAO,kBAAA;AAAA;AAAA,iBAiBO,cAAA,CAAe,QAAA;EAC7B,GAAA,EAAK,kBAAA;EACL,KAAA,EAAO,kBAAA;AAAA;AAAA,cAiBI,UAAA,GAAc,KAAA"}
|
package/dist/utils/model.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.mjs","names":[],"sources":["../../src/utils/model.ts"],"sourcesContent":["import type { Agent } from \"node:https\";\nimport { AnthropicChatModel } from \"@aigne/anthropic\";\nimport { BedrockChatModel } from \"@aigne/bedrock\";\nimport type {\n ChatModel,\n ChatModelInputOptionsWithGetter,\n ImageModel,\n ImageModelInputOptionsWithGetter,\n VideoModel,\n} from \"@aigne/core\";\nimport { DeepSeekChatModel } from \"@aigne/deepseek\";\nimport { DoubaoChatModel, DoubaoImageModel } from \"@aigne/doubao\";\nimport { GeminiChatModel, GeminiImageModel, GeminiVideoModel } from \"@aigne/gemini\";\nimport { IdeogramImageModel } from \"@aigne/ideogram\";\nimport { OllamaChatModel } from \"@aigne/ollama\";\nimport { OpenRouterChatModel } from \"@aigne/open-router\";\nimport {\n OpenAIChatModel,\n type OpenAIChatModelOptions,\n OpenAIImageModel,\n OpenAIVideoModel,\n} from \"@aigne/openai\";\nimport { PoeChatModel } from \"@aigne/poe\";\nimport { XAIChatModel } from \"@aigne/xai\";\nimport { NodeHttpHandler, streamCollector } from \"@smithy/node-http-handler\";\nimport { HttpsProxyAgent } from \"https-proxy-agent\";\nimport { AIGNEHubChatModel } from \"../aigne-hub-chat-model.js\";\nimport { AIGNEHubImageModel } from \"../aigne-hub-image-model.js\";\nimport { AIGNEHubVideoModel } from \"../aigne-hub-video-model.js\";\nimport { AIGNE_HUB_PROVIDER } from \"./constants.js\";\n\nconst getClientOptions = () => {\n const proxy = [\"HTTPS_PROXY\", \"https_proxy\", \"HTTP_PROXY\", \"http_proxy\", \"ALL_PROXY\", \"all_proxy\"]\n .map((i) => process.env[i])\n .filter(Boolean)[0];\n\n const httpAgent = proxy ? (new HttpsProxyAgent(proxy) as Agent) : undefined;\n const clientOptions: Pick<\n NonNullable<OpenAIChatModelOptions[\"clientOptions\"]>,\n \"fetchOptions\"\n > = {\n fetchOptions: {\n // @ts-ignore\n agent: httpAgent,\n },\n };\n\n return {\n clientOptions,\n httpAgent,\n };\n};\n\nconst GOOGLE = \"google\";\n\nexport interface LoadableModel {\n name: string | string[];\n apiKeyEnvName?: string | string[];\n create: (options: {\n model?: string;\n modelOptions?: ChatModelInputOptionsWithGetter;\n apiKey?: string;\n baseURL?: string;\n }) => ChatModel;\n}\n\nexport function availableModels(): LoadableModel[] {\n const { clientOptions, httpAgent } = getClientOptions();\n\n return [\n {\n name: OpenAIChatModel.name,\n apiKeyEnvName: \"OPENAI_API_KEY\",\n create: (params) => new OpenAIChatModel({ ...params, clientOptions }),\n },\n {\n name: AnthropicChatModel.name,\n apiKeyEnvName: \"ANTHROPIC_API_KEY\",\n create: (params) => new AnthropicChatModel({ ...params, clientOptions }),\n },\n {\n name: BedrockChatModel.name,\n apiKeyEnvName: \"AWS_ACCESS_KEY_ID\",\n create: (params) =>\n new BedrockChatModel({\n ...params,\n clientOptions: {\n requestHandler: NodeHttpHandler.create({ httpAgent, httpsAgent: httpAgent }),\n streamCollector,\n },\n }),\n },\n {\n name: DeepSeekChatModel.name,\n apiKeyEnvName: \"DEEPSEEK_API_KEY\",\n create: (params) => new DeepSeekChatModel({ ...params, clientOptions }),\n },\n {\n name: [GeminiChatModel.name, GOOGLE],\n apiKeyEnvName: [\"GEMINI_API_KEY\", \"GOOGLE_API_KEY\"],\n create: (params) =>\n new GeminiChatModel({\n ...params,\n clientOptions: { httpOptions: clientOptions.fetchOptions },\n }),\n },\n {\n name: OllamaChatModel.name,\n apiKeyEnvName: \"OLLAMA_API_KEY\",\n create: (params) => new OllamaChatModel({ ...params, clientOptions }),\n },\n {\n name: OpenRouterChatModel.name,\n apiKeyEnvName: \"OPEN_ROUTER_API_KEY\",\n create: (params) => new OpenRouterChatModel({ ...params, clientOptions }),\n },\n {\n name: XAIChatModel.name,\n apiKeyEnvName: \"XAI_API_KEY\",\n create: (params) => new XAIChatModel({ ...params, clientOptions }),\n },\n {\n name: DoubaoChatModel.name,\n apiKeyEnvName: \"DOUBAO_API_KEY\",\n create: (params) => new DoubaoChatModel({ ...params, clientOptions }),\n },\n {\n name: PoeChatModel.name,\n apiKeyEnvName: \"POE_API_KEY\",\n create: (params) => new PoeChatModel({ ...params, clientOptions }),\n },\n {\n name: AIGNEHubChatModel.name,\n apiKeyEnvName: \"AIGNE_HUB_API_KEY\",\n create: (params) => new AIGNEHubChatModel({ ...params, clientOptions }),\n },\n ];\n}\n\nexport interface LoadableImageModel {\n name: string | string[];\n apiKeyEnvName: string;\n create: (options: {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n modelOptions?: ImageModelInputOptionsWithGetter;\n }) => ImageModel;\n}\n\nexport interface LoadableVideoModel {\n name: string | string[];\n apiKeyEnvName: string;\n create: (options: {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n modelOptions?: { [key: string]: any };\n }) => VideoModel;\n}\n\nexport function availableImageModels(): LoadableImageModel[] {\n const { clientOptions } = getClientOptions();\n\n return [\n {\n name: OpenAIImageModel.name,\n apiKeyEnvName: \"OPENAI_API_KEY\",\n create: (params) => new OpenAIImageModel({ ...params, clientOptions }),\n },\n {\n name: [GeminiImageModel.name, GOOGLE],\n apiKeyEnvName: \"GEMINI_API_KEY\",\n create: (params) => new GeminiImageModel({ ...params, clientOptions }),\n },\n {\n name: IdeogramImageModel.name,\n apiKeyEnvName: \"IDEOGRAM_API_KEY\",\n create: (params) => new IdeogramImageModel({ ...params }),\n },\n {\n name: DoubaoImageModel.name,\n apiKeyEnvName: \"DOUBAO_API_KEY\",\n create: (params) => new DoubaoImageModel({ ...params, clientOptions }),\n },\n {\n name: AIGNEHubImageModel.name,\n apiKeyEnvName: \"AIGNE_HUB_API_KEY\",\n create: (params) => new AIGNEHubImageModel({ ...params, clientOptions }),\n },\n ];\n}\n\nexport function availableVideoModels(): LoadableVideoModel[] {\n const { clientOptions } = getClientOptions();\n\n return [\n {\n name: OpenAIVideoModel.name,\n apiKeyEnvName: \"OPENAI_API_KEY\",\n create: (params) => new OpenAIVideoModel({ ...params, clientOptions }) as VideoModel,\n },\n {\n name: [GeminiVideoModel.name, GOOGLE],\n apiKeyEnvName: \"GEMINI_API_KEY\",\n create: (params) => new GeminiVideoModel({ ...params, clientOptions }) as VideoModel,\n },\n {\n name: AIGNEHubVideoModel.name,\n apiKeyEnvName: \"AIGNE_HUB_API_KEY\",\n create: (params) => new AIGNEHubVideoModel({ ...params, clientOptions }) as VideoModel,\n },\n ];\n}\n\nexport function findModel(provider: string): {\n all: LoadableModel[];\n match: LoadableModel | undefined;\n} {\n provider = provider.toLowerCase().replace(/-/g, \"\");\n\n const all = availableModels();\n\n const match = all.find((m) => {\n if (typeof m.name === \"string\") {\n return m.name.toLowerCase().includes(provider);\n }\n\n return m.name.some((n) => n.toLowerCase().includes(provider));\n });\n\n return { all, match };\n}\n\nexport function findImageModel(provider: string): {\n all: LoadableImageModel[];\n match: LoadableImageModel | undefined;\n} {\n provider = provider.toLowerCase().replace(/-/g, \"\");\n\n const all = availableImageModels();\n\n const match = all.find((m) => {\n if (typeof m.name === \"string\") {\n return m.name.toLowerCase().includes(provider);\n }\n\n return m.name.some((n) => n.toLowerCase().includes(provider));\n });\n\n return { all, match };\n}\n\nexport function findVideoModel(provider: string): {\n all: LoadableVideoModel[];\n match: LoadableVideoModel | undefined;\n} {\n provider = provider.toLowerCase().replace(/-/g, \"\");\n\n const all = availableVideoModels();\n\n const match = all.find((m) => {\n if (typeof m.name === \"string\") {\n return m.name.toLowerCase().includes(provider);\n }\n\n return m.name.some((n) => n.toLowerCase().includes(provider));\n });\n\n return { all, match };\n}\n\nexport const parseModel = (model: string) => {\n // replace first ':' with '/' to compatible with `provider:model-name` format\n model = model.replace(/^([\\w-]+):/, \"$1/\");\n let { provider, name } = model.match(/(?<provider>[^/]*)(\\/(?<name>.*))?/)?.groups ?? {};\n provider = provider?.replace(/-/g, \"\");\n const match = provider ? findModel(provider)?.match : undefined;\n\n if (match) {\n return { provider, model: name };\n }\n\n return { provider: AIGNE_HUB_PROVIDER, model };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,MAAM,yBAAyB;CAC7B,MAAM,QAAQ;EAAC;EAAe;EAAe;EAAc;EAAc;EAAa;EAAY,CAC/F,KAAK,MAAM,QAAQ,IAAI,GAAG,CAC1B,OAAO,QAAQ,CAAC;CAEnB,MAAM,YAAY,QAAS,IAAI,gBAAgB,MAAM,GAAa;AAWlE,QAAO;EACL,eARE,EACF,cAAc,EAEZ,OAAO,WACR,EACF;EAIC;EACD;;AAGH,MAAM,SAAS;AAaf,SAAgB,kBAAmC;CACjD,MAAM,EAAE,eAAe,cAAc,kBAAkB;AAEvD,QAAO;EACL;GACE,MAAM,gBAAgB;GACtB,eAAe;GACf,SAAS,WAAW,IAAI,gBAAgB;IAAE,GAAG;IAAQ;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AAO,EAAE,KAAK,MAAM,MAAM,EAAE,aAAa,CAAC,SAAS,SAAS,CAAC;IAC7D;EAEmB;;AAGvB,SAAgB,eAAe,UAG7B;AACA,YAAW,SAAS,aAAa,CAAC,QAAQ,MAAM,GAAG;CAEnD,MAAM,MAAM,sBAAsB;AAUlC,QAAO;EAAE;EAAK,OARA,IAAI,MAAM,MAAM;AAC5B,OAAI,OAAO,EAAE,SAAS,SACpB,QAAO,EAAE,KAAK,aAAa,CAAC,SAAS,SAAS;AAGhD,UAAO,EAAE,KAAK,MAAM,MAAM,EAAE,aAAa,CAAC,SAAS,SAAS,CAAC;IAC7D;EAEmB;;AAGvB,SAAgB,eAAe,UAG7B;AACA,YAAW,SAAS,aAAa,CAAC,QAAQ,MAAM,GAAG;CAEnD,MAAM,MAAM,sBAAsB;AAUlC,QAAO;EAAE;EAAK,OARA,IAAI,MAAM,MAAM;AAC5B,OAAI,OAAO,EAAE,SAAS,SACpB,QAAO,EAAE,KAAK,aAAa,CAAC,SAAS,SAAS;AAGhD,UAAO,EAAE,KAAK,MAAM,MAAM,EAAE,aAAa,CAAC,SAAS,SAAS,CAAC;IAC7D;EAEmB;;AAGvB,MAAa,cAAc,UAAkB;AAE3C,SAAQ,MAAM,QAAQ,cAAc,MAAM;CAC1C,IAAI,EAAE,UAAU,SAAS,MAAM,MAAM,qCAAqC,EAAE,UAAU,EAAE;AACxF,YAAW,UAAU,QAAQ,MAAM,GAAG;AAGtC,KAFc,WAAW,UAAU,SAAS,EAAE,QAAQ,OAGpD,QAAO;EAAE;EAAU,OAAO;EAAM;AAGlC,QAAO;EAAE,UAAU;EAAoB;EAAO"}
|
|
1
|
+
{"version":3,"file":"model.mjs","names":[],"sources":["../../src/utils/model.ts"],"sourcesContent":["import type { Agent } from \"node:https\";\nimport { AnthropicChatModel } from \"@aigne/anthropic\";\nimport { BedrockChatModel } from \"@aigne/bedrock\";\nimport { DeepSeekChatModel } from \"@aigne/deepseek\";\nimport { DoubaoChatModel, DoubaoImageModel } from \"@aigne/doubao\";\nimport { GeminiChatModel, GeminiImageModel, GeminiVideoModel } from \"@aigne/gemini\";\nimport { IdeogramImageModel } from \"@aigne/ideogram\";\nimport type {\n ChatModel,\n ChatModelInputOptions,\n ImageModel,\n ImageModelInputOptions,\n VideoModel,\n} from \"@aigne/model-base\";\nimport { OllamaChatModel } from \"@aigne/ollama\";\nimport { OpenRouterChatModel } from \"@aigne/open-router\";\nimport {\n OpenAIChatModel,\n type OpenAIChatModelOptions,\n OpenAIImageModel,\n OpenAIVideoModel,\n} from \"@aigne/openai\";\nimport { PoeChatModel } from \"@aigne/poe\";\nimport { XAIChatModel } from \"@aigne/xai\";\nimport { NodeHttpHandler, streamCollector } from \"@smithy/node-http-handler\";\nimport { HttpsProxyAgent } from \"https-proxy-agent\";\nimport { AIGNEHubChatModel } from \"../aigne-hub-chat-model.js\";\nimport { AIGNEHubImageModel } from \"../aigne-hub-image-model.js\";\nimport { AIGNEHubVideoModel } from \"../aigne-hub-video-model.js\";\nimport { AIGNE_HUB_PROVIDER } from \"./constants.js\";\n\nconst getClientOptions = () => {\n const proxy = [\"HTTPS_PROXY\", \"https_proxy\", \"HTTP_PROXY\", \"http_proxy\", \"ALL_PROXY\", \"all_proxy\"]\n .map((i) => process.env[i])\n .filter(Boolean)[0];\n\n const httpAgent = proxy ? (new HttpsProxyAgent(proxy) as Agent) : undefined;\n const clientOptions: Pick<\n NonNullable<OpenAIChatModelOptions[\"clientOptions\"]>,\n \"fetchOptions\"\n > = {\n fetchOptions: {\n // @ts-ignore\n agent: httpAgent,\n },\n };\n\n return {\n clientOptions,\n httpAgent,\n };\n};\n\nconst GOOGLE = \"google\";\n\nexport interface LoadableModel {\n name: string | string[];\n apiKeyEnvName?: string | string[];\n create: (options: {\n model?: string;\n modelOptions?: ChatModelInputOptions;\n apiKey?: string;\n baseURL?: string;\n }) => ChatModel;\n}\n\nexport function availableModels(): LoadableModel[] {\n const { clientOptions, httpAgent } = getClientOptions();\n\n return [\n {\n name: OpenAIChatModel.name,\n apiKeyEnvName: \"OPENAI_API_KEY\",\n create: (params) => new OpenAIChatModel({ ...params, clientOptions }),\n },\n {\n name: AnthropicChatModel.name,\n apiKeyEnvName: \"ANTHROPIC_API_KEY\",\n create: (params) => new AnthropicChatModel({ ...params, clientOptions }),\n },\n {\n name: BedrockChatModel.name,\n apiKeyEnvName: \"AWS_ACCESS_KEY_ID\",\n create: (params) =>\n new BedrockChatModel({\n ...params,\n clientOptions: {\n requestHandler: NodeHttpHandler.create({ httpAgent, httpsAgent: httpAgent }),\n streamCollector,\n },\n }),\n },\n {\n name: DeepSeekChatModel.name,\n apiKeyEnvName: \"DEEPSEEK_API_KEY\",\n create: (params) => new DeepSeekChatModel({ ...params, clientOptions }),\n },\n {\n name: [GeminiChatModel.name, GOOGLE],\n apiKeyEnvName: [\"GEMINI_API_KEY\", \"GOOGLE_API_KEY\"],\n create: (params) =>\n new GeminiChatModel({\n ...params,\n clientOptions: { httpOptions: clientOptions.fetchOptions },\n }),\n },\n {\n name: OllamaChatModel.name,\n apiKeyEnvName: \"OLLAMA_API_KEY\",\n create: (params) => new OllamaChatModel({ ...params, clientOptions }),\n },\n {\n name: OpenRouterChatModel.name,\n apiKeyEnvName: \"OPEN_ROUTER_API_KEY\",\n create: (params) => new OpenRouterChatModel({ ...params, clientOptions }),\n },\n {\n name: XAIChatModel.name,\n apiKeyEnvName: \"XAI_API_KEY\",\n create: (params) => new XAIChatModel({ ...params, clientOptions }),\n },\n {\n name: DoubaoChatModel.name,\n apiKeyEnvName: \"DOUBAO_API_KEY\",\n create: (params) => new DoubaoChatModel({ ...params, clientOptions }),\n },\n {\n name: PoeChatModel.name,\n apiKeyEnvName: \"POE_API_KEY\",\n create: (params) => new PoeChatModel({ ...params, clientOptions }),\n },\n {\n name: AIGNEHubChatModel.name,\n apiKeyEnvName: \"AIGNE_HUB_API_KEY\",\n create: (params) => new AIGNEHubChatModel({ ...params, clientOptions }),\n },\n ];\n}\n\nexport interface LoadableImageModel {\n name: string | string[];\n apiKeyEnvName: string;\n create: (options: {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n modelOptions?: ImageModelInputOptions;\n }) => ImageModel;\n}\n\nexport interface LoadableVideoModel {\n name: string | string[];\n apiKeyEnvName: string;\n create: (options: {\n apiKey?: string;\n baseURL?: string;\n model?: string;\n modelOptions?: { [key: string]: any };\n }) => VideoModel;\n}\n\nexport function availableImageModels(): LoadableImageModel[] {\n const { clientOptions } = getClientOptions();\n\n return [\n {\n name: OpenAIImageModel.name,\n apiKeyEnvName: \"OPENAI_API_KEY\",\n create: (params) => new OpenAIImageModel({ ...params, clientOptions }),\n },\n {\n name: [GeminiImageModel.name, GOOGLE],\n apiKeyEnvName: \"GEMINI_API_KEY\",\n create: (params) => new GeminiImageModel({ ...params, clientOptions }),\n },\n {\n name: IdeogramImageModel.name,\n apiKeyEnvName: \"IDEOGRAM_API_KEY\",\n create: (params) => new IdeogramImageModel({ ...params }),\n },\n {\n name: DoubaoImageModel.name,\n apiKeyEnvName: \"DOUBAO_API_KEY\",\n create: (params) => new DoubaoImageModel({ ...params, clientOptions }),\n },\n {\n name: AIGNEHubImageModel.name,\n apiKeyEnvName: \"AIGNE_HUB_API_KEY\",\n create: (params) => new AIGNEHubImageModel({ ...params, clientOptions }),\n },\n ];\n}\n\nexport function availableVideoModels(): LoadableVideoModel[] {\n const { clientOptions } = getClientOptions();\n\n return [\n {\n name: OpenAIVideoModel.name,\n apiKeyEnvName: \"OPENAI_API_KEY\",\n create: (params) => new OpenAIVideoModel({ ...params, clientOptions }) as VideoModel,\n },\n {\n name: [GeminiVideoModel.name, GOOGLE],\n apiKeyEnvName: \"GEMINI_API_KEY\",\n create: (params) => new GeminiVideoModel({ ...params, clientOptions }) as VideoModel,\n },\n {\n name: AIGNEHubVideoModel.name,\n apiKeyEnvName: \"AIGNE_HUB_API_KEY\",\n create: (params) => new AIGNEHubVideoModel({ ...params, clientOptions }) as VideoModel,\n },\n ];\n}\n\nexport function findModel(provider: string): {\n all: LoadableModel[];\n match: LoadableModel | undefined;\n} {\n provider = provider.toLowerCase().replace(/-/g, \"\");\n\n const all = availableModels();\n\n const match = all.find((m) => {\n if (typeof m.name === \"string\") {\n return m.name.toLowerCase().includes(provider);\n }\n\n return m.name.some((n) => n.toLowerCase().includes(provider));\n });\n\n return { all, match };\n}\n\nexport function findImageModel(provider: string): {\n all: LoadableImageModel[];\n match: LoadableImageModel | undefined;\n} {\n provider = provider.toLowerCase().replace(/-/g, \"\");\n\n const all = availableImageModels();\n\n const match = all.find((m) => {\n if (typeof m.name === \"string\") {\n return m.name.toLowerCase().includes(provider);\n }\n\n return m.name.some((n) => n.toLowerCase().includes(provider));\n });\n\n return { all, match };\n}\n\nexport function findVideoModel(provider: string): {\n all: LoadableVideoModel[];\n match: LoadableVideoModel | undefined;\n} {\n provider = provider.toLowerCase().replace(/-/g, \"\");\n\n const all = availableVideoModels();\n\n const match = all.find((m) => {\n if (typeof m.name === \"string\") {\n return m.name.toLowerCase().includes(provider);\n }\n\n return m.name.some((n) => n.toLowerCase().includes(provider));\n });\n\n return { all, match };\n}\n\nexport const parseModel = (model: string) => {\n // replace first ':' with '/' to compatible with `provider:model-name` format\n model = model.replace(/^([\\w-]+):/, \"$1/\");\n let { provider, name } = model.match(/(?<provider>[^/]*)(\\/(?<name>.*))?/)?.groups ?? {};\n provider = provider?.replace(/-/g, \"\");\n const match = provider ? findModel(provider)?.match : undefined;\n\n if (match) {\n return { provider, model: name };\n }\n\n return { provider: AIGNE_HUB_PROVIDER, model };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,MAAM,yBAAyB;CAC7B,MAAM,QAAQ;EAAC;EAAe;EAAe;EAAc;EAAc;EAAa;EAAY,CAC/F,KAAK,MAAM,QAAQ,IAAI,GAAG,CAC1B,OAAO,QAAQ,CAAC;CAEnB,MAAM,YAAY,QAAS,IAAI,gBAAgB,MAAM,GAAa;AAWlE,QAAO;EACL,eARE,EACF,cAAc,EAEZ,O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/type.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.cts","names":[],"sources":["../../src/utils/type.ts"],"mappings":";;;;UAqBiB,wBAAA,SAAiC,gBAAA;
|
|
1
|
+
{"version":3,"file":"type.d.cts","names":[],"sources":["../../src/utils/type.ts"],"mappings":";;;;UAqBiB,wBAAA,SAAiC,gBAAA;EAChD,OAAA;EACA,MAAA;EACA,aAAA,GAAgB,sBAAA;IAA4C,QAAA;EAAA;AAAA;AAAA,UAG7C,yBAAA,SAAkC,iBAAA;EACjD,OAAA;EACA,MAAA;EACA,aAAA,GAAgB,sBAAA;IAA4C,QAAA;EAAA;AAAA;AAAA,UAG7C,yBAAA,SAAkC,iBAAA;EACjD,OAAA;EACA,MAAA;EACA,aAAA,GAAgB,sBAAA;IAA4C,QAAA;EAAA;AAAA"}
|
package/dist/utils/type.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.mts","names":[],"sources":["../../src/utils/type.ts"],"mappings":";;;;;UAqBiB,wBAAA,SAAiC,gBAAA;
|
|
1
|
+
{"version":3,"file":"type.d.mts","names":[],"sources":["../../src/utils/type.ts"],"mappings":";;;;;UAqBiB,wBAAA,SAAiC,gBAAA;EAChD,OAAA;EACA,MAAA;EACA,aAAA,GAAgB,sBAAA;IAA4C,QAAA;EAAA;AAAA;AAAA,UAG7C,yBAAA,SAAkC,iBAAA;EACjD,OAAA;EACA,MAAA;EACA,aAAA,GAAgB,sBAAA;IAA4C,QAAA;EAAA;AAAA;AAAA,UAG7C,yBAAA,SAAkC,iBAAA;EACjD,OAAA;EACA,MAAA;EACA,aAAA,GAAgB,sBAAA;IAA4C,QAAA;EAAA;AAAA"}
|
package/dist/utils/type.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.mjs","names":[],"sources":["../../src/utils/type.ts"],"sourcesContent":["import type { ChatModelOptions, ImageModelOptions, VideoModelOptions } from \"@aigne/
|
|
1
|
+
{"version":3,"file":"type.mjs","names":[],"sources":["../../src/utils/type.ts"],"sourcesContent":["import type { ChatModelOptions, ImageModelOptions, VideoModelOptions } from \"@aigne/model-base\";\nimport type { OpenAIChatModelOptions } from \"@aigne/openai\";\nimport { z } from \"zod\";\n\nexport const aigneHubModelOptionsSchema = z.object({\n baseURL: z.string().optional(),\n apiKey: z.string().optional(),\n model: z.string().optional(),\n modelOptions: z\n .object({\n model: z.string().optional(),\n temperature: z.number().optional(),\n topP: z.number().optional(),\n frequencyPenalty: z.number().optional(),\n presencePenalty: z.number().optional(),\n parallelToolCalls: z.boolean().optional().default(true),\n })\n .optional(),\n clientOptions: z.object({}).optional(),\n});\n\nexport interface AIGNEHubChatModelOptions extends ChatModelOptions {\n baseURL?: string;\n apiKey?: string;\n clientOptions?: OpenAIChatModelOptions[\"clientOptions\"] & { clientId?: string };\n}\n\nexport interface AIGNEHubImageModelOptions extends ImageModelOptions {\n baseURL?: string;\n apiKey?: string;\n clientOptions?: OpenAIChatModelOptions[\"clientOptions\"] & { clientId?: string };\n}\n\nexport interface AIGNEHubVideoModelOptions extends VideoModelOptions {\n baseURL?: string;\n apiKey?: string;\n clientOptions?: OpenAIChatModelOptions[\"clientOptions\"] & { clientId?: string };\n}\n"],"mappings":";;;AAIA,MAAa,6BAA6B,EAAE,OAAO;CACjD,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,cAAc,EACX,OAAO;EACN,OAAO,EAAE,QAAQ,CAAC,UAAU;EAC5B,aAAa,EAAE,QAAQ,CAAC,UAAU;EAClC,MAAM,EAAE,QAAQ,CAAC,UAAU;EAC3B,kBAAkB,EAAE,QAAQ,CAAC,UAAU;EACvC,iBAAiB,EAAE,QAAQ,CAAC,UAAU;EACtC,mBAAmB,EAAE,SAAS,CAAC,UAAU,CAAC,QAAQ,KAAK;EACxD,CAAC,CACD,UAAU;CACb,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU;CACvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/aigne-hub",
|
|
3
|
-
"version": "1.74.0-beta.
|
|
3
|
+
"version": "1.74.0-beta.5",
|
|
4
4
|
"description": "AIGNE Hub SDK for integrating with Hub AI models",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -49,20 +49,18 @@
|
|
|
49
49
|
"https-proxy-agent": "^7.0.6",
|
|
50
50
|
"ufo": "^1.6.1",
|
|
51
51
|
"zod": "^3.25.67",
|
|
52
|
-
"@aigne/
|
|
53
|
-
"@aigne/
|
|
54
|
-
"@aigne/
|
|
55
|
-
"@aigne/
|
|
56
|
-
"@aigne/
|
|
57
|
-
"@aigne/
|
|
58
|
-
"@aigne/
|
|
59
|
-
"@aigne/
|
|
60
|
-
"@aigne/
|
|
61
|
-
"@aigne/poe": "^1.74.0-beta.
|
|
62
|
-
"@aigne/
|
|
63
|
-
"@aigne/
|
|
64
|
-
"@aigne/xai": "^1.74.0-beta.3",
|
|
65
|
-
"@aigne/utils": "^1.74.0-beta.3"
|
|
52
|
+
"@aigne/anthropic": "^1.74.0-beta.5",
|
|
53
|
+
"@aigne/bedrock": "^1.74.0-beta.5",
|
|
54
|
+
"@aigne/model-base": "^1.74.0-beta.5",
|
|
55
|
+
"@aigne/deepseek": "^1.74.0-beta.5",
|
|
56
|
+
"@aigne/doubao": "^1.74.0-beta.5",
|
|
57
|
+
"@aigne/gemini": "^1.74.0-beta.5",
|
|
58
|
+
"@aigne/ideogram": "^1.74.0-beta.5",
|
|
59
|
+
"@aigne/openai": "^1.74.0-beta.5",
|
|
60
|
+
"@aigne/ollama": "^1.74.0-beta.5",
|
|
61
|
+
"@aigne/poe": "^1.74.0-beta.5",
|
|
62
|
+
"@aigne/xai": "^1.74.0-beta.5",
|
|
63
|
+
"@aigne/open-router": "^1.74.0-beta.5"
|
|
66
64
|
},
|
|
67
65
|
"devDependencies": {
|
|
68
66
|
"@types/bun": "^1.3.6",
|
|
@@ -72,7 +70,6 @@
|
|
|
72
70
|
"rimraf": "^6.1.2",
|
|
73
71
|
"tsdown": "0.20.0-beta.3",
|
|
74
72
|
"typescript": "5.9.2",
|
|
75
|
-
"@aigne/scripts": "0.0.0",
|
|
76
73
|
"@aigne/typescript-config": "0.0.0"
|
|
77
74
|
},
|
|
78
75
|
"scripts": {
|
package/LICENSE.md
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
Elastic License 2.0
|
|
2
|
-
|
|
3
|
-
URL: https://www.elastic.co/licensing/elastic-license
|
|
4
|
-
|
|
5
|
-
## Acceptance
|
|
6
|
-
|
|
7
|
-
By using the software, you agree to all of the terms and conditions below.
|
|
8
|
-
|
|
9
|
-
## Copyright License
|
|
10
|
-
|
|
11
|
-
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
12
|
-
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
13
|
-
available, and prepare derivative works of the software, in each case subject to
|
|
14
|
-
the limitations and conditions below.
|
|
15
|
-
|
|
16
|
-
## Limitations
|
|
17
|
-
|
|
18
|
-
You may not provide the software to third parties as a hosted or managed
|
|
19
|
-
service, where the service provides users with access to any substantial set of
|
|
20
|
-
the features or functionality of the software.
|
|
21
|
-
|
|
22
|
-
You may not move, change, disable, or circumvent the license key functionality
|
|
23
|
-
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
-
software that is protected by the license key.
|
|
25
|
-
|
|
26
|
-
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
27
|
-
of the licensor in the software. Any use of the licensor’s trademarks is subject
|
|
28
|
-
to applicable law.
|
|
29
|
-
|
|
30
|
-
## Patents
|
|
31
|
-
|
|
32
|
-
The licensor grants you a license, under any patent claims the licensor can
|
|
33
|
-
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
34
|
-
sale, import and have imported the software, in each case subject to the
|
|
35
|
-
limitations and conditions in this license. This license does not cover any
|
|
36
|
-
patent claims that you cause to be infringed by modifications or additions to
|
|
37
|
-
the software. If you or your company make any written claim that the software
|
|
38
|
-
infringes or contributes to infringement of any patent, your patent license for
|
|
39
|
-
the software granted under these terms ends immediately. If your company makes
|
|
40
|
-
such a claim, your patent license ends immediately for work on behalf of your
|
|
41
|
-
company.
|
|
42
|
-
|
|
43
|
-
## Notices
|
|
44
|
-
|
|
45
|
-
You must ensure that anyone who gets a copy of any part of the software from you
|
|
46
|
-
also gets a copy of these terms.
|
|
47
|
-
|
|
48
|
-
If you modify the software, you must include in any modified copies of the
|
|
49
|
-
software prominent notices stating that you have modified the software.
|
|
50
|
-
|
|
51
|
-
## No Other Rights
|
|
52
|
-
|
|
53
|
-
These terms do not imply any licenses other than those expressly granted in
|
|
54
|
-
these terms.
|
|
55
|
-
|
|
56
|
-
## Termination
|
|
57
|
-
|
|
58
|
-
If you use the software in violation of these terms, such use is not licensed,
|
|
59
|
-
and your licenses will automatically terminate. If the licensor provides you
|
|
60
|
-
with a notice of your violation, and you cease all violation of this license no
|
|
61
|
-
later than 30 days after you receive that notice, your licenses will be
|
|
62
|
-
reinstated retroactively. However, if you violate these terms after such
|
|
63
|
-
reinstatement, any additional violation of these terms will cause your licenses
|
|
64
|
-
to terminate automatically and permanently.
|
|
65
|
-
|
|
66
|
-
## No Liability
|
|
67
|
-
|
|
68
|
-
*As far as the law allows, the software comes as is, without any warranty or
|
|
69
|
-
condition, and the licensor will not be liable to you for any damages arising
|
|
70
|
-
out of these terms or the use or nature of the software, under any kind of
|
|
71
|
-
legal claim.*
|
|
72
|
-
|
|
73
|
-
## Definitions
|
|
74
|
-
|
|
75
|
-
The **licensor** is the entity offering these terms, and the **software** is the
|
|
76
|
-
software the licensor makes available under these terms, including any portion
|
|
77
|
-
of it.
|
|
78
|
-
|
|
79
|
-
**you** refers to the individual or entity agreeing to these terms.
|
|
80
|
-
|
|
81
|
-
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
82
|
-
organization that you work for, plus all organizations that have control over,
|
|
83
|
-
are under the control of, or are under common control with that
|
|
84
|
-
organization. **control** means ownership of substantially all the assets of an
|
|
85
|
-
entity, or the power to direct its management and policies by vote, contract, or
|
|
86
|
-
otherwise. Control can be direct or indirect.
|
|
87
|
-
|
|
88
|
-
**your licenses** are all the licenses granted to you for the software under
|
|
89
|
-
these terms.
|
|
90
|
-
|
|
91
|
-
**use** means anything you do with the software requiring one of your licenses.
|
|
92
|
-
|
|
93
|
-
**trademark** means trademarks, service marks, and similar rights.
|