ai-world-sdk 1.5.7 → 1.5.8
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/__tests__/llm.real.test.d.ts +1 -3
- package/dist/__tests__/llm.real.test.js +34 -4
- package/dist/ai-config.d.ts +17 -0
- package/dist/ai-config.js +56 -0
- package/dist/cli/commands/ai-config.d.ts +2 -0
- package/dist/cli/commands/ai-config.js +61 -0
- package/dist/cli/commands/stats.js +20 -4
- package/dist/cli/index.js +2 -0
- package/dist/config.d.ts +3 -3
- package/dist/config.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/stats.d.ts +5 -2
- package/dist/stats.js +11 -0
- package/package.json +6 -6
- package/skills/ai-world-sdk/SKILL.md +2 -1
- package/skills/ai-world-sdk/docs/cli-commands.md +11 -1
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* llm.ts
|
|
2
|
+
* llm.ts 真实集成测试(文本生成 + kunpo 图像生成)
|
|
3
3
|
*
|
|
4
4
|
* 通过真实后端代理测试 createProvider 和 checkModel。
|
|
5
5
|
* 需要:
|
|
6
6
|
* 1. 运行中的后端服务 (http://localhost:8000)
|
|
7
7
|
* 2. .env 文件中配置 AUTH_TOKEN
|
|
8
8
|
*
|
|
9
|
-
* ⚠️ 图像生成测试由用户手动测试,此文件仅包含文本生成测试。
|
|
10
|
-
*
|
|
11
9
|
* 运行: npm run test:llm-real
|
|
12
10
|
*/
|
|
13
11
|
export {};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* llm.ts
|
|
3
|
+
* llm.ts 真实集成测试(文本生成 + kunpo 图像生成)
|
|
4
4
|
*
|
|
5
5
|
* 通过真实后端代理测试 createProvider 和 checkModel。
|
|
6
6
|
* 需要:
|
|
7
7
|
* 1. 运行中的后端服务 (http://localhost:8000)
|
|
8
8
|
* 2. .env 文件中配置 AUTH_TOKEN
|
|
9
9
|
*
|
|
10
|
-
* ⚠️ 图像生成测试由用户手动测试,此文件仅包含文本生成测试。
|
|
11
|
-
*
|
|
12
10
|
* 运行: npm run test:llm-real
|
|
13
11
|
*/
|
|
14
12
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -54,7 +52,8 @@ dotenv.config();
|
|
|
54
52
|
config_1.sdkConfig.setBaseUrl("http://localhost:8000");
|
|
55
53
|
config_1.sdkConfig.setToken(process.env.AUTH_TOKEN || process.env.TOKEN || "");
|
|
56
54
|
config_1.sdkConfig.setDebug(true);
|
|
57
|
-
|
|
55
|
+
const PLUGIN_ID = "test-plugin";
|
|
56
|
+
describe("llm.ts — 真实集成测试(文本 + 图像)", () => {
|
|
58
57
|
const token = process.env.AUTH_TOKEN || process.env.TOKEN;
|
|
59
58
|
beforeAll(() => {
|
|
60
59
|
if (!token) {
|
|
@@ -213,6 +212,32 @@ describe("llm.ts — 真实集成测试(文本生成)", () => {
|
|
|
213
212
|
}, 30000);
|
|
214
213
|
});
|
|
215
214
|
// ============================================================
|
|
215
|
+
// createProvider + generateImage(kunpo 图像生成)
|
|
216
|
+
// ============================================================
|
|
217
|
+
describe("createProvider + generateImage(kunpo 图像)", () => {
|
|
218
|
+
const promptArg = "A simple red circle on a white background";
|
|
219
|
+
test("kunpo — openai/gpt-5.4-image-2", async () => {
|
|
220
|
+
const modelId = process.env.KUNPO_IMAGE_MODEL || "openai/gpt-5.4-image-2";
|
|
221
|
+
const provider = (0, llm_1.createProvider)("kunpo", "openai", PLUGIN_ID);
|
|
222
|
+
const imageModel = provider.imageModel(modelId);
|
|
223
|
+
const result = await (0, ai_1.generateImage)({
|
|
224
|
+
model: imageModel,
|
|
225
|
+
prompt: promptArg,
|
|
226
|
+
n: 1,
|
|
227
|
+
size: "1024x1024",
|
|
228
|
+
});
|
|
229
|
+
expect(result.images).toBeDefined();
|
|
230
|
+
expect(result.images.length).toBeGreaterThan(0);
|
|
231
|
+
const first = result.images[0];
|
|
232
|
+
expect(first?.base64 || first?.uint8Array?.byteLength).toBeTruthy();
|
|
233
|
+
console.log("✅ Kunpo 图像生成:", {
|
|
234
|
+
model: modelId,
|
|
235
|
+
mediaType: first?.mediaType,
|
|
236
|
+
bytes: first?.uint8Array?.byteLength ?? first?.base64?.length,
|
|
237
|
+
});
|
|
238
|
+
}, 120000);
|
|
239
|
+
});
|
|
240
|
+
// ============================================================
|
|
216
241
|
// checkModel 真实可用性检查
|
|
217
242
|
// ============================================================
|
|
218
243
|
describe("checkModel(模型可用性检查)", () => {
|
|
@@ -263,10 +288,15 @@ describe("llm.ts — 真实集成测试(文本生成)", () => {
|
|
|
263
288
|
expect(() => (0, llm_1.createProvider)("api2img", "gemini", "test")).not.toThrow();
|
|
264
289
|
// Anthropic
|
|
265
290
|
expect(() => (0, llm_1.createProvider)("anthropic", "anthropic", "test")).not.toThrow();
|
|
291
|
+
expect(() => (0, llm_1.createProvider)("kunpo", "openai", "test")).not.toThrow();
|
|
266
292
|
});
|
|
267
293
|
test("provider 实例有 languageModel 方法", () => {
|
|
268
294
|
const provider = (0, llm_1.createProvider)("api2img", "openai", "test");
|
|
269
295
|
expect(typeof provider.languageModel).toBe("function");
|
|
270
296
|
});
|
|
297
|
+
test("kunpo provider 实例有 imageModel 方法", () => {
|
|
298
|
+
const provider = (0, llm_1.createProvider)("kunpo", "openai", "test");
|
|
299
|
+
expect(typeof provider.imageModel).toBe("function");
|
|
300
|
+
});
|
|
271
301
|
});
|
|
272
302
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Config Client
|
|
3
|
+
* 管理员 AI 配置(提供商、模型列表)
|
|
4
|
+
*/
|
|
5
|
+
export interface AIConfigClientConfig {
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
token?: string;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export declare class AIConfigClient {
|
|
11
|
+
private baseUrl;
|
|
12
|
+
private headers;
|
|
13
|
+
constructor(config?: AIConfigClientConfig);
|
|
14
|
+
private handleErrorResponse;
|
|
15
|
+
getProviders(): Promise<any>;
|
|
16
|
+
getProviderModels(providerId: string): Promise<any>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AI Config Client
|
|
4
|
+
* 管理员 AI 配置(提供商、模型列表)
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.AIConfigClient = void 0;
|
|
8
|
+
const config_1 = require("./config");
|
|
9
|
+
const log_1 = require("./log");
|
|
10
|
+
class AIConfigClient {
|
|
11
|
+
constructor(config = {}) {
|
|
12
|
+
this.baseUrl =
|
|
13
|
+
config.baseUrl ||
|
|
14
|
+
config_1.sdkConfig.getServerUrl() ||
|
|
15
|
+
(typeof window !== "undefined" ? window.location.origin : "");
|
|
16
|
+
const globalHeaders = config_1.sdkConfig.getHeaders();
|
|
17
|
+
const globalToken = config.token || config_1.sdkConfig.getToken();
|
|
18
|
+
this.headers = {
|
|
19
|
+
"Content-Type": "application/json",
|
|
20
|
+
...globalHeaders,
|
|
21
|
+
...config.headers,
|
|
22
|
+
};
|
|
23
|
+
if (globalToken) {
|
|
24
|
+
this.headers["Authorization"] = `Bearer ${globalToken}`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async handleErrorResponse(response) {
|
|
28
|
+
let errorMessage = `Request failed: ${response.status} ${response.statusText}`;
|
|
29
|
+
try {
|
|
30
|
+
const errorText = await response.text();
|
|
31
|
+
const errorJson = JSON.parse(errorText);
|
|
32
|
+
errorMessage = errorJson.detail || errorMessage;
|
|
33
|
+
}
|
|
34
|
+
catch { }
|
|
35
|
+
throw new Error(errorMessage);
|
|
36
|
+
}
|
|
37
|
+
async getProviders() {
|
|
38
|
+
config_1.sdkConfig.ensureVersionCompatible();
|
|
39
|
+
const url = `${this.baseUrl}/api/ai/config/providers`;
|
|
40
|
+
(0, log_1.logRequest)("GET", url, this.headers);
|
|
41
|
+
const response = await fetch(url, { headers: this.headers });
|
|
42
|
+
if (!response.ok)
|
|
43
|
+
await this.handleErrorResponse(response);
|
|
44
|
+
return await response.json();
|
|
45
|
+
}
|
|
46
|
+
async getProviderModels(providerId) {
|
|
47
|
+
config_1.sdkConfig.ensureVersionCompatible();
|
|
48
|
+
const url = `${this.baseUrl}/api/ai/config/providers/${encodeURIComponent(providerId)}/models`;
|
|
49
|
+
(0, log_1.logRequest)("GET", url, this.headers);
|
|
50
|
+
const response = await fetch(url, { headers: this.headers });
|
|
51
|
+
if (!response.ok)
|
|
52
|
+
await this.handleErrorResponse(response);
|
|
53
|
+
return await response.json();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.AIConfigClient = AIConfigClient;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerAiConfigCommands = registerAiConfigCommands;
|
|
4
|
+
const ai_config_1 = require("../../ai-config");
|
|
5
|
+
const config_1 = require("../config");
|
|
6
|
+
const output_1 = require("../output");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
function collectOpts(cmd) {
|
|
9
|
+
const chain = [];
|
|
10
|
+
for (let c = cmd; c; c = c.parent) {
|
|
11
|
+
chain.unshift(c);
|
|
12
|
+
}
|
|
13
|
+
const o = {};
|
|
14
|
+
for (const c of chain) {
|
|
15
|
+
Object.assign(o, c.opts());
|
|
16
|
+
}
|
|
17
|
+
return o;
|
|
18
|
+
}
|
|
19
|
+
function prepareAiConfig(program, cmd) {
|
|
20
|
+
const o = collectOpts(cmd);
|
|
21
|
+
const auth = (0, config_1.resolveAuth)({
|
|
22
|
+
baseUrl: o.baseUrl,
|
|
23
|
+
token: o.token,
|
|
24
|
+
pluginId: o.pluginId,
|
|
25
|
+
});
|
|
26
|
+
(0, utils_1.requireOption)(auth.token, 'token');
|
|
27
|
+
(0, utils_1.initSDK)(auth);
|
|
28
|
+
return (0, utils_1.getFormat)(program);
|
|
29
|
+
}
|
|
30
|
+
function registerAiConfigCommands(program) {
|
|
31
|
+
const aiConfig = program
|
|
32
|
+
.command('ai-config')
|
|
33
|
+
.description('AI 配置(提供商与模型列表)');
|
|
34
|
+
aiConfig.command('providers').action(async (_opts, cmd) => {
|
|
35
|
+
const commandName = 'ai-config providers';
|
|
36
|
+
try {
|
|
37
|
+
const format = prepareAiConfig(program, cmd);
|
|
38
|
+
const client = new ai_config_1.AIConfigClient();
|
|
39
|
+
const result = await client.getProviders();
|
|
40
|
+
(0, output_1.output)(result, format);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
(0, utils_1.handleError)(err, commandName);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
aiConfig
|
|
47
|
+
.command('models')
|
|
48
|
+
.requiredOption('--provider <id>', '提供商 ID')
|
|
49
|
+
.action(async (opts, cmd) => {
|
|
50
|
+
const commandName = 'ai-config models';
|
|
51
|
+
try {
|
|
52
|
+
const format = prepareAiConfig(program, cmd);
|
|
53
|
+
const client = new ai_config_1.AIConfigClient();
|
|
54
|
+
const result = await client.getProviderModels(opts.provider);
|
|
55
|
+
(0, output_1.output)(result, format);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
(0, utils_1.handleError)(err, commandName);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -30,9 +30,9 @@ function prepareStats(program, cmd) {
|
|
|
30
30
|
function parsePeriod(raw) {
|
|
31
31
|
if (raw === undefined)
|
|
32
32
|
return undefined;
|
|
33
|
-
if (raw === 'daily' || raw === 'weekly' || raw === 'monthly')
|
|
33
|
+
if (raw === 'hourly' || raw === 'daily' || raw === 'weekly' || raw === 'monthly')
|
|
34
34
|
return raw;
|
|
35
|
-
const err = new Error('period 必须是 daily | weekly | monthly');
|
|
35
|
+
const err = new Error('period 必须是 hourly | daily | weekly | monthly');
|
|
36
36
|
err.code = 'VALIDATION_ERROR';
|
|
37
37
|
throw err;
|
|
38
38
|
}
|
|
@@ -116,8 +116,10 @@ function registerStatsCommands(program) {
|
|
|
116
116
|
});
|
|
117
117
|
stats
|
|
118
118
|
.command('ai-trend')
|
|
119
|
-
.option('--period <p>', 'daily | weekly | monthly', 'daily')
|
|
119
|
+
.option('--period <p>', 'hourly | daily | weekly | monthly', 'daily')
|
|
120
120
|
.option('--days <n>', '天数', (v) => parseInt(v, 10))
|
|
121
|
+
.option('--start-date <date>', '开始日期')
|
|
122
|
+
.option('--end-date <date>', '结束日期')
|
|
121
123
|
.option('--provider <name>', '提供商')
|
|
122
124
|
.option('--model <id>', '模型')
|
|
123
125
|
.option('--user-id <n>', '用户 ID', (v) => parseInt(v, 10))
|
|
@@ -131,6 +133,8 @@ function registerStatsCommands(program) {
|
|
|
131
133
|
const result = await client.getAiApiCallsTrend({
|
|
132
134
|
period,
|
|
133
135
|
days: opts.days,
|
|
136
|
+
startDate: opts.startDate,
|
|
137
|
+
endDate: opts.endDate,
|
|
134
138
|
userId: opts.userId,
|
|
135
139
|
apiType: opts.apiType,
|
|
136
140
|
provider: opts.provider,
|
|
@@ -142,9 +146,21 @@ function registerStatsCommands(program) {
|
|
|
142
146
|
(0, utils_1.handleError)(err, commandName);
|
|
143
147
|
}
|
|
144
148
|
});
|
|
149
|
+
stats.command('ai-filters').action(async (_opts, cmd) => {
|
|
150
|
+
const commandName = 'stats ai-filters';
|
|
151
|
+
try {
|
|
152
|
+
const format = prepareStats(program, cmd);
|
|
153
|
+
const client = new stats_1.StatsClient();
|
|
154
|
+
const result = await client.getAiApiCallsFilters();
|
|
155
|
+
(0, output_1.output)(result, format);
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
(0, utils_1.handleError)(err, commandName);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
145
161
|
stats
|
|
146
162
|
.command('ai-trend-by-user')
|
|
147
|
-
.option('--period <p>', 'daily | weekly | monthly', 'daily')
|
|
163
|
+
.option('--period <p>', 'hourly | daily | weekly | monthly', 'daily')
|
|
148
164
|
.option('--days <n>', '天数', (v) => parseInt(v, 10))
|
|
149
165
|
.option('--limit <n>', '条数上限', (v) => parseInt(v, 10))
|
|
150
166
|
.option('--provider <name>', '提供商')
|
package/dist/cli/index.js
CHANGED
|
@@ -101,6 +101,7 @@ const skill_1 = require("./commands/skill");
|
|
|
101
101
|
const plugin_1 = require("./commands/plugin");
|
|
102
102
|
const admin_1 = require("./commands/admin");
|
|
103
103
|
const stats_1 = require("./commands/stats");
|
|
104
|
+
const ai_config_1 = require("./commands/ai-config");
|
|
104
105
|
const shared_1 = require("./commands/shared");
|
|
105
106
|
const chrome_1 = require("./commands/chrome");
|
|
106
107
|
(0, help_1.registerHelpCommand)(program);
|
|
@@ -117,6 +118,7 @@ const chrome_1 = require("./commands/chrome");
|
|
|
117
118
|
(0, plugin_1.registerPluginCommands)(program);
|
|
118
119
|
(0, admin_1.registerAdminCommands)(program);
|
|
119
120
|
(0, stats_1.registerStatsCommands)(program);
|
|
121
|
+
(0, ai_config_1.registerAiConfigCommands)(program);
|
|
120
122
|
(0, shared_1.registerSharedCommands)(program);
|
|
121
123
|
(0, chrome_1.registerChromeCommands)(program);
|
|
122
124
|
program.parseAsync(process.argv).catch((err) => {
|
package/dist/config.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* 注意: {VERSION} 占位符会在构建时被替换为实际版本号
|
|
11
11
|
*/
|
|
12
|
-
export declare const SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.
|
|
12
|
+
export declare const SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.8";
|
|
13
13
|
/**
|
|
14
14
|
* 版本兼容性错误
|
|
15
15
|
*/
|
|
@@ -35,8 +35,8 @@ declare class SDKConfig {
|
|
|
35
35
|
private _authCheckPromise;
|
|
36
36
|
private _currentUser;
|
|
37
37
|
private _cliMode;
|
|
38
|
-
readonly sdkSignature = "AI_WORLD_SDK_V:1.5.
|
|
39
|
-
readonly sdkVersion = "1.5.
|
|
38
|
+
readonly sdkSignature = "AI_WORLD_SDK_V:1.5.8";
|
|
39
|
+
readonly sdkVersion = "1.5.8";
|
|
40
40
|
constructor();
|
|
41
41
|
/**
|
|
42
42
|
* Set global base URL
|
package/dist/config.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.sdkConfig = exports.VersionCompatibilityError = exports.SDK_SIGNATURE = void 0;
|
|
8
8
|
// SDK 版本号(构建时自动从 package.json 更新)
|
|
9
9
|
// 此版本号会在运行 npm run build 时自动从 package.json 读取并更新
|
|
10
|
-
const SDK_VERSION = "1.5.
|
|
10
|
+
const SDK_VERSION = "1.5.8";
|
|
11
11
|
/**
|
|
12
12
|
* SDK 特征码 - 用于在构建后的 JS 文件中识别 SDK 版本
|
|
13
13
|
* 格式: AI_WORLD_SDK_V:版本号
|
|
@@ -15,7 +15,7 @@ const SDK_VERSION = "1.5.7";
|
|
|
15
15
|
*
|
|
16
16
|
* 注意: {VERSION} 占位符会在构建时被替换为实际版本号
|
|
17
17
|
*/
|
|
18
|
-
exports.SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.
|
|
18
|
+
exports.SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.8";
|
|
19
19
|
/**
|
|
20
20
|
* 版本兼容性错误
|
|
21
21
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export { AuthClient, getCurrentUserInfo, type AuthConfig, type UserInfo, };
|
|
|
36
36
|
export { AdminClient, type AdminClientConfig, type AdminUserInfo, type AdminUserListResponse, type ListUsersOptions, type RoleInfo, type CreateRoleData, type UpdateRoleData, type RoleUserCount, type TableColumn, type TableDataResponse, type ListTableDataOptions, } from "./admin";
|
|
37
37
|
export { PluginManagementClient, type PluginManagementClientConfig, type PluginInfo, type PluginListResponse, type ListPluginsOptions, type CreatePluginData, type PluginStatus, type PluginTemplateInfo, type PluginTemplateListResponse, type ListPluginTemplatesOptions, type CreatePluginTemplateData, type UpdatePluginTemplateData, } from "./plugin-management";
|
|
38
38
|
export { StatsClient, DashboardClient, type StatsClientConfig, type AiApiCallsOptions, type AiApiCallsTrendOptions, type AiApiCallsTrendByUserOptions, type PluginAccessOptions, } from "./stats";
|
|
39
|
+
export { AIConfigClient, type AIConfigClientConfig, } from "./ai-config";
|
|
39
40
|
export { SharedResourceClient, type SharedResourceClientConfig, type SharedResourceInfo, type SharedResourceListResponse, type ListSharedResourceOptions, type UpdateSharedResourceData, } from "./shared-resource";
|
|
40
41
|
export { ChromeExtensionClient, type ChromeExtensionClientConfig, type ChromeExtensionInfo, type ChromeExtensionListResponse, type ListChromeExtensionsOptions, type CreateChromeExtensionData, } from "./chrome-extension";
|
|
41
42
|
export { sdkConfig, VersionCompatibilityError, SDK_SIGNATURE, type AuthenticatedUser } from "./config";
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
20
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.SDK_SIGNATURE = exports.VersionCompatibilityError = exports.sdkConfig = exports.ChromeExtensionClient = exports.SharedResourceClient = exports.DashboardClient = exports.StatsClient = exports.PluginManagementClient = exports.AdminClient = exports.getCurrentUserInfo = exports.AuthClient = exports.AgentSkillClient = exports.VersionedResourceClient = exports.ResourceClient = exports.MinioStorageClient = exports.DownloadClient = exports.OpenAIVideoGenerationClient = exports.VideoUnderstandingClient = exports.VideoGenerationClient = exports.GeminiImageGenerationClient = exports.DoubaoImageGenerationClient = exports.ChatAnthropic = exports.ChatGoogleGenerativeAI = exports.ChatOpenAI = exports.BaseChatModel = exports.AIMessageChunk = exports.SystemMessage = exports.AIMessage = exports.HumanMessage = void 0;
|
|
23
|
+
exports.SDK_SIGNATURE = exports.VersionCompatibilityError = exports.sdkConfig = exports.ChromeExtensionClient = exports.SharedResourceClient = exports.AIConfigClient = exports.DashboardClient = exports.StatsClient = exports.PluginManagementClient = exports.AdminClient = exports.getCurrentUserInfo = exports.AuthClient = exports.AgentSkillClient = exports.VersionedResourceClient = exports.ResourceClient = exports.MinioStorageClient = exports.DownloadClient = exports.OpenAIVideoGenerationClient = exports.VideoUnderstandingClient = exports.VideoGenerationClient = exports.GeminiImageGenerationClient = exports.DoubaoImageGenerationClient = exports.ChatAnthropic = exports.ChatGoogleGenerativeAI = exports.ChatOpenAI = exports.BaseChatModel = exports.AIMessageChunk = exports.SystemMessage = exports.AIMessage = exports.HumanMessage = void 0;
|
|
24
24
|
exports.createChatModel = createChatModel;
|
|
25
25
|
const openai_1 = require("./chat_models/openai");
|
|
26
26
|
const google_1 = require("./chat_models/google");
|
|
@@ -76,6 +76,9 @@ Object.defineProperty(exports, "PluginManagementClient", { enumerable: true, get
|
|
|
76
76
|
var stats_1 = require("./stats");
|
|
77
77
|
Object.defineProperty(exports, "StatsClient", { enumerable: true, get: function () { return stats_1.StatsClient; } });
|
|
78
78
|
Object.defineProperty(exports, "DashboardClient", { enumerable: true, get: function () { return stats_1.DashboardClient; } });
|
|
79
|
+
// Export AI config client
|
|
80
|
+
var ai_config_1 = require("./ai-config");
|
|
81
|
+
Object.defineProperty(exports, "AIConfigClient", { enumerable: true, get: function () { return ai_config_1.AIConfigClient; } });
|
|
79
82
|
// Export shared resource client
|
|
80
83
|
var shared_resource_1 = require("./shared-resource");
|
|
81
84
|
Object.defineProperty(exports, "SharedResourceClient", { enumerable: true, get: function () { return shared_resource_1.SharedResourceClient; } });
|
package/dist/stats.d.ts
CHANGED
|
@@ -17,15 +17,17 @@ export interface AiApiCallsOptions {
|
|
|
17
17
|
pageSize?: number;
|
|
18
18
|
}
|
|
19
19
|
export interface AiApiCallsTrendOptions {
|
|
20
|
-
period?: "daily" | "weekly" | "monthly";
|
|
20
|
+
period?: "hourly" | "daily" | "weekly" | "monthly";
|
|
21
21
|
days?: number;
|
|
22
|
+
startDate?: string;
|
|
23
|
+
endDate?: string;
|
|
22
24
|
userId?: number;
|
|
23
25
|
apiType?: string;
|
|
24
26
|
provider?: string;
|
|
25
27
|
model?: string;
|
|
26
28
|
}
|
|
27
29
|
export interface AiApiCallsTrendByUserOptions {
|
|
28
|
-
period?: "daily" | "weekly" | "monthly";
|
|
30
|
+
period?: "hourly" | "daily" | "weekly" | "monthly";
|
|
29
31
|
days?: number;
|
|
30
32
|
apiType?: string;
|
|
31
33
|
provider?: string;
|
|
@@ -47,6 +49,7 @@ export declare class StatsClient {
|
|
|
47
49
|
getAiApiCalls(options?: AiApiCallsOptions): Promise<any>;
|
|
48
50
|
getAiApiCallsSummary(): Promise<any>;
|
|
49
51
|
getAiApiCallsTrend(options?: AiApiCallsTrendOptions): Promise<any>;
|
|
52
|
+
getAiApiCallsFilters(): Promise<any>;
|
|
50
53
|
getAiApiCallsTrendByUser(options?: AiApiCallsTrendByUserOptions): Promise<any>;
|
|
51
54
|
getPluginAccess(options?: PluginAccessOptions): Promise<any>;
|
|
52
55
|
getPluginAccessSummary(): Promise<any>;
|
package/dist/stats.js
CHANGED
|
@@ -78,6 +78,8 @@ class StatsClient {
|
|
|
78
78
|
const url = this.buildUrl("/api/stats/ai-api-calls/trend", {
|
|
79
79
|
period: options.period,
|
|
80
80
|
days: options.days,
|
|
81
|
+
start_date: options.startDate,
|
|
82
|
+
end_date: options.endDate,
|
|
81
83
|
user_id: options.userId,
|
|
82
84
|
api_type: options.apiType,
|
|
83
85
|
provider: options.provider,
|
|
@@ -89,6 +91,15 @@ class StatsClient {
|
|
|
89
91
|
await this.handleErrorResponse(response);
|
|
90
92
|
return await response.json();
|
|
91
93
|
}
|
|
94
|
+
async getAiApiCallsFilters() {
|
|
95
|
+
config_1.sdkConfig.ensureVersionCompatible();
|
|
96
|
+
const url = `${this.baseUrl}/api/stats/ai-api-calls/filters`;
|
|
97
|
+
(0, log_1.logRequest)("GET", url, this.headers);
|
|
98
|
+
const response = await fetch(url, { headers: this.headers });
|
|
99
|
+
if (!response.ok)
|
|
100
|
+
await this.handleErrorResponse(response);
|
|
101
|
+
return await response.json();
|
|
102
|
+
}
|
|
92
103
|
async getAiApiCallsTrendByUser(options = {}) {
|
|
93
104
|
config_1.sdkConfig.ensureVersionCompatible();
|
|
94
105
|
const url = this.buildUrl("/api/stats/ai-api-calls/trend/by-user", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-world-sdk",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
4
4
|
"description": "TypeScript SDK for AI World Platform - Chat Models, Image Generation, and Video Generation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -78,11 +78,11 @@
|
|
|
78
78
|
"skills"
|
|
79
79
|
],
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
82
|
-
"@ai-sdk/google": "^3.0.
|
|
83
|
-
"@ai-sdk/openai": "^3.0.
|
|
84
|
-
"@openrouter/ai-sdk-provider": "
|
|
85
|
-
"ai": "^6.0.
|
|
81
|
+
"@ai-sdk/anthropic": "^3.0.78",
|
|
82
|
+
"@ai-sdk/google": "^3.0.75",
|
|
83
|
+
"@ai-sdk/openai": "^3.0.64",
|
|
84
|
+
"@openrouter/ai-sdk-provider": "./pacakges/ai-sdk-provider",
|
|
85
|
+
"ai": "^6.0.162",
|
|
86
86
|
"commander": "^14.0.3",
|
|
87
87
|
"undici": "^8.1.0"
|
|
88
88
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ai-world-sdk
|
|
3
|
-
description: Use when initializing ai-world-sdk, calling AI models in ai-world projects, or using the ai-world CLI. Covers sdkConfig initialization, createProvider with Vercel AI SDK (generateText, streamText, generateImage), Doubao image/video generation/understanding, MinIO object storage (MinioStorageClient), resource management with ACL (ResourceClient), versioned resource management (VersionedResourceClient), agent skills management (AgentSkillClient), VSCode extension login (initAIWorld), user auth (AuthClient, getCurrentUserInfo), download proxy (DownloadClient), admin management (AdminClient for user/role/database), plugin management (PluginManagementClient), statistics (StatsClient, DashboardClient), shared resources (SharedResourceClient), chrome extensions (ChromeExtensionClient), and CLI command-line tool (ai-world). Triggers on ai-world-sdk, ai-world, cli, 命令行, npx ai-world, command line, createProvider, sdkConfig, generateText, streamText, generateImage, doubao, video understanding, VideoUnderstandingClient, MinioStorageClient, minio, ResourceClient, resource management, access control, file sharing, VersionedResourceClient, versioned resource, version management, AgentSkillClient, agent skill, vscode extension, initAIWorld, AuthClient, getCurrentUserInfo, DownloadClient, AdminClient, admin API, user management, role management, database management, PluginManagementClient, plugin management, StatsClient, DashboardClient, statistics, SharedResourceClient, shared resources, ChromeExtensionClient, chrome extension, or any AI model integration.
|
|
3
|
+
description: Use when initializing ai-world-sdk, calling AI models in ai-world projects, or using the ai-world CLI. Covers sdkConfig initialization, createProvider with Vercel AI SDK (generateText, streamText, generateImage), Doubao image/video generation/understanding, MinIO object storage (MinioStorageClient), resource management with ACL (ResourceClient), versioned resource management (VersionedResourceClient), agent skills management (AgentSkillClient), VSCode extension login (initAIWorld), user auth (AuthClient, getCurrentUserInfo), download proxy (DownloadClient), admin management (AdminClient for user/role/database), plugin management (PluginManagementClient), AI config listing (AIConfigClient, getProviders, getProviderModels), statistics (StatsClient, DashboardClient), shared resources (SharedResourceClient), chrome extensions (ChromeExtensionClient), and CLI command-line tool (ai-world). Triggers on ai-world-sdk, ai-world, cli, 命令行, npx ai-world, command line, createProvider, sdkConfig, generateText, streamText, generateImage, doubao, video understanding, VideoUnderstandingClient, MinioStorageClient, minio, ResourceClient, resource management, access control, file sharing, VersionedResourceClient, versioned resource, version management, AgentSkillClient, agent skill, vscode extension, initAIWorld, AuthClient, getCurrentUserInfo, DownloadClient, AdminClient, admin API, user management, role management, database management, PluginManagementClient, plugin management, StatsClient, DashboardClient, statistics, SharedResourceClient, shared resources, ChromeExtensionClient, chrome extension, or any AI model integration.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# AI World SDK
|
|
@@ -264,6 +264,7 @@ for await (const chunk of stream.textStream) {
|
|
|
264
264
|
|
|
265
265
|
### 平台通用 API → `docs/platform-api.md`
|
|
266
266
|
|
|
267
|
+
- `AIConfigClient` — 配置驱动的 AI 供应商与模型列表(登录即可):`getProviders()`、`getProviderModels(providerId)`
|
|
267
268
|
- `PluginManagementClient` — 插件 CRUD(`create` / `update` 分离)、启用/禁用/重载/重启、模板管理
|
|
268
269
|
- `create(data)` — 创建新插件(POST `/api/plugins/create`),插件不存在时使用
|
|
269
270
|
- `update(data)` — 更新已有插件(POST `/api/plugins/update`),插件必须已存在,未传入的字段保留原值
|
|
@@ -35,6 +35,15 @@ ai-world config reset [key] # 重置配置(不指定则全部重
|
|
|
35
35
|
|
|
36
36
|
默认值:`base-url`=`https://aiworld.local:8000`、`plugin-id`=`cli`、`provider`=`kunpo`、`endpoint`=`openai`、`model`=`deepseek/deepseek-v4-pro`、`format`=`json`
|
|
37
37
|
|
|
38
|
+
## ai-config — 平台 AI 配置(登录即可,与 CLI `config` 不同)
|
|
39
|
+
|
|
40
|
+
后端配置驱动的供应商与模型列表(`GET /api/ai/config/...`)。
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
ai-world ai-config providers # 列出 AI 供应商
|
|
44
|
+
ai-world ai-config models --provider <provider_id> # 列出某供应商下的模型
|
|
45
|
+
```
|
|
46
|
+
|
|
38
47
|
## text — 文本生成
|
|
39
48
|
|
|
40
49
|
```bash
|
|
@@ -179,7 +188,8 @@ ai-world stats plugin-access [--user-id 1] [--plugin-id my-plugin] [--page 1]
|
|
|
179
188
|
ai-world stats plugin-access-summary
|
|
180
189
|
ai-world stats ai-calls [--provider api2img] [--model gpt-4o-mini] [--plugin-id my-plugin]
|
|
181
190
|
ai-world stats ai-calls-summary
|
|
182
|
-
ai-world stats ai-
|
|
191
|
+
ai-world stats ai-filters # 从实际数据返回可选筛选值(api_type / provider / model / plugin_id)
|
|
192
|
+
ai-world stats ai-trend [--period hourly|daily|weekly|monthly] [--days 30] [--start-date YYYY-MM-DD] [--end-date YYYY-MM-DD]
|
|
183
193
|
ai-world stats ai-trend-by-user [--period daily] [--days 30] [--limit 10]
|
|
184
194
|
ai-world stats dashboard
|
|
185
195
|
```
|