@yuku123/z-team-component 0.2.50 → 0.2.52
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/{ComponentDoc-DQqssf25.js → ComponentDoc-Cky9jCGu.js} +1 -1
- package/dist/{InvitationManagementPage-VP4Z5dfA.js → InvitationManagementPage-BsbaIGvB.js} +1 -1
- package/dist/{OnboardingPage-DItjgM-n.js → OnboardingPage-CHVgeBiO.js} +2 -2
- package/dist/{SystemShell-5h2iViyD.js → SystemShell-4OiqvM11.js} +1 -1
- package/dist/{api-yLI7Ykc0.js → api-BT968Uwc.js} +1 -1
- package/dist/{index-CLLTeFL6.js → index-B11_fFjX.js} +1 -1
- package/dist/{index-DDFDZ3CZ.js → index-B3-0eXYQ.js} +1 -1
- package/dist/{index-dPkeRBwq.js → index-B_C7H9WL.js} +2 -2
- package/dist/{index-B6bDmTPW.js → index-CdlfWFvS.js} +430 -431
- package/dist/{index-CKCDXE2N.js → index-Cp3DAwNx.js} +1 -1
- package/dist/{index-uQn3pzQd.js → index-DxFZKDq-.js} +2 -2
- package/dist/{index-td6dkPa2.js → index-LwKUkzKI.js} +1 -1
- package/dist/{index-BzBTizx3.js → index-NaBR2aQE.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/pages.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as s, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { CopyOutlined as se, ReloadOutlined as Te, PlusOutlined as Se, DeleteOutlined as Oe, ClearOutlined as De, CloseOutlined as Le, SendOutlined as ze, RobotOutlined as Ce, CloudServerOutlined as Re, MessageOutlined as Ue, KeyOutlined as He, ApiOutlined as je, ToolOutlined as qe, BarChartOutlined as Fe } from "@ant-design/icons";
|
|
3
|
-
import { Tooltip as W, Tabs as Ae, Button as
|
|
4
|
-
import { useState as
|
|
3
|
+
import { Tooltip as W, Tabs as Ae, Button as R, Modal as de, Input as we, Drawer as xe, Spin as V, Statistic as $, Table as Ke, message as G, Tag as J, Select as Ge, Checkbox as Je } from "antd";
|
|
4
|
+
import { useState as S, useEffect as X, useCallback as q, useRef as me, useMemo as Me, Suspense as Qe, lazy as We } from "react";
|
|
5
5
|
import { s as t } from "./SmartWorkbench.module-xRRmpTTw.js";
|
|
6
6
|
import { u as be } from "./useAppStore-ibJyVIAX.js";
|
|
7
7
|
import { AgentAppList as Ye, McpPage as Ve, SkillMarket as Xe } from "@yuku123/z-agent-component";
|
|
@@ -51,8 +51,8 @@ async function ge() {
|
|
|
51
51
|
return l.map(Ze);
|
|
52
52
|
}
|
|
53
53
|
async function et(a, n, l, o) {
|
|
54
|
-
var
|
|
55
|
-
const
|
|
54
|
+
var M, D, x;
|
|
55
|
+
const m = await fetch(`${he}/v1/chat/completions`, {
|
|
56
56
|
method: "POST",
|
|
57
57
|
headers: {
|
|
58
58
|
"Content-Type": "application/json",
|
|
@@ -66,67 +66,66 @@ async function et(a, n, l, o) {
|
|
|
66
66
|
}),
|
|
67
67
|
signal: o.signal
|
|
68
68
|
});
|
|
69
|
-
if (!
|
|
70
|
-
const T = await
|
|
69
|
+
if (!m.ok || !m.body) {
|
|
70
|
+
const T = await m.text().catch(() => "");
|
|
71
71
|
if (/<!doctype html/i.test(T.slice(0, 200)))
|
|
72
72
|
throw new Error("模型网关未接入(/v1/chat/completions 落到主壳 SPA,无网关响应)");
|
|
73
|
-
let
|
|
73
|
+
let A = `HTTP ${m.status}`;
|
|
74
74
|
try {
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const h = JSON.parse(T);
|
|
76
|
+
A = ((M = h == null ? void 0 : h.error) == null ? void 0 : M.message) ?? A;
|
|
77
77
|
} catch {
|
|
78
|
-
T && (
|
|
78
|
+
T && (A = T);
|
|
79
79
|
}
|
|
80
|
-
throw new Error(
|
|
80
|
+
throw new Error(A);
|
|
81
81
|
}
|
|
82
|
-
const
|
|
83
|
-
let
|
|
82
|
+
const N = m.body.getReader(), v = new TextDecoder();
|
|
83
|
+
let y = "", g;
|
|
84
84
|
try {
|
|
85
85
|
for (; ; ) {
|
|
86
|
-
const { done: T, value:
|
|
86
|
+
const { done: T, value: A } = await N.read();
|
|
87
87
|
if (T) break;
|
|
88
|
-
|
|
89
|
-
const
|
|
88
|
+
y += v.decode(A, { stream: !0 });
|
|
89
|
+
const h = y.split(`
|
|
90
90
|
|
|
91
91
|
`);
|
|
92
|
-
|
|
93
|
-
for (const
|
|
94
|
-
let
|
|
95
|
-
for (const
|
|
92
|
+
y = h.pop() ?? "";
|
|
93
|
+
for (const c of h) {
|
|
94
|
+
let k = "";
|
|
95
|
+
for (const d of c.split(`
|
|
96
96
|
`))
|
|
97
|
-
|
|
98
|
-
if (!
|
|
99
|
-
if (
|
|
97
|
+
d.startsWith("data:") && (k += d.slice(5).trim());
|
|
98
|
+
if (!k || k === "[DONE]") {
|
|
99
|
+
if (k === "[DONE]") {
|
|
100
100
|
o.onDone(g);
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
105
105
|
try {
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
o.onDone(g);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
continue;
|
|
106
|
+
const d = JSON.parse(k), K = d == null ? void 0 : d.choices;
|
|
107
|
+
if (d != null && d.usage) {
|
|
108
|
+
const _ = {
|
|
109
|
+
promptTokens: d.usage.prompt_tokens ?? 0,
|
|
110
|
+
completionTokens: d.usage.completion_tokens ?? 0,
|
|
111
|
+
totalTokens: d.usage.total_tokens ?? 0
|
|
112
|
+
};
|
|
113
|
+
(!g || _.totalTokens > 0) && (g = _);
|
|
118
114
|
}
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
if (Array.isArray(K) && K.length > 0) {
|
|
116
|
+
const _ = (D = K[0]) == null ? void 0 : D.delta;
|
|
117
|
+
_ != null && _.content && o.onDelta(_.content);
|
|
118
|
+
continue;
|
|
122
119
|
}
|
|
120
|
+
o.onDone(g);
|
|
121
|
+
return;
|
|
123
122
|
} catch {
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
o.onDone(g);
|
|
128
127
|
} catch (T) {
|
|
129
|
-
if ((
|
|
128
|
+
if ((x = o.signal) != null && x.aborted) return;
|
|
130
129
|
throw o.onError(T instanceof Error ? T : new Error(String(T))), T;
|
|
131
130
|
}
|
|
132
131
|
}
|
|
@@ -176,15 +175,15 @@ async function Ee(a, n, l) {
|
|
|
176
175
|
ownerUserId: a,
|
|
177
176
|
ownerUserName: n
|
|
178
177
|
})
|
|
179
|
-
}),
|
|
180
|
-
return
|
|
178
|
+
}), m = await ae(o, "创建 AK"), N = (m == null ? void 0 : m.data) ?? {}, v = N.accessKey ?? "", y = N.secretKey ?? "";
|
|
179
|
+
return v && y && ke(v, y), { apiKey: y, akPrefix: v, message: "AK 已创建,secretKey 仅创建时可见" };
|
|
181
180
|
}
|
|
182
181
|
async function ie(a) {
|
|
183
182
|
const n = await fetch(
|
|
184
183
|
`${Z}/api/ak/list`,
|
|
185
184
|
{ headers: ee({ Accept: "application/json" }), credentials: "include" }
|
|
186
185
|
), l = await ae(n, "获取 AK 列表"), o = Array.isArray(l == null ? void 0 : l.data) ? l.data : [];
|
|
187
|
-
return (a ? o.filter((
|
|
186
|
+
return (a ? o.filter((N) => (N.owner_user_id == null || N.owner_user_id === "" ? _e : String(N.owner_user_id)) === String(a)) : o).filter((N) => (N.is_deleted ?? 0) === 0).map(tt);
|
|
188
187
|
}
|
|
189
188
|
async function at(a) {
|
|
190
189
|
const n = await fetch(`${Z}/api/ak/delete?id=${encodeURIComponent(String(a))}`, {
|
|
@@ -195,59 +194,59 @@ async function at(a) {
|
|
|
195
194
|
await ae(n, "吊销 AK");
|
|
196
195
|
}
|
|
197
196
|
async function Pe(a) {
|
|
198
|
-
var
|
|
197
|
+
var T, A;
|
|
199
198
|
const n = await fetch(
|
|
200
199
|
`${Z}/api/admin/llm-call-monitor/stats?hours=168`,
|
|
201
200
|
{ headers: ee({ Accept: "application/json" }), credentials: "include" }
|
|
202
|
-
), l = await ae(n, "获取调用统计"),
|
|
203
|
-
let
|
|
201
|
+
), l = await ae(n, "获取调用统计"), m = ((l == null ? void 0 : l.data) ?? {}).summary ?? {};
|
|
202
|
+
let N = [];
|
|
204
203
|
try {
|
|
205
|
-
const
|
|
204
|
+
const h = await fetch(
|
|
206
205
|
`${Z}/api/admin/llm-call-monitor/recent?page=1&size=20`,
|
|
207
206
|
{ headers: ee({ Accept: "application/json" }), credentials: "include" }
|
|
208
|
-
),
|
|
209
|
-
|
|
210
|
-
const
|
|
207
|
+
), c = await ae(h, "获取调用明细");
|
|
208
|
+
N = (Array.isArray((T = c == null ? void 0 : c.data) == null ? void 0 : T.records) ? c.data.records : []).map((d, K) => {
|
|
209
|
+
const _ = Number(d.promptTokens ?? 0), F = Number(d.completionTokens ?? 0);
|
|
211
210
|
return {
|
|
212
|
-
id: Number(
|
|
211
|
+
id: Number(d.id ?? K),
|
|
213
212
|
apiKeyId: a,
|
|
214
213
|
protocol: "chat/completions",
|
|
215
|
-
model: String(
|
|
216
|
-
stream: Number(
|
|
217
|
-
promptTokens:
|
|
218
|
-
completionTokens:
|
|
219
|
-
totalTokens: Number(
|
|
220
|
-
latencyMs: Number(
|
|
221
|
-
statusCode:
|
|
222
|
-
errorMsg:
|
|
223
|
-
createTime: String(
|
|
214
|
+
model: String(d.model ?? ""),
|
|
215
|
+
stream: Number(d.stream ?? 0),
|
|
216
|
+
promptTokens: _,
|
|
217
|
+
completionTokens: F,
|
|
218
|
+
totalTokens: Number(d.totalTokens ?? _ + F),
|
|
219
|
+
latencyMs: Number(d.durationMs ?? 0),
|
|
220
|
+
statusCode: d.success === !1 || d.success === 0 ? 500 : 200,
|
|
221
|
+
errorMsg: d.errorType ?? null,
|
|
222
|
+
createTime: String(d.createTime ?? "").replace("T", " ").slice(0, 19)
|
|
224
223
|
};
|
|
225
224
|
});
|
|
226
225
|
} catch {
|
|
227
226
|
}
|
|
228
|
-
const
|
|
229
|
-
for (const
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
if (
|
|
234
|
-
const
|
|
235
|
-
|
|
227
|
+
const v = {}, y = {};
|
|
228
|
+
for (const h of N) {
|
|
229
|
+
const c = v[A = h.model] || (v[A] = [0, 0, 0]);
|
|
230
|
+
c[0] += 1, c[1] += h.promptTokens, c[2] += h.completionTokens;
|
|
231
|
+
const k = (h.createTime || "").slice(0, 10);
|
|
232
|
+
if (k) {
|
|
233
|
+
const d = y[k] || (y[k] = [0, 0, 0]);
|
|
234
|
+
d[0] += 1, d[1] += h.promptTokens, d[2] += h.completionTokens;
|
|
236
235
|
}
|
|
237
236
|
}
|
|
238
|
-
const g = Number(
|
|
237
|
+
const g = Number(m.totalTokens ?? 0), M = N.reduce((h, c) => h + c.totalTokens, 0), D = N.reduce((h, c) => h + c.promptTokens, 0), x = N.reduce((h, c) => h + c.completionTokens, 0);
|
|
239
238
|
return {
|
|
240
|
-
totalRequests: Number(
|
|
239
|
+
totalRequests: Number(m.totalCount ?? 0),
|
|
241
240
|
// 汇总口径优先用后端整窗合计(后端 selectStats 才有 token 合计),
|
|
242
241
|
// 明细只有最近一页 ⇒ 只在汇总缺失时用明细兜底。
|
|
243
|
-
totalPromptTokens: Number(
|
|
244
|
-
totalCompletionTokens: Number(
|
|
245
|
-
totalTokens: g ||
|
|
246
|
-
avgLatencyMs: Number(
|
|
247
|
-
errorCount: Number(
|
|
248
|
-
daily:
|
|
249
|
-
models:
|
|
250
|
-
recent:
|
|
242
|
+
totalPromptTokens: Number(m.totalPromptTokens ?? 0) || D,
|
|
243
|
+
totalCompletionTokens: Number(m.totalCompletionTokens ?? 0) || x,
|
|
244
|
+
totalTokens: g || M,
|
|
245
|
+
avgLatencyMs: Number(m.avgDurationMs ?? 0),
|
|
246
|
+
errorCount: Number(m.failCount ?? 0),
|
|
247
|
+
daily: y,
|
|
248
|
+
models: v,
|
|
249
|
+
recent: N
|
|
251
250
|
};
|
|
252
251
|
}
|
|
253
252
|
function nt() {
|
|
@@ -326,55 +325,55 @@ curl -X POST ${a}/v1/messages \\
|
|
|
326
325
|
}'`;
|
|
327
326
|
}
|
|
328
327
|
function ot() {
|
|
329
|
-
const [a, n] =
|
|
328
|
+
const [a, n] = S("personal"), [l, o] = S([]), [m, N] = S([]), [v, y] = S(!0), [g, M] = S(!1), [D, x] = S(!1), [T, A] = S(""), [h, c] = S({ open: !1 }), [k, d] = S(null), [K, _] = S(null), [F, Q] = S(!1), H = be((u) => u.currentUser), i = String((H == null ? void 0 : H.id) ?? ""), P = (H == null ? void 0 : H.username) ?? "", I = nt(), [r, p] = S("<model-name>");
|
|
330
329
|
X(() => {
|
|
331
|
-
let
|
|
330
|
+
let u = !1;
|
|
332
331
|
return ge().then((w) => {
|
|
333
|
-
!
|
|
332
|
+
!u && w.length > 0 && p(w[0].modelName);
|
|
334
333
|
}).catch(() => {
|
|
335
334
|
}), () => {
|
|
336
|
-
|
|
335
|
+
u = !0;
|
|
337
336
|
};
|
|
338
337
|
}, []);
|
|
339
|
-
const
|
|
340
|
-
|
|
338
|
+
const C = q(async () => {
|
|
339
|
+
y(!0);
|
|
341
340
|
try {
|
|
342
|
-
const
|
|
341
|
+
const u = i ? await ie(i).catch(() => []) : [], [w] = await Promise.all([
|
|
343
342
|
ie("system-default").catch(() => [])
|
|
344
343
|
]);
|
|
345
|
-
o(w),
|
|
344
|
+
o(w), N(u);
|
|
346
345
|
} finally {
|
|
347
|
-
|
|
346
|
+
y(!1);
|
|
348
347
|
}
|
|
349
|
-
}, [
|
|
348
|
+
}, [i]);
|
|
350
349
|
X(() => {
|
|
351
|
-
|
|
352
|
-
}, [
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
},
|
|
356
|
-
if (!
|
|
350
|
+
C();
|
|
351
|
+
}, [C]);
|
|
352
|
+
const B = () => {
|
|
353
|
+
A(""), x(!0);
|
|
354
|
+
}, E = async () => {
|
|
355
|
+
if (!T.trim()) {
|
|
357
356
|
G.warning("请输入 AK 名称");
|
|
358
357
|
return;
|
|
359
358
|
}
|
|
360
|
-
if (!
|
|
359
|
+
if (!i) {
|
|
361
360
|
G.warning("登录态不可用,无法生成 AK");
|
|
362
361
|
return;
|
|
363
362
|
}
|
|
364
|
-
|
|
363
|
+
M(!0);
|
|
365
364
|
try {
|
|
366
|
-
const
|
|
367
|
-
ke(
|
|
365
|
+
const u = await Ee(i, P, T.trim());
|
|
366
|
+
ke(u.akPrefix, u.apiKey), x(!1), c({
|
|
368
367
|
open: !0,
|
|
369
|
-
apiKey:
|
|
370
|
-
akPrefix:
|
|
371
|
-
}),
|
|
372
|
-
} catch (
|
|
373
|
-
G.error(
|
|
368
|
+
apiKey: u.apiKey,
|
|
369
|
+
akPrefix: u.akPrefix
|
|
370
|
+
}), C();
|
|
371
|
+
} catch (u) {
|
|
372
|
+
G.error(u instanceof Error ? u.message : "创建 AK 失败");
|
|
374
373
|
} finally {
|
|
375
|
-
|
|
374
|
+
M(!1);
|
|
376
375
|
}
|
|
377
|
-
}, b = (
|
|
376
|
+
}, b = (u) => {
|
|
378
377
|
de.confirm({
|
|
379
378
|
title: "确认吊销此 AK?",
|
|
380
379
|
content: "吊销后此 AK 将立即失效,无法恢复。",
|
|
@@ -383,75 +382,75 @@ function ot() {
|
|
|
383
382
|
cancelText: "取消",
|
|
384
383
|
onOk: async () => {
|
|
385
384
|
try {
|
|
386
|
-
await at(
|
|
385
|
+
await at(u), G.success("AK 已吊销"), C(), Ie();
|
|
387
386
|
} catch (w) {
|
|
388
387
|
G.error(w instanceof Error ? w.message : "吊销失败");
|
|
389
388
|
}
|
|
390
389
|
}
|
|
391
390
|
});
|
|
392
|
-
},
|
|
393
|
-
navigator.clipboard.writeText(
|
|
394
|
-
}, oe = (
|
|
395
|
-
const w = st(
|
|
396
|
-
w ?
|
|
397
|
-
},
|
|
398
|
-
|
|
391
|
+
}, L = (u) => {
|
|
392
|
+
navigator.clipboard.writeText(u).then(() => G.success("已复制到剪贴板")).catch(() => G.warning("复制失败,请手动复制"));
|
|
393
|
+
}, oe = (u) => {
|
|
394
|
+
const w = st(u.akPrefix);
|
|
395
|
+
w ? L(w) : (L(u.akPrefix), G.info("完整 AK 未在本地缓存(可能在本设备外创建),已复制前缀"));
|
|
396
|
+
}, z = async (u) => {
|
|
397
|
+
d(u), Q(!0), _(null);
|
|
399
398
|
try {
|
|
400
|
-
const w = await Pe(
|
|
401
|
-
|
|
399
|
+
const w = await Pe(u.id);
|
|
400
|
+
_(w);
|
|
402
401
|
} catch (w) {
|
|
403
402
|
G.error(w instanceof Error ? w.message : "获取用量失败");
|
|
404
403
|
} finally {
|
|
405
|
-
|
|
404
|
+
Q(!1);
|
|
406
405
|
}
|
|
407
|
-
},
|
|
408
|
-
|
|
409
|
-
}, ne = (
|
|
410
|
-
const w = Object.entries(
|
|
406
|
+
}, j = () => {
|
|
407
|
+
d(null), _(null);
|
|
408
|
+
}, ne = (u) => {
|
|
409
|
+
const w = Object.entries(u);
|
|
411
410
|
if (w.length === 0)
|
|
412
411
|
return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
|
|
413
|
-
const Y = Math.max(...w.map(([,
|
|
414
|
-
return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: w.map(([
|
|
415
|
-
const ye =
|
|
412
|
+
const Y = Math.max(...w.map(([, f]) => f[1] + f[2]), 1);
|
|
413
|
+
return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: w.map(([f, U]) => {
|
|
414
|
+
const ye = U[1] + U[2], $e = ye / Y * 100;
|
|
416
415
|
return /* @__PURE__ */ s("div", { className: t.usageBarCol, children: [
|
|
417
|
-
/* @__PURE__ */ e(W, { title: `${
|
|
416
|
+
/* @__PURE__ */ e(W, { title: `${f}: ${U[0]}次 / ${ye} tokens`, children: /* @__PURE__ */ e(
|
|
418
417
|
"div",
|
|
419
418
|
{
|
|
420
419
|
className: t.usageBar,
|
|
421
420
|
style: { height: `${Math.max($e, 2)}%` }
|
|
422
421
|
}
|
|
423
422
|
) }),
|
|
424
|
-
/* @__PURE__ */ e("span", { className: t.usageBarLabel, children:
|
|
425
|
-
] },
|
|
423
|
+
/* @__PURE__ */ e("span", { className: t.usageBarLabel, children: f })
|
|
424
|
+
] }, f);
|
|
426
425
|
}) });
|
|
427
|
-
}, ce = (
|
|
428
|
-
const w = Object.entries(
|
|
426
|
+
}, ce = (u) => {
|
|
427
|
+
const w = Object.entries(u);
|
|
429
428
|
if (w.length === 0)
|
|
430
429
|
return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
|
|
431
|
-
const Y = Math.max(...w.map(([,
|
|
432
|
-
return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: w.sort((
|
|
433
|
-
/* @__PURE__ */ e("span", { className: t.modelBreakdownName, children:
|
|
430
|
+
const Y = Math.max(...w.map(([, f]) => f[0]), 1);
|
|
431
|
+
return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: w.sort((f, U) => U[1][0] - f[1][0]).map(([f, U]) => /* @__PURE__ */ s("div", { className: t.modelBreakdownRow, children: [
|
|
432
|
+
/* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: f }),
|
|
434
433
|
/* @__PURE__ */ e("div", { className: t.modelBreakdownBar, children: /* @__PURE__ */ e(
|
|
435
434
|
"div",
|
|
436
435
|
{
|
|
437
436
|
className: t.modelBreakdownFill,
|
|
438
|
-
style: { width: `${
|
|
437
|
+
style: { width: `${U[0] / Y * 100}%` }
|
|
439
438
|
}
|
|
440
439
|
) }),
|
|
441
440
|
/* @__PURE__ */ s("span", { className: t.modelBreakdownCount, children: [
|
|
442
|
-
|
|
441
|
+
U[0],
|
|
443
442
|
"次 / ",
|
|
444
|
-
|
|
443
|
+
U[1] + (U[2] || 0),
|
|
445
444
|
"tokens"
|
|
446
445
|
] })
|
|
447
|
-
] },
|
|
446
|
+
] }, f)) });
|
|
448
447
|
}, Be = [
|
|
449
448
|
{
|
|
450
449
|
title: "时间",
|
|
451
450
|
dataIndex: "createTime",
|
|
452
451
|
key: "createTime",
|
|
453
452
|
width: 160,
|
|
454
|
-
render: (
|
|
453
|
+
render: (u) => u ? new Date(u).toLocaleString("zh-CN") : "-"
|
|
455
454
|
},
|
|
456
455
|
{ title: "模型", dataIndex: "model", key: "model", width: 140 },
|
|
457
456
|
{
|
|
@@ -459,7 +458,7 @@ function ot() {
|
|
|
459
458
|
dataIndex: "protocol",
|
|
460
459
|
key: "protocol",
|
|
461
460
|
width: 90,
|
|
462
|
-
render: (
|
|
461
|
+
render: (u) => /* @__PURE__ */ e(J, { children: u })
|
|
463
462
|
},
|
|
464
463
|
{
|
|
465
464
|
title: "输入",
|
|
@@ -484,59 +483,59 @@ function ot() {
|
|
|
484
483
|
dataIndex: "latencyMs",
|
|
485
484
|
key: "latencyMs",
|
|
486
485
|
width: 70,
|
|
487
|
-
render: (
|
|
486
|
+
render: (u) => u ? `${u}ms` : "-"
|
|
488
487
|
},
|
|
489
488
|
{
|
|
490
489
|
title: "状态",
|
|
491
490
|
dataIndex: "statusCode",
|
|
492
491
|
key: "statusCode",
|
|
493
492
|
width: 60,
|
|
494
|
-
render: (
|
|
493
|
+
render: (u) => u ? /* @__PURE__ */ e(J, { color: u < 400 ? "green" : "red", children: u }) : "-"
|
|
495
494
|
}
|
|
496
|
-
], fe = (
|
|
497
|
-
const Y = Array.isArray(
|
|
498
|
-
return
|
|
495
|
+
], fe = (u, w) => {
|
|
496
|
+
const Y = Array.isArray(u) ? u : [];
|
|
497
|
+
return v ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 40 }, children: /* @__PURE__ */ e(V, { tip: "加载中..." }) }) : Y.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: w ? "暂无应用 AK" : "暂无个人 AK,点击上方按钮生成" }) : /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: Y.map((f) => /* @__PURE__ */ s(
|
|
499
498
|
"div",
|
|
500
499
|
{
|
|
501
500
|
className: t.akCard,
|
|
502
|
-
onClick: () =>
|
|
501
|
+
onClick: () => z(f),
|
|
503
502
|
children: [
|
|
504
503
|
/* @__PURE__ */ s("div", { className: t.akCardRow, children: [
|
|
505
|
-
/* @__PURE__ */ e("span", { className: t.akTitle, children:
|
|
506
|
-
/* @__PURE__ */ e("code", { className: t.akPrefixSmall, children:
|
|
504
|
+
/* @__PURE__ */ e("span", { className: t.akTitle, children: f.description || f.akPrefix.replace("...", "**") }),
|
|
505
|
+
/* @__PURE__ */ e("code", { className: t.akPrefixSmall, children: f.akPrefix.replace("...", "**") }),
|
|
507
506
|
/* @__PURE__ */ e(
|
|
508
507
|
"span",
|
|
509
508
|
{
|
|
510
|
-
className: `${t.akStatus} ${
|
|
511
|
-
children:
|
|
509
|
+
className: `${t.akStatus} ${f.active ? t.akStatusActive : t.akStatusRevoked}`,
|
|
510
|
+
children: f.active ? "活跃" : "已吊销"
|
|
512
511
|
}
|
|
513
512
|
),
|
|
514
|
-
|
|
513
|
+
f.defaultModel && /* @__PURE__ */ s(J, { style: { fontSize: 11 }, children: [
|
|
515
514
|
"默认: ",
|
|
516
|
-
|
|
515
|
+
f.defaultModel
|
|
517
516
|
] }),
|
|
518
517
|
/* @__PURE__ */ s(
|
|
519
518
|
"div",
|
|
520
519
|
{
|
|
521
520
|
className: t.akCardActions,
|
|
522
|
-
onClick: (
|
|
521
|
+
onClick: (U) => U.stopPropagation(),
|
|
523
522
|
children: [
|
|
524
523
|
/* @__PURE__ */ e(W, { title: "复制完整 AK", children: /* @__PURE__ */ e(
|
|
525
|
-
|
|
524
|
+
R,
|
|
526
525
|
{
|
|
527
526
|
size: "small",
|
|
528
527
|
icon: /* @__PURE__ */ e(se, {}),
|
|
529
|
-
onClick: () => oe(
|
|
528
|
+
onClick: () => oe(f),
|
|
530
529
|
children: "复制"
|
|
531
530
|
}
|
|
532
531
|
) }),
|
|
533
|
-
!w &&
|
|
534
|
-
|
|
532
|
+
!w && f.active && /* @__PURE__ */ e(
|
|
533
|
+
R,
|
|
535
534
|
{
|
|
536
535
|
size: "small",
|
|
537
536
|
danger: !0,
|
|
538
537
|
icon: /* @__PURE__ */ e(Oe, {}),
|
|
539
|
-
onClick: () => b(
|
|
538
|
+
onClick: () => b(f.id),
|
|
540
539
|
children: "吊销"
|
|
541
540
|
}
|
|
542
541
|
)
|
|
@@ -545,28 +544,28 @@ function ot() {
|
|
|
545
544
|
)
|
|
546
545
|
] }),
|
|
547
546
|
/* @__PURE__ */ s("div", { className: t.akCardRow2, children: [
|
|
548
|
-
|
|
547
|
+
f.tokenQuota > 0 && /* @__PURE__ */ e("div", { className: t.akMiniBar, children: /* @__PURE__ */ e(
|
|
549
548
|
"div",
|
|
550
549
|
{
|
|
551
550
|
className: t.akMiniBarFill,
|
|
552
551
|
style: {
|
|
553
552
|
width: `${Math.min(
|
|
554
|
-
(
|
|
553
|
+
(f.totalTokens || 0) / f.tokenQuota * 100,
|
|
555
554
|
100
|
|
556
555
|
)}%`
|
|
557
556
|
}
|
|
558
557
|
}
|
|
559
558
|
) }),
|
|
560
559
|
/* @__PURE__ */ s("span", { className: t.akUsageText, children: [
|
|
561
|
-
Ne(
|
|
562
|
-
|
|
560
|
+
Ne(f.totalTokens || 0),
|
|
561
|
+
f.tokenQuota > 0 ? ` / ${Ne(f.tokenQuota)}` : " tokens"
|
|
563
562
|
] }),
|
|
564
|
-
/* @__PURE__ */ e("span", { className: t.akMetaText, children:
|
|
565
|
-
/* @__PURE__ */ e("span", { className: t.akMetaText, children: new Date(
|
|
563
|
+
/* @__PURE__ */ e("span", { className: t.akMetaText, children: f.lastUsedAt ? `最近使用 ${f.lastUsedAt}` : "尚未使用" }),
|
|
564
|
+
/* @__PURE__ */ e("span", { className: t.akMetaText, children: new Date(f.createTime).toLocaleDateString("zh-CN") })
|
|
566
565
|
] })
|
|
567
566
|
]
|
|
568
567
|
},
|
|
569
|
-
|
|
568
|
+
f.id
|
|
570
569
|
)) });
|
|
571
570
|
};
|
|
572
571
|
return /* @__PURE__ */ s("div", { className: t.akContainer, children: [
|
|
@@ -575,23 +574,23 @@ function ot() {
|
|
|
575
574
|
/* @__PURE__ */ s("div", { className: t.akBaseUrlRow, children: [
|
|
576
575
|
/* @__PURE__ */ s("div", { className: t.akBaseUrlItem, children: [
|
|
577
576
|
/* @__PURE__ */ e("span", { className: t.akBaseUrlLabel, children: "OpenAI 兼容" }),
|
|
578
|
-
/* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children:
|
|
577
|
+
/* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: I }),
|
|
579
578
|
/* @__PURE__ */ e(W, { title: "复制 Base URL", children: /* @__PURE__ */ e(
|
|
580
579
|
se,
|
|
581
580
|
{
|
|
582
581
|
className: t.akCopyIcon,
|
|
583
|
-
onClick: () =>
|
|
582
|
+
onClick: () => L(I)
|
|
584
583
|
}
|
|
585
584
|
) })
|
|
586
585
|
] }),
|
|
587
586
|
/* @__PURE__ */ s("div", { className: t.akBaseUrlItem, children: [
|
|
588
587
|
/* @__PURE__ */ e("span", { className: t.akBaseUrlLabel, children: "Anthropic 兼容" }),
|
|
589
|
-
/* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children:
|
|
588
|
+
/* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: I }),
|
|
590
589
|
/* @__PURE__ */ e(W, { title: "复制 Base URL", children: /* @__PURE__ */ e(
|
|
591
590
|
se,
|
|
592
591
|
{
|
|
593
592
|
className: t.akCopyIcon,
|
|
594
|
-
onClick: () =>
|
|
593
|
+
onClick: () => L(I)
|
|
595
594
|
}
|
|
596
595
|
) })
|
|
597
596
|
] })
|
|
@@ -599,11 +598,11 @@ function ot() {
|
|
|
599
598
|
/* @__PURE__ */ s("div", { className: t.akIntegrationGrid, children: [
|
|
600
599
|
/* @__PURE__ */ s("div", { children: [
|
|
601
600
|
/* @__PURE__ */ e("p", { className: t.akCodeLabel, children: "OpenAI 兼容 — curl 示例" }),
|
|
602
|
-
/* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: lt(
|
|
601
|
+
/* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: lt(I, r) })
|
|
603
602
|
] }),
|
|
604
603
|
/* @__PURE__ */ s("div", { children: [
|
|
605
604
|
/* @__PURE__ */ e("p", { className: t.akCodeLabel, children: "Anthropic 兼容 — curl 示例" }),
|
|
606
|
-
/* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: it(
|
|
605
|
+
/* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: it(I, r) })
|
|
607
606
|
] })
|
|
608
607
|
] })
|
|
609
608
|
] }),
|
|
@@ -622,7 +621,7 @@ function ot() {
|
|
|
622
621
|
Ae,
|
|
623
622
|
{
|
|
624
623
|
activeKey: a,
|
|
625
|
-
onChange: (
|
|
624
|
+
onChange: (u) => n(u),
|
|
626
625
|
items: [
|
|
627
626
|
{ key: "app", label: "应用 AK" },
|
|
628
627
|
{ key: "personal", label: "个人 AK" }
|
|
@@ -631,13 +630,13 @@ function ot() {
|
|
|
631
630
|
}
|
|
632
631
|
),
|
|
633
632
|
/* @__PURE__ */ s("div", { style: { display: "flex", gap: 8 }, children: [
|
|
634
|
-
/* @__PURE__ */ e(
|
|
633
|
+
/* @__PURE__ */ e(R, { icon: /* @__PURE__ */ e(Te, {}), onClick: C, size: "small", children: "刷新" }),
|
|
635
634
|
a === "personal" && /* @__PURE__ */ e(
|
|
636
|
-
|
|
635
|
+
R,
|
|
637
636
|
{
|
|
638
637
|
type: "primary",
|
|
639
638
|
icon: /* @__PURE__ */ e(Se, {}),
|
|
640
|
-
onClick:
|
|
639
|
+
onClick: B,
|
|
641
640
|
loading: g,
|
|
642
641
|
children: "生成 AK"
|
|
643
642
|
}
|
|
@@ -646,7 +645,7 @@ function ot() {
|
|
|
646
645
|
]
|
|
647
646
|
}
|
|
648
647
|
),
|
|
649
|
-
a === "app" ? fe(l, !0) : fe(
|
|
648
|
+
a === "app" ? fe(l, !0) : fe(m, !1)
|
|
650
649
|
] }),
|
|
651
650
|
/* @__PURE__ */ s(
|
|
652
651
|
de,
|
|
@@ -654,7 +653,7 @@ function ot() {
|
|
|
654
653
|
open: D,
|
|
655
654
|
title: "生成新 AK",
|
|
656
655
|
onCancel: () => x(!1),
|
|
657
|
-
onOk:
|
|
656
|
+
onOk: E,
|
|
658
657
|
okText: "确认生成",
|
|
659
658
|
cancelText: "取消",
|
|
660
659
|
confirmLoading: g,
|
|
@@ -674,9 +673,9 @@ function ot() {
|
|
|
674
673
|
we,
|
|
675
674
|
{
|
|
676
675
|
placeholder: "例如:测试用 AK、生产网关 AK",
|
|
677
|
-
value:
|
|
678
|
-
onChange: (
|
|
679
|
-
onPressEnter:
|
|
676
|
+
value: T,
|
|
677
|
+
onChange: (u) => A(u.target.value),
|
|
678
|
+
onPressEnter: E,
|
|
680
679
|
maxLength: 50,
|
|
681
680
|
autoFocus: !0
|
|
682
681
|
}
|
|
@@ -687,24 +686,24 @@ function ot() {
|
|
|
687
686
|
/* @__PURE__ */ s(
|
|
688
687
|
de,
|
|
689
688
|
{
|
|
690
|
-
open:
|
|
689
|
+
open: h.open,
|
|
691
690
|
title: "AK 创建成功",
|
|
692
|
-
onCancel: () =>
|
|
691
|
+
onCancel: () => c({ open: !1 }),
|
|
693
692
|
footer: [
|
|
694
693
|
/* @__PURE__ */ e(
|
|
695
|
-
|
|
694
|
+
R,
|
|
696
695
|
{
|
|
697
696
|
icon: /* @__PURE__ */ e(se, {}),
|
|
698
|
-
onClick: () =>
|
|
697
|
+
onClick: () => h.apiKey && L(h.apiKey),
|
|
699
698
|
children: "复制 AK"
|
|
700
699
|
},
|
|
701
700
|
"copy"
|
|
702
701
|
),
|
|
703
702
|
/* @__PURE__ */ e(
|
|
704
|
-
|
|
703
|
+
R,
|
|
705
704
|
{
|
|
706
705
|
type: "primary",
|
|
707
|
-
onClick: () =>
|
|
706
|
+
onClick: () => c({ open: !1 }),
|
|
708
707
|
children: "我已保存"
|
|
709
708
|
},
|
|
710
709
|
"close"
|
|
@@ -724,12 +723,12 @@ function ot() {
|
|
|
724
723
|
wordBreak: "break-all",
|
|
725
724
|
userSelect: "all"
|
|
726
725
|
},
|
|
727
|
-
children:
|
|
726
|
+
children: h.apiKey
|
|
728
727
|
}
|
|
729
728
|
),
|
|
730
729
|
/* @__PURE__ */ s("div", { style: { marginTop: 8, fontSize: 12, color: "var(--text-muted)" }, children: [
|
|
731
730
|
"前缀: ",
|
|
732
|
-
|
|
731
|
+
h.akPrefix
|
|
733
732
|
] })
|
|
734
733
|
]
|
|
735
734
|
}
|
|
@@ -737,67 +736,67 @@ function ot() {
|
|
|
737
736
|
/* @__PURE__ */ e(
|
|
738
737
|
xe,
|
|
739
738
|
{
|
|
740
|
-
title:
|
|
739
|
+
title: k ? /* @__PURE__ */ s("span", { children: [
|
|
741
740
|
"AK 详情 — ",
|
|
742
|
-
/* @__PURE__ */ e("code", { children:
|
|
741
|
+
/* @__PURE__ */ e("code", { children: k.akPrefix })
|
|
743
742
|
] }) : "AK 详情",
|
|
744
|
-
open: !!
|
|
745
|
-
onClose:
|
|
743
|
+
open: !!k,
|
|
744
|
+
onClose: j,
|
|
746
745
|
size: "large",
|
|
747
|
-
children:
|
|
746
|
+
children: F ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载用量数据..." }) }) : K ? /* @__PURE__ */ s("div", { className: t.usageDrawerContent, children: [
|
|
748
747
|
/* @__PURE__ */ e("div", { style: { fontSize: 12, color: "#8c8c8c", marginBottom: 12 }, children: "以下为网关全局调用统计(近 7 天窗口), 监控侧不按 AK 留存;该 AK 自身的累计消耗见下方「本 AK 累计 Token」。" }),
|
|
749
748
|
/* @__PURE__ */ s("div", { className: t.usageStatsGrid, children: [
|
|
750
|
-
/* @__PURE__ */ e(
|
|
751
|
-
/* @__PURE__ */ e(
|
|
749
|
+
/* @__PURE__ */ e($, { title: "总请求数", value: K.totalRequests }),
|
|
750
|
+
/* @__PURE__ */ e($, { title: "总 Token", value: K.totalTokens }),
|
|
752
751
|
/* @__PURE__ */ e(
|
|
753
|
-
|
|
752
|
+
$,
|
|
754
753
|
{
|
|
755
754
|
title: "输入 Token",
|
|
756
|
-
value:
|
|
755
|
+
value: K.totalPromptTokens
|
|
757
756
|
}
|
|
758
757
|
),
|
|
759
758
|
/* @__PURE__ */ e(
|
|
760
|
-
|
|
759
|
+
$,
|
|
761
760
|
{
|
|
762
761
|
title: "输出 Token",
|
|
763
|
-
value:
|
|
762
|
+
value: K.totalCompletionTokens
|
|
764
763
|
}
|
|
765
764
|
),
|
|
766
765
|
/* @__PURE__ */ e(
|
|
767
|
-
|
|
766
|
+
$,
|
|
768
767
|
{
|
|
769
768
|
title: "平均耗时",
|
|
770
|
-
value:
|
|
769
|
+
value: K.avgLatencyMs,
|
|
771
770
|
suffix: "ms"
|
|
772
771
|
}
|
|
773
772
|
),
|
|
774
773
|
/* @__PURE__ */ e(
|
|
775
|
-
|
|
774
|
+
$,
|
|
776
775
|
{
|
|
777
776
|
title: "错误数",
|
|
778
|
-
value:
|
|
777
|
+
value: K.errorCount,
|
|
779
778
|
styles: {
|
|
780
779
|
content: {
|
|
781
|
-
color:
|
|
780
|
+
color: K.errorCount > 0 ? "#ff4d4f" : void 0
|
|
782
781
|
}
|
|
783
782
|
}
|
|
784
783
|
}
|
|
785
784
|
),
|
|
786
785
|
/* @__PURE__ */ e(
|
|
787
|
-
|
|
786
|
+
$,
|
|
788
787
|
{
|
|
789
788
|
title: "本 AK 累计 Token",
|
|
790
|
-
value: (
|
|
789
|
+
value: (k == null ? void 0 : k.totalTokens) ?? 0
|
|
791
790
|
}
|
|
792
791
|
)
|
|
793
792
|
] }),
|
|
794
793
|
/* @__PURE__ */ s("div", { className: t.usageSection, children: [
|
|
795
794
|
/* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "每日调用曲线(按最近调用明细聚合)" }),
|
|
796
|
-
ne(
|
|
795
|
+
ne(K.daily)
|
|
797
796
|
] }),
|
|
798
797
|
/* @__PURE__ */ s("div", { className: t.usageSection, children: [
|
|
799
798
|
/* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "模型用量分布" }),
|
|
800
|
-
ce(
|
|
799
|
+
ce(K.models)
|
|
801
800
|
] }),
|
|
802
801
|
/* @__PURE__ */ s("div", { className: t.usageSection, children: [
|
|
803
802
|
/* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "最近调用记录" }),
|
|
@@ -805,7 +804,7 @@ function ot() {
|
|
|
805
804
|
Ke,
|
|
806
805
|
{
|
|
807
806
|
columns: Be,
|
|
808
|
-
dataSource:
|
|
807
|
+
dataSource: K.recent,
|
|
809
808
|
rowKey: "id",
|
|
810
809
|
size: "small",
|
|
811
810
|
pagination: {
|
|
@@ -813,7 +812,7 @@ function ot() {
|
|
|
813
812
|
size: "small",
|
|
814
813
|
showSizeChanger: !0,
|
|
815
814
|
pageSizeOptions: ["10", "20", "50", "100"],
|
|
816
|
-
showTotal: (
|
|
815
|
+
showTotal: (u) => `共 ${u} 条`
|
|
817
816
|
},
|
|
818
817
|
scroll: { x: 760 }
|
|
819
818
|
}
|
|
@@ -828,24 +827,24 @@ function ct(a) {
|
|
|
828
827
|
const n = [];
|
|
829
828
|
if (!a) return n;
|
|
830
829
|
const l = /<(think|thinking|reasoning)>([\s\S]*?)<\/\1>/gi;
|
|
831
|
-
let o = 0,
|
|
832
|
-
for (; (
|
|
833
|
-
|
|
830
|
+
let o = 0, m;
|
|
831
|
+
for (; (m = l.exec(a)) !== null; )
|
|
832
|
+
m.index > o && n.push({ type: "text", text: a.slice(o, m.index) }), n.push({ type: "think", text: m[2] }), o = m.index + m[0].length;
|
|
834
833
|
return o < a.length && n.push({ type: "text", text: a.slice(o) }), n;
|
|
835
834
|
}
|
|
836
835
|
const re = 4;
|
|
837
836
|
let dt = 0;
|
|
838
837
|
function mt({ initialModels: a }) {
|
|
839
|
-
const [n, l] =
|
|
838
|
+
const [n, l] = S([]), [o, m] = S([]), [N, v] = S(!0), [y, g] = S(null), [M, D] = S(""), [x, T] = S(!1), A = me(""), h = me(/* @__PURE__ */ new Map()), c = me(/* @__PURE__ */ new Map());
|
|
840
839
|
X(() => {
|
|
841
840
|
(async () => {
|
|
842
841
|
try {
|
|
843
842
|
const r = await ge();
|
|
844
|
-
|
|
845
|
-
const p = a.length > 0 ? a : r.slice(0, 1).map((
|
|
846
|
-
l(p.slice(0, re).map((
|
|
843
|
+
m(r), v(!1);
|
|
844
|
+
const p = a.length > 0 ? a : r.slice(0, 1).map((C) => C.modelName);
|
|
845
|
+
l(p.slice(0, re).map((C) => ue(C)));
|
|
847
846
|
} catch (r) {
|
|
848
|
-
|
|
847
|
+
v(!1), g(r instanceof Error ? r.message : "模型列表加载失败");
|
|
849
848
|
}
|
|
850
849
|
})();
|
|
851
850
|
}, []), X(() => {
|
|
@@ -854,29 +853,29 @@ function mt({ initialModels: a }) {
|
|
|
854
853
|
l(r);
|
|
855
854
|
}
|
|
856
855
|
}, [a.join(",")]);
|
|
857
|
-
const
|
|
858
|
-
const p =
|
|
856
|
+
const k = q((r) => {
|
|
857
|
+
const p = c.current.get(r);
|
|
859
858
|
p && (p.scrollTop = p.scrollHeight);
|
|
860
|
-
}, []),
|
|
859
|
+
}, []), d = q(
|
|
861
860
|
(r, p) => {
|
|
862
|
-
l((
|
|
861
|
+
l((C) => C.map((B) => B.id === r ? p(B) : B));
|
|
863
862
|
},
|
|
864
863
|
[]
|
|
865
|
-
),
|
|
866
|
-
if (
|
|
864
|
+
), K = q(async () => {
|
|
865
|
+
if (A.current) return A.current;
|
|
867
866
|
const r = await rt();
|
|
868
|
-
return
|
|
869
|
-
}, []),
|
|
870
|
-
const r =
|
|
867
|
+
return A.current = r, r;
|
|
868
|
+
}, []), _ = q(async () => {
|
|
869
|
+
const r = M.trim();
|
|
871
870
|
if (!r || x) return;
|
|
872
871
|
let p;
|
|
873
872
|
try {
|
|
874
|
-
p = await
|
|
873
|
+
p = await K();
|
|
875
874
|
} catch {
|
|
876
875
|
return;
|
|
877
876
|
}
|
|
878
|
-
D(""),
|
|
879
|
-
const
|
|
877
|
+
D(""), T(!0);
|
|
878
|
+
const C = n.map((b) => ({
|
|
880
879
|
...b,
|
|
881
880
|
messages: [
|
|
882
881
|
...b.messages,
|
|
@@ -888,61 +887,61 @@ function mt({ initialModels: a }) {
|
|
|
888
887
|
error: null,
|
|
889
888
|
usage: null
|
|
890
889
|
}));
|
|
891
|
-
l(
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
const
|
|
895
|
-
|
|
890
|
+
l(C);
|
|
891
|
+
const B = C;
|
|
892
|
+
B.forEach((b) => {
|
|
893
|
+
const L = new AbortController();
|
|
894
|
+
h.current.set(b.id, L);
|
|
896
895
|
const oe = b.messages.slice(0, -1);
|
|
897
896
|
et(p, b.model, oe, {
|
|
898
|
-
onDelta: (
|
|
899
|
-
|
|
900
|
-
...
|
|
901
|
-
streamingContent:
|
|
902
|
-
messages:
|
|
903
|
-
(ne, ce) => ce ===
|
|
897
|
+
onDelta: (z) => {
|
|
898
|
+
d(b.id, (j) => ({
|
|
899
|
+
...j,
|
|
900
|
+
streamingContent: j.streamingContent + z,
|
|
901
|
+
messages: j.messages.map(
|
|
902
|
+
(ne, ce) => ce === j.messages.length - 1 ? { ...ne, content: j.streamingContent + z } : ne
|
|
904
903
|
)
|
|
905
|
-
})),
|
|
904
|
+
})), k(b.id);
|
|
906
905
|
},
|
|
907
|
-
onDone: (
|
|
908
|
-
|
|
909
|
-
...
|
|
906
|
+
onDone: (z) => {
|
|
907
|
+
d(b.id, (j) => ({
|
|
908
|
+
...j,
|
|
910
909
|
isStreaming: !1,
|
|
911
|
-
usage:
|
|
912
|
-
promptTokens:
|
|
913
|
-
completionTokens:
|
|
914
|
-
totalTokens:
|
|
910
|
+
usage: z ? {
|
|
911
|
+
promptTokens: z.promptTokens,
|
|
912
|
+
completionTokens: z.completionTokens,
|
|
913
|
+
totalTokens: z.totalTokens
|
|
915
914
|
} : null
|
|
916
|
-
})),
|
|
915
|
+
})), h.current.delete(b.id);
|
|
917
916
|
},
|
|
918
|
-
onError: (
|
|
919
|
-
(
|
|
920
|
-
...
|
|
917
|
+
onError: (z) => {
|
|
918
|
+
(z.message.includes("401") || z.message.includes("API key")) && (Ie(), A.current = ""), d(b.id, (j) => ({
|
|
919
|
+
...j,
|
|
921
920
|
isStreaming: !1,
|
|
922
|
-
error:
|
|
923
|
-
})),
|
|
921
|
+
error: z.message
|
|
922
|
+
})), h.current.delete(b.id);
|
|
924
923
|
},
|
|
925
|
-
signal:
|
|
924
|
+
signal: L.signal
|
|
926
925
|
}).catch(() => {
|
|
927
926
|
});
|
|
928
927
|
});
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
(
|
|
932
|
-
) && (clearInterval(
|
|
928
|
+
const E = setInterval(() => {
|
|
929
|
+
B.every(
|
|
930
|
+
(L) => !h.current.has(L.id)
|
|
931
|
+
) && (clearInterval(E), T(!1));
|
|
933
932
|
}, 200);
|
|
934
933
|
setTimeout(() => {
|
|
935
|
-
clearInterval(
|
|
934
|
+
clearInterval(E), T(!1);
|
|
936
935
|
}, 300 * 1e3);
|
|
937
|
-
}, [
|
|
938
|
-
|
|
939
|
-
}, []),
|
|
936
|
+
}, [M, x, n, K, d, k]), F = q(() => {
|
|
937
|
+
h.current.forEach((r) => r.abort()), h.current.clear(), l((r) => r.map((p) => ({ ...p, isStreaming: !1 }))), T(!1);
|
|
938
|
+
}, []), Q = q(() => {
|
|
940
939
|
var p;
|
|
941
940
|
if (n.length >= re) return;
|
|
942
|
-
const r = (p = o.find((
|
|
943
|
-
r && l((
|
|
944
|
-
}, [n, o]),
|
|
945
|
-
|
|
941
|
+
const r = (p = o.find((C) => !n.some((B) => B.model === C.modelName))) == null ? void 0 : p.modelName;
|
|
942
|
+
r && l((C) => [...C, ue(r)]);
|
|
943
|
+
}, [n, o]), H = q(() => {
|
|
944
|
+
h.current.forEach((r) => r.abort()), h.current.clear(), l(
|
|
946
945
|
(r) => r.map((p) => ({
|
|
947
946
|
...p,
|
|
948
947
|
messages: [],
|
|
@@ -951,40 +950,40 @@ function mt({ initialModels: a }) {
|
|
|
951
950
|
error: null,
|
|
952
951
|
usage: null
|
|
953
952
|
}))
|
|
954
|
-
),
|
|
955
|
-
}, [x, n]),
|
|
956
|
-
const p =
|
|
957
|
-
p && p.abort(),
|
|
958
|
-
}, []),
|
|
953
|
+
), T(!1);
|
|
954
|
+
}, [x, n]), i = q((r) => {
|
|
955
|
+
const p = h.current.get(r);
|
|
956
|
+
p && p.abort(), h.current.delete(r), l((C) => C.filter((B) => B.id !== r));
|
|
957
|
+
}, []), P = q(
|
|
959
958
|
(r, p) => {
|
|
960
|
-
|
|
959
|
+
d(r, (C) => ({ ...C, model: p }));
|
|
961
960
|
},
|
|
962
|
-
[
|
|
963
|
-
),
|
|
961
|
+
[d]
|
|
962
|
+
), I = o.map((r) => ({
|
|
964
963
|
label: r.modelName,
|
|
965
964
|
value: r.modelName
|
|
966
965
|
}));
|
|
967
|
-
return
|
|
966
|
+
return N ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载模型列表..." }) }) : y ? /* @__PURE__ */ s("div", { className: t.chatContainer, children: [
|
|
968
967
|
/* @__PURE__ */ e("div", { className: t.chatHeader, children: /* @__PURE__ */ e("h3", { className: t.chatTitle, children: "模型对话" }) }),
|
|
969
968
|
/* @__PURE__ */ s("div", { className: t.akEmpty, children: [
|
|
970
969
|
"模型列表加载失败:",
|
|
971
|
-
|
|
970
|
+
y
|
|
972
971
|
] })
|
|
973
972
|
] }) : /* @__PURE__ */ s("div", { className: t.chatContainer, children: [
|
|
974
973
|
/* @__PURE__ */ s("div", { className: t.chatHeader, children: [
|
|
975
974
|
/* @__PURE__ */ s("h3", { className: t.chatTitle, children: [
|
|
976
975
|
"模型对话",
|
|
977
|
-
n.length > 1 && /* @__PURE__ */ s(
|
|
976
|
+
n.length > 1 && /* @__PURE__ */ s(J, { color: "blue", style: { marginLeft: 12, fontSize: 12 }, children: [
|
|
978
977
|
n.length,
|
|
979
978
|
" 个模型对比"
|
|
980
979
|
] })
|
|
981
980
|
] }),
|
|
982
981
|
/* @__PURE__ */ e(
|
|
983
|
-
|
|
982
|
+
R,
|
|
984
983
|
{
|
|
985
984
|
size: "small",
|
|
986
985
|
icon: /* @__PURE__ */ e(De, {}),
|
|
987
|
-
onClick:
|
|
986
|
+
onClick: H,
|
|
988
987
|
disabled: x || n.every((r) => r.messages.length === 0),
|
|
989
988
|
children: "清空重新来"
|
|
990
989
|
}
|
|
@@ -998,8 +997,8 @@ function mt({ initialModels: a }) {
|
|
|
998
997
|
{
|
|
999
998
|
size: "small",
|
|
1000
999
|
value: r.model,
|
|
1001
|
-
onChange: (p) =>
|
|
1002
|
-
options:
|
|
1000
|
+
onChange: (p) => P(r.id, p),
|
|
1001
|
+
options: I,
|
|
1003
1002
|
style: { minWidth: 140, flex: 1 },
|
|
1004
1003
|
showSearch: !0,
|
|
1005
1004
|
optionFilterProp: "label"
|
|
@@ -1009,7 +1008,7 @@ function mt({ initialModels: a }) {
|
|
|
1009
1008
|
"span",
|
|
1010
1009
|
{
|
|
1011
1010
|
className: t.chatPanelClose,
|
|
1012
|
-
onClick: () =>
|
|
1011
|
+
onClick: () => i(r.id),
|
|
1013
1012
|
children: /* @__PURE__ */ e(Le, {})
|
|
1014
1013
|
}
|
|
1015
1014
|
)
|
|
@@ -1019,31 +1018,31 @@ function mt({ initialModels: a }) {
|
|
|
1019
1018
|
{
|
|
1020
1019
|
className: t.chatPanelBody,
|
|
1021
1020
|
ref: (p) => {
|
|
1022
|
-
|
|
1021
|
+
c.current.set(r.id, p);
|
|
1023
1022
|
},
|
|
1024
1023
|
children: [
|
|
1025
|
-
r.messages.map((p,
|
|
1024
|
+
r.messages.map((p, C) => /* @__PURE__ */ s(
|
|
1026
1025
|
"div",
|
|
1027
1026
|
{
|
|
1028
1027
|
className: p.role === "user" ? t.chatMsgUser : t.chatMsgAI,
|
|
1029
1028
|
children: [
|
|
1030
1029
|
p.role === "assistant" ? ct(p.content).map(
|
|
1031
|
-
(
|
|
1030
|
+
(B, E) => B.type === "think" ? /* @__PURE__ */ s(
|
|
1032
1031
|
"details",
|
|
1033
1032
|
{
|
|
1034
1033
|
className: t.chatThinkBlock,
|
|
1035
1034
|
children: [
|
|
1036
1035
|
/* @__PURE__ */ e("summary", { children: "思考过程" }),
|
|
1037
|
-
/* @__PURE__ */ e("pre", { children:
|
|
1036
|
+
/* @__PURE__ */ e("pre", { children: B.text })
|
|
1038
1037
|
]
|
|
1039
1038
|
},
|
|
1040
|
-
|
|
1041
|
-
) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children:
|
|
1039
|
+
E
|
|
1040
|
+
) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: B.text }, E)
|
|
1042
1041
|
) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: p.content }),
|
|
1043
|
-
r.isStreaming &&
|
|
1042
|
+
r.isStreaming && C === r.messages.length - 1 && p.role === "assistant" && /* @__PURE__ */ e("span", { className: t.chatStreamingCursor })
|
|
1044
1043
|
]
|
|
1045
1044
|
},
|
|
1046
|
-
|
|
1045
|
+
C
|
|
1047
1046
|
)),
|
|
1048
1047
|
r.error && /* @__PURE__ */ e("div", { className: t.chatMsgError, children: r.error }),
|
|
1049
1048
|
r.usage && /* @__PURE__ */ s("div", { className: t.chatUsageBar, children: [
|
|
@@ -1060,24 +1059,24 @@ function mt({ initialModels: a }) {
|
|
|
1060
1059
|
}
|
|
1061
1060
|
)
|
|
1062
1061
|
] }, r.id)),
|
|
1063
|
-
n.length < re && /* @__PURE__ */ e(W, { title: "添加面板", children: /* @__PURE__ */ e("div", { className: t.addPanelBtn, onClick:
|
|
1062
|
+
n.length < re && /* @__PURE__ */ e(W, { title: "添加面板", children: /* @__PURE__ */ e("div", { className: t.addPanelBtn, onClick: Q, children: /* @__PURE__ */ e(Se, {}) }) })
|
|
1064
1063
|
] }),
|
|
1065
1064
|
/* @__PURE__ */ s("div", { className: t.chatInputBar, children: [
|
|
1066
1065
|
/* @__PURE__ */ e(
|
|
1067
1066
|
we.TextArea,
|
|
1068
1067
|
{
|
|
1069
1068
|
className: t.chatInput,
|
|
1070
|
-
value:
|
|
1069
|
+
value: M,
|
|
1071
1070
|
onChange: (r) => D(r.target.value),
|
|
1072
1071
|
placeholder: "输入消息,所有面板将同时收到并流式输出...",
|
|
1073
1072
|
autoSize: { minRows: 1, maxRows: 4 },
|
|
1074
1073
|
onPressEnter: (r) => {
|
|
1075
|
-
r.shiftKey || (r.preventDefault(),
|
|
1074
|
+
r.shiftKey || (r.preventDefault(), _());
|
|
1076
1075
|
},
|
|
1077
1076
|
disabled: x
|
|
1078
1077
|
}
|
|
1079
1078
|
),
|
|
1080
|
-
x ? /* @__PURE__ */ e(
|
|
1079
|
+
x ? /* @__PURE__ */ e(R, { danger: !0, onClick: F, children: "停止" }) : /* @__PURE__ */ s(R, { type: "primary", onClick: _, disabled: !M.trim(), children: [
|
|
1081
1080
|
/* @__PURE__ */ e(ze, {}),
|
|
1082
1081
|
" 发送"
|
|
1083
1082
|
] })
|
|
@@ -1096,39 +1095,39 @@ function ue(a) {
|
|
|
1096
1095
|
};
|
|
1097
1096
|
}
|
|
1098
1097
|
function ut({ onStartChat: a }) {
|
|
1099
|
-
const [n, l] =
|
|
1100
|
-
|
|
1101
|
-
l(
|
|
1102
|
-
}).catch((
|
|
1103
|
-
l([]),
|
|
1098
|
+
const [n, l] = S([]), [o, m] = S(!0), [N, v] = S(null), [y, g] = S(/* @__PURE__ */ new Set()), M = () => {
|
|
1099
|
+
m(!0), v(null), ge().then((c) => {
|
|
1100
|
+
l(c), m(!1);
|
|
1101
|
+
}).catch((c) => {
|
|
1102
|
+
l([]), v(c instanceof Error ? c.message : "加载失败"), m(!1);
|
|
1104
1103
|
});
|
|
1105
1104
|
};
|
|
1106
1105
|
X(() => {
|
|
1107
|
-
|
|
1106
|
+
M();
|
|
1108
1107
|
}, []);
|
|
1109
|
-
const D = (
|
|
1110
|
-
g((
|
|
1111
|
-
const
|
|
1112
|
-
return
|
|
1108
|
+
const D = (c) => {
|
|
1109
|
+
g((k) => {
|
|
1110
|
+
const d = new Set(k);
|
|
1111
|
+
return d.has(c) ? d.delete(c) : d.add(c), d;
|
|
1113
1112
|
});
|
|
1114
|
-
}, x = Array.from(
|
|
1115
|
-
a([
|
|
1116
|
-
},
|
|
1113
|
+
}, x = Array.from(y), T = (c) => {
|
|
1114
|
+
a([c]);
|
|
1115
|
+
}, A = () => {
|
|
1117
1116
|
x.length > 0 && a(x);
|
|
1118
|
-
},
|
|
1119
|
-
if (!
|
|
1120
|
-
const
|
|
1121
|
-
return
|
|
1117
|
+
}, h = (c) => {
|
|
1118
|
+
if (!c) return "default";
|
|
1119
|
+
const k = c.toLowerCase();
|
|
1120
|
+
return k.includes("aliyun") || k.includes("ali") ? "blue" : k.includes("zhipu") || k.includes("glm") ? "purple" : k.includes("moonshot") || k.includes("kimi") ? "cyan" : k.includes("minimax") ? "orange" : "default";
|
|
1122
1121
|
};
|
|
1123
|
-
return o ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载模型列表..." }) }) :
|
|
1122
|
+
return o ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载模型列表..." }) }) : N ? /* @__PURE__ */ s("div", { children: [
|
|
1124
1123
|
/* @__PURE__ */ s("div", { className: t.modelMgmtHeader, children: [
|
|
1125
1124
|
/* @__PURE__ */ e("h3", { className: t.modelMgmtTitle, children: "模型管理" }),
|
|
1126
1125
|
/* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "数据库管理的可用模型,可选择单个或多个模型发起对话对比" })
|
|
1127
1126
|
] }),
|
|
1128
1127
|
/* @__PURE__ */ s("div", { className: t.akEmpty, children: [
|
|
1129
1128
|
"模型列表加载失败:",
|
|
1130
|
-
|
|
1131
|
-
/* @__PURE__ */ e("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ e(
|
|
1129
|
+
N,
|
|
1130
|
+
/* @__PURE__ */ e("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ e(R, { type: "primary", onClick: M, children: "重试" }) })
|
|
1132
1131
|
] })
|
|
1133
1132
|
] }) : /* @__PURE__ */ s("div", { children: [
|
|
1134
1133
|
/* @__PURE__ */ s("div", { className: t.modelMgmtHeader, children: [
|
|
@@ -1136,56 +1135,56 @@ function ut({ onStartChat: a }) {
|
|
|
1136
1135
|
/* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "数据库管理的可用模型,可选择单个或多个模型发起对话对比" })
|
|
1137
1136
|
] }),
|
|
1138
1137
|
n.length === 0 && /* @__PURE__ */ e("div", { className: t.akEmpty, children: "后端暂无启用模型(z_team_model_config 中 enable=1 的行),请先在数据库或网关配置中启用" }),
|
|
1139
|
-
/* @__PURE__ */ e("div", { className: t.modelGrid, children: n.map((
|
|
1140
|
-
const
|
|
1138
|
+
/* @__PURE__ */ e("div", { className: t.modelGrid, children: n.map((c) => {
|
|
1139
|
+
const k = y.has(c.modelName);
|
|
1141
1140
|
return /* @__PURE__ */ s(
|
|
1142
1141
|
"div",
|
|
1143
1142
|
{
|
|
1144
|
-
className: `${t.modelCard} ${
|
|
1145
|
-
onClick: () => D(
|
|
1143
|
+
className: `${t.modelCard} ${k ? t.modelCardSelected : ""}`,
|
|
1144
|
+
onClick: () => D(c.modelName),
|
|
1146
1145
|
children: [
|
|
1147
1146
|
/* @__PURE__ */ e(
|
|
1148
1147
|
Je,
|
|
1149
1148
|
{
|
|
1150
1149
|
className: t.modelCheckbox,
|
|
1151
|
-
checked:
|
|
1152
|
-
onChange: (
|
|
1153
|
-
|
|
1150
|
+
checked: k,
|
|
1151
|
+
onChange: (d) => {
|
|
1152
|
+
d.stopPropagation(), D(c.modelName);
|
|
1154
1153
|
}
|
|
1155
1154
|
}
|
|
1156
1155
|
),
|
|
1157
1156
|
/* @__PURE__ */ s("div", { className: t.modelCardHeader, children: [
|
|
1158
1157
|
/* @__PURE__ */ e("div", { className: t.modelIconWrap, children: /* @__PURE__ */ e(Ce, {}) }),
|
|
1159
1158
|
/* @__PURE__ */ s("div", { className: t.modelCardInfo, children: [
|
|
1160
|
-
/* @__PURE__ */ e("h4", { className: t.modelName, children:
|
|
1159
|
+
/* @__PURE__ */ e("h4", { className: t.modelName, children: c.modelName }),
|
|
1161
1160
|
/* @__PURE__ */ s("div", { className: t.modelTags, children: [
|
|
1162
|
-
|
|
1163
|
-
|
|
1161
|
+
c.modelProvider && /* @__PURE__ */ e(
|
|
1162
|
+
J,
|
|
1164
1163
|
{
|
|
1165
|
-
color:
|
|
1164
|
+
color: h(c.modelProvider),
|
|
1166
1165
|
style: { fontSize: 11, margin: 0 },
|
|
1167
|
-
children:
|
|
1166
|
+
children: c.modelProvider
|
|
1168
1167
|
}
|
|
1169
1168
|
),
|
|
1170
|
-
/* @__PURE__ */ e(
|
|
1169
|
+
/* @__PURE__ */ e(J, { style: { fontSize: 11, margin: 0 }, children: c.apiType })
|
|
1171
1170
|
] })
|
|
1172
1171
|
] })
|
|
1173
1172
|
] }),
|
|
1174
|
-
/* @__PURE__ */ e("p", { className: t.modelEndpoint, children:
|
|
1173
|
+
/* @__PURE__ */ e("p", { className: t.modelEndpoint, children: c.endpoint }),
|
|
1175
1174
|
/* @__PURE__ */ e("div", { className: t.modelCardFooter, children: /* @__PURE__ */ e(
|
|
1176
|
-
|
|
1175
|
+
R,
|
|
1177
1176
|
{
|
|
1178
1177
|
type: "link",
|
|
1179
1178
|
size: "small",
|
|
1180
|
-
onClick: (
|
|
1181
|
-
|
|
1179
|
+
onClick: (d) => {
|
|
1180
|
+
d.stopPropagation(), T(c.modelName);
|
|
1182
1181
|
},
|
|
1183
1182
|
children: "发起对话"
|
|
1184
1183
|
}
|
|
1185
1184
|
) })
|
|
1186
1185
|
]
|
|
1187
1186
|
},
|
|
1188
|
-
|
|
1187
|
+
c.modelName
|
|
1189
1188
|
);
|
|
1190
1189
|
}) }),
|
|
1191
1190
|
x.length > 0 && /* @__PURE__ */ s("div", { className: t.modelActionBar, children: [
|
|
@@ -1195,10 +1194,10 @@ function ut({ onStartChat: a }) {
|
|
|
1195
1194
|
" 个模型"
|
|
1196
1195
|
] }),
|
|
1197
1196
|
/* @__PURE__ */ e(
|
|
1198
|
-
|
|
1197
|
+
R,
|
|
1199
1198
|
{
|
|
1200
1199
|
type: "primary",
|
|
1201
|
-
onClick:
|
|
1200
|
+
onClick: A,
|
|
1202
1201
|
disabled: x.length === 0,
|
|
1203
1202
|
children: "批量对比"
|
|
1204
1203
|
}
|
|
@@ -1228,14 +1227,14 @@ function wt({ daily: a }) {
|
|
|
1228
1227
|
const n = Object.entries(a);
|
|
1229
1228
|
if (n.length === 0) return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
|
|
1230
1229
|
const l = Math.max(...n.map(([, o]) => o[1] + o[2]), 1);
|
|
1231
|
-
return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: n.map(([o,
|
|
1232
|
-
const
|
|
1230
|
+
return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: n.map(([o, m]) => {
|
|
1231
|
+
const N = m[1] + m[2];
|
|
1233
1232
|
return /* @__PURE__ */ s("div", { className: t.usageBarCol, children: [
|
|
1234
|
-
/* @__PURE__ */ e(W, { title: `${o}: ${
|
|
1233
|
+
/* @__PURE__ */ e(W, { title: `${o}: ${m[0]}次 / ${N} tokens`, children: /* @__PURE__ */ e(
|
|
1235
1234
|
"div",
|
|
1236
1235
|
{
|
|
1237
1236
|
className: t.usageBar,
|
|
1238
|
-
style: { height: `${Math.max(
|
|
1237
|
+
style: { height: `${Math.max(N / l * 100, 2)}%` }
|
|
1239
1238
|
}
|
|
1240
1239
|
) }),
|
|
1241
1240
|
/* @__PURE__ */ e("span", { className: t.usageBarLabel, children: o })
|
|
@@ -1246,19 +1245,19 @@ function ve({ models: a }) {
|
|
|
1246
1245
|
const n = Object.entries(a);
|
|
1247
1246
|
if (n.length === 0) return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
|
|
1248
1247
|
const l = Math.max(...n.map(([, o]) => o[0]), 1);
|
|
1249
|
-
return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: n.sort((o,
|
|
1248
|
+
return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: n.sort((o, m) => m[1][0] - o[1][0]).map(([o, m]) => /* @__PURE__ */ s("div", { className: t.modelBreakdownRow, children: [
|
|
1250
1249
|
/* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: o }),
|
|
1251
1250
|
/* @__PURE__ */ e("div", { className: t.modelBreakdownBar, children: /* @__PURE__ */ e(
|
|
1252
1251
|
"div",
|
|
1253
1252
|
{
|
|
1254
1253
|
className: t.modelBreakdownFill,
|
|
1255
|
-
style: { width: `${
|
|
1254
|
+
style: { width: `${m[0] / l * 100}%` }
|
|
1256
1255
|
}
|
|
1257
1256
|
) }),
|
|
1258
1257
|
/* @__PURE__ */ s("span", { className: t.modelBreakdownCount, children: [
|
|
1259
|
-
|
|
1258
|
+
m[0],
|
|
1260
1259
|
"次 / ",
|
|
1261
|
-
te(
|
|
1260
|
+
te(m[1] + (m[2] || 0)),
|
|
1262
1261
|
"tokens"
|
|
1263
1262
|
] })
|
|
1264
1263
|
] }, o)) });
|
|
@@ -1272,7 +1271,7 @@ const xt = [
|
|
|
1272
1271
|
render: (a) => a ? new Date(a).toLocaleString("zh-CN") : "-"
|
|
1273
1272
|
},
|
|
1274
1273
|
{ title: "模型", dataIndex: "model", key: "model", width: 150 },
|
|
1275
|
-
{ title: "协议", dataIndex: "protocol", key: "protocol", width: 90, render: (a) => /* @__PURE__ */ e(
|
|
1274
|
+
{ title: "协议", dataIndex: "protocol", key: "protocol", width: 90, render: (a) => /* @__PURE__ */ e(J, { children: a }) },
|
|
1276
1275
|
{ title: "输入", dataIndex: "promptTokens", key: "promptTokens", width: 70 },
|
|
1277
1276
|
{ title: "输出", dataIndex: "completionTokens", key: "completionTokens", width: 70 },
|
|
1278
1277
|
{ title: "总Token", dataIndex: "totalTokens", key: "totalTokens", width: 80 },
|
|
@@ -1282,7 +1281,7 @@ const xt = [
|
|
|
1282
1281
|
dataIndex: "statusCode",
|
|
1283
1282
|
key: "statusCode",
|
|
1284
1283
|
width: 60,
|
|
1285
|
-
render: (a) => a ? /* @__PURE__ */ e(
|
|
1284
|
+
render: (a) => a ? /* @__PURE__ */ e(J, { color: a < 400 ? "green" : "red", children: a }) : "-"
|
|
1286
1285
|
}
|
|
1287
1286
|
];
|
|
1288
1287
|
function Kt(a) {
|
|
@@ -1290,108 +1289,108 @@ function Kt(a) {
|
|
|
1290
1289
|
return ((n = a == null ? void 0 : a.stats) == null ? void 0 : n.recent) ?? [];
|
|
1291
1290
|
}
|
|
1292
1291
|
function Mt() {
|
|
1293
|
-
var
|
|
1294
|
-
const [a, n] =
|
|
1295
|
-
var
|
|
1296
|
-
return ((
|
|
1292
|
+
var k, d, K, _, F, Q, H;
|
|
1293
|
+
const [a, n] = S(!0), [l, o] = S(null), [m, N] = S([]), [v, y] = S(null), [g, M] = S(null), D = String(be((i) => {
|
|
1294
|
+
var P;
|
|
1295
|
+
return ((P = i.currentUser) == null ? void 0 : P.id) ?? "";
|
|
1297
1296
|
})), x = Array.from(
|
|
1298
|
-
new Set([D, _e].filter((
|
|
1299
|
-
),
|
|
1297
|
+
new Set([D, _e].filter((i) => i !== ""))
|
|
1298
|
+
), T = q(async () => {
|
|
1300
1299
|
n(!0), o(null);
|
|
1301
1300
|
try {
|
|
1302
|
-
const
|
|
1303
|
-
x.map((
|
|
1304
|
-
),
|
|
1301
|
+
const i = await Promise.allSettled(
|
|
1302
|
+
x.map((E) => ie(E))
|
|
1303
|
+
), P = [], I = /* @__PURE__ */ new Set();
|
|
1305
1304
|
let r = 0;
|
|
1306
|
-
for (const
|
|
1307
|
-
if (
|
|
1308
|
-
for (const b of
|
|
1309
|
-
const
|
|
1310
|
-
|
|
1305
|
+
for (const E of i)
|
|
1306
|
+
if (E.status === "fulfilled")
|
|
1307
|
+
for (const b of E.value) {
|
|
1308
|
+
const L = String(b.id ?? b.akPrefix ?? "");
|
|
1309
|
+
I.has(L) || (I.add(L), P.push(b));
|
|
1311
1310
|
}
|
|
1312
1311
|
else r += 1;
|
|
1313
|
-
if (r ===
|
|
1312
|
+
if (r === i.length)
|
|
1314
1313
|
throw new Error("网关不可达:无法获取 AK 列表");
|
|
1315
|
-
|
|
1316
|
-
let p = null,
|
|
1314
|
+
P.sort((E, b) => (E.id ?? 0) - (b.id ?? 0));
|
|
1315
|
+
let p = null, C = null;
|
|
1317
1316
|
try {
|
|
1318
1317
|
p = await Pe(0);
|
|
1319
|
-
} catch (
|
|
1320
|
-
|
|
1318
|
+
} catch (E) {
|
|
1319
|
+
C = E instanceof Error ? E.message : "获取用量失败";
|
|
1321
1320
|
}
|
|
1322
|
-
|
|
1323
|
-
const
|
|
1324
|
-
key:
|
|
1321
|
+
y(p);
|
|
1322
|
+
const B = P.map((E) => ({
|
|
1323
|
+
key: E,
|
|
1325
1324
|
stats: p,
|
|
1326
|
-
statsError:
|
|
1325
|
+
statsError: C
|
|
1327
1326
|
}));
|
|
1328
|
-
|
|
1329
|
-
} catch (
|
|
1330
|
-
o(
|
|
1327
|
+
N(B);
|
|
1328
|
+
} catch (i) {
|
|
1329
|
+
o(i instanceof Error ? i.message : "加载失败");
|
|
1331
1330
|
} finally {
|
|
1332
1331
|
n(!1);
|
|
1333
1332
|
}
|
|
1334
1333
|
}, [x.join(",")]);
|
|
1335
1334
|
X(() => {
|
|
1336
|
-
|
|
1337
|
-
}, [
|
|
1338
|
-
const
|
|
1339
|
-
const
|
|
1340
|
-
for (const [
|
|
1341
|
-
|
|
1335
|
+
T();
|
|
1336
|
+
}, [T]);
|
|
1337
|
+
const A = Me(() => {
|
|
1338
|
+
const i = v, P = {};
|
|
1339
|
+
for (const [I, r] of Object.entries((i == null ? void 0 : i.models) ?? {}))
|
|
1340
|
+
P[I] = [r[0] ?? 0, r[1] ?? 0, r[2] ?? 0];
|
|
1342
1341
|
return {
|
|
1343
|
-
requests: (
|
|
1344
|
-
tokens: (
|
|
1345
|
-
avgLatency: (
|
|
1346
|
-
errors: (
|
|
1347
|
-
models:
|
|
1342
|
+
requests: (i == null ? void 0 : i.totalRequests) ?? 0,
|
|
1343
|
+
tokens: (i == null ? void 0 : i.totalTokens) ?? 0,
|
|
1344
|
+
avgLatency: (i == null ? void 0 : i.avgLatencyMs) ?? 0,
|
|
1345
|
+
errors: (i == null ? void 0 : i.errorCount) ?? 0,
|
|
1346
|
+
models: P
|
|
1348
1347
|
};
|
|
1349
|
-
}, [
|
|
1348
|
+
}, [v]), h = m.reduce((i, P) => i + (P.key.tokenQuota || 0), 0), c = () => a ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载监控数据..." }) }) : l ? /* @__PURE__ */ s("div", { className: O.errorState, children: [
|
|
1350
1349
|
/* @__PURE__ */ e("div", { className: O.errorTitle, children: "模型监控数据加载失败" }),
|
|
1351
1350
|
/* @__PURE__ */ e("div", { className: O.errorDetail, children: l }),
|
|
1352
|
-
/* @__PURE__ */ e(
|
|
1351
|
+
/* @__PURE__ */ e(R, { icon: /* @__PURE__ */ e(Te, {}), onClick: T, type: "primary", children: "重试" })
|
|
1353
1352
|
] }) : /* @__PURE__ */ s("div", { className: O.page, children: [
|
|
1354
1353
|
/* @__PURE__ */ s("div", { className: O.kpiGrid, children: [
|
|
1355
|
-
/* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(
|
|
1356
|
-
/* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(
|
|
1357
|
-
/* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(
|
|
1354
|
+
/* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e($, { title: "总请求(近7天)", value: A.requests }) }),
|
|
1355
|
+
/* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e($, { title: "总 Tokens", value: te(A.tokens) }) }),
|
|
1356
|
+
/* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e($, { title: "平均延迟", value: A.avgLatency, suffix: "ms" }) }),
|
|
1358
1357
|
/* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(
|
|
1359
|
-
|
|
1358
|
+
$,
|
|
1360
1359
|
{
|
|
1361
1360
|
title: "错误数",
|
|
1362
|
-
value:
|
|
1363
|
-
valueStyle:
|
|
1361
|
+
value: A.errors,
|
|
1362
|
+
valueStyle: A.errors > 0 ? { color: "#ff4d4f" } : void 0
|
|
1364
1363
|
}
|
|
1365
1364
|
) })
|
|
1366
1365
|
] }),
|
|
1367
1366
|
/* @__PURE__ */ s("div", { className: O.sectionCard, children: [
|
|
1368
1367
|
/* @__PURE__ */ s("div", { className: O.sectionHead, children: [
|
|
1369
1368
|
/* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "AK 用量" }),
|
|
1370
|
-
|
|
1369
|
+
h > 0 && /* @__PURE__ */ s("span", { className: O.sectionHint, children: [
|
|
1371
1370
|
"合计额度 ",
|
|
1372
|
-
te(
|
|
1371
|
+
te(h),
|
|
1373
1372
|
" tokens"
|
|
1374
1373
|
] })
|
|
1375
1374
|
] }),
|
|
1376
|
-
|
|
1377
|
-
const
|
|
1375
|
+
m.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: "网关下暂无 AK" }) : /* @__PURE__ */ e("div", { className: O.akList, children: m.map((i) => {
|
|
1376
|
+
const P = i.key.totalTokens ?? 0, I = i.key.tokenQuota || 0, r = I > 0 ? Math.min(P / I * 100, 100) : 0;
|
|
1378
1377
|
return /* @__PURE__ */ s(
|
|
1379
1378
|
"div",
|
|
1380
1379
|
{
|
|
1381
1380
|
className: t.akCard,
|
|
1382
|
-
onClick: () =>
|
|
1381
|
+
onClick: () => M(i),
|
|
1383
1382
|
children: [
|
|
1384
1383
|
/* @__PURE__ */ s("div", { className: t.akCardRow, children: [
|
|
1385
|
-
/* @__PURE__ */ e("span", { className: t.akTitle, children:
|
|
1386
|
-
/* @__PURE__ */ e("span", { className: t.akPrefixSmall, children:
|
|
1384
|
+
/* @__PURE__ */ e("span", { className: t.akTitle, children: i.key.description || i.key.userName || `AK #${i.key.id}` }),
|
|
1385
|
+
/* @__PURE__ */ e("span", { className: t.akPrefixSmall, children: i.key.akPrefix }),
|
|
1387
1386
|
/* @__PURE__ */ e(
|
|
1388
1387
|
"span",
|
|
1389
1388
|
{
|
|
1390
|
-
className: `${t.akStatus} ${
|
|
1391
|
-
children:
|
|
1389
|
+
className: `${t.akStatus} ${i.key.active ? t.akStatusActive : t.akStatusRevoked}`,
|
|
1390
|
+
children: i.key.active ? "启用" : "吊销"
|
|
1392
1391
|
}
|
|
1393
1392
|
),
|
|
1394
|
-
/* @__PURE__ */ e("span", { className: t.akMetaText, children:
|
|
1393
|
+
/* @__PURE__ */ e("span", { className: t.akMetaText, children: i.key.userId === "system-default" ? "系统对话" : i.key.userId })
|
|
1395
1394
|
] }),
|
|
1396
1395
|
/* @__PURE__ */ s("div", { className: t.akCardRow2, children: [
|
|
1397
1396
|
/* @__PURE__ */ e("div", { className: t.akMiniBar, children: /* @__PURE__ */ e(
|
|
@@ -1402,21 +1401,21 @@ function Mt() {
|
|
|
1402
1401
|
}
|
|
1403
1402
|
) }),
|
|
1404
1403
|
/* @__PURE__ */ s("span", { className: t.akUsageText, children: [
|
|
1405
|
-
te(
|
|
1406
|
-
|
|
1404
|
+
te(P),
|
|
1405
|
+
I > 0 ? ` / ${te(I)}` : "",
|
|
1407
1406
|
" tokens"
|
|
1408
1407
|
] }),
|
|
1409
|
-
/* @__PURE__ */ e("span", { className: t.akMetaText, children:
|
|
1408
|
+
/* @__PURE__ */ e("span", { className: t.akMetaText, children: i.statsError ? i.statsError : i.key.lastUsedAt ? `最近使用 ${i.key.lastUsedAt}` : "尚未使用" })
|
|
1410
1409
|
] })
|
|
1411
1410
|
]
|
|
1412
1411
|
},
|
|
1413
|
-
|
|
1412
|
+
i.key.id
|
|
1414
1413
|
);
|
|
1415
1414
|
}) })
|
|
1416
1415
|
] }),
|
|
1417
1416
|
/* @__PURE__ */ s("div", { className: O.sectionCard, children: [
|
|
1418
1417
|
/* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "模型用量分布(网关全局)" }),
|
|
1419
|
-
/* @__PURE__ */ e(ve, { models:
|
|
1418
|
+
/* @__PURE__ */ e(ve, { models: A.models })
|
|
1420
1419
|
] })
|
|
1421
1420
|
] });
|
|
1422
1421
|
return /* @__PURE__ */ s("div", { className: O.container, children: [
|
|
@@ -1429,7 +1428,7 @@ function Mt() {
|
|
|
1429
1428
|
{
|
|
1430
1429
|
defaultActiveKey: "usage",
|
|
1431
1430
|
items: [
|
|
1432
|
-
{ key: "usage", label: "模型用量", children:
|
|
1431
|
+
{ key: "usage", label: "模型用量", children: c() },
|
|
1433
1432
|
{
|
|
1434
1433
|
key: "sessions",
|
|
1435
1434
|
label: "会话统计",
|
|
@@ -1444,29 +1443,29 @@ function Mt() {
|
|
|
1444
1443
|
title: g ? `AK 用量 — ${g.key.description || g.key.akPrefix}` : "",
|
|
1445
1444
|
width: 860,
|
|
1446
1445
|
open: !!g,
|
|
1447
|
-
onClose: () =>
|
|
1446
|
+
onClose: () => M(null),
|
|
1448
1447
|
destroyOnHidden: !0,
|
|
1449
1448
|
children: g && /* @__PURE__ */ s("div", { className: t.usageDrawerContent, children: [
|
|
1450
1449
|
/* @__PURE__ */ e("div", { style: { fontSize: 12, color: "#8c8c8c", marginBottom: 12 }, children: "调用监控是网关全局维度(不按 AK 留存),以下统计覆盖全部 AK; 该 AK 自身的累计消耗见「本 AK 累计 Token」。" }),
|
|
1451
1450
|
/* @__PURE__ */ s("div", { className: t.usageStatsGrid, children: [
|
|
1452
|
-
/* @__PURE__ */ e(
|
|
1453
|
-
/* @__PURE__ */ e(
|
|
1454
|
-
/* @__PURE__ */ e(
|
|
1455
|
-
/* @__PURE__ */ e(
|
|
1456
|
-
/* @__PURE__ */ e(
|
|
1451
|
+
/* @__PURE__ */ e($, { title: "总请求", value: ((k = g.stats) == null ? void 0 : k.totalRequests) ?? 0 }),
|
|
1452
|
+
/* @__PURE__ */ e($, { title: "总 Tokens", value: ((d = g.stats) == null ? void 0 : d.totalTokens) ?? 0 }),
|
|
1453
|
+
/* @__PURE__ */ e($, { title: "平均延迟", value: ((K = g.stats) == null ? void 0 : K.avgLatencyMs) ?? 0, suffix: "ms" }),
|
|
1454
|
+
/* @__PURE__ */ e($, { title: "输入 Tokens", value: ((_ = g.stats) == null ? void 0 : _.totalPromptTokens) ?? 0 }),
|
|
1455
|
+
/* @__PURE__ */ e($, { title: "输出 Tokens", value: ((F = g.stats) == null ? void 0 : F.totalCompletionTokens) ?? 0 }),
|
|
1457
1456
|
/* @__PURE__ */ e(
|
|
1458
|
-
|
|
1457
|
+
$,
|
|
1459
1458
|
{
|
|
1460
1459
|
title: "本 AK 累计 Token",
|
|
1461
1460
|
value: g.key.totalTokens ?? 0
|
|
1462
1461
|
}
|
|
1463
1462
|
),
|
|
1464
1463
|
/* @__PURE__ */ e(
|
|
1465
|
-
|
|
1464
|
+
$,
|
|
1466
1465
|
{
|
|
1467
1466
|
title: "错误数",
|
|
1468
|
-
value: ((
|
|
1469
|
-
valueStyle: (((
|
|
1467
|
+
value: ((Q = g.stats) == null ? void 0 : Q.errorCount) ?? 0,
|
|
1468
|
+
valueStyle: (((H = g.stats) == null ? void 0 : H.errorCount) ?? 0) > 0 ? { color: "#ff4d4f" } : void 0
|
|
1470
1469
|
}
|
|
1471
1470
|
)
|
|
1472
1471
|
] }),
|
|
@@ -1491,7 +1490,7 @@ function Mt() {
|
|
|
1491
1490
|
pageSize: 8,
|
|
1492
1491
|
showSizeChanger: !0,
|
|
1493
1492
|
pageSizeOptions: ["8", "20", "50", "100"],
|
|
1494
|
-
showTotal: (
|
|
1493
|
+
showTotal: (i) => `共 ${i} 条`
|
|
1495
1494
|
}
|
|
1496
1495
|
}
|
|
1497
1496
|
)
|
|
@@ -1511,36 +1510,36 @@ const bt = [
|
|
|
1511
1510
|
{ key: "model-monitor", label: "模型监控", icon: /* @__PURE__ */ e(Fe, {}) }
|
|
1512
1511
|
];
|
|
1513
1512
|
function Dt() {
|
|
1514
|
-
const [a, n] =
|
|
1515
|
-
o(
|
|
1516
|
-
},
|
|
1513
|
+
const [a, n] = S("model-management"), [l, o] = S([]), m = (y) => {
|
|
1514
|
+
o(y), n("model-chat");
|
|
1515
|
+
}, N = Me(() => bt, []), v = (y, g, M = !1) => /* @__PURE__ */ e(
|
|
1517
1516
|
"div",
|
|
1518
1517
|
{
|
|
1519
1518
|
style: {
|
|
1520
|
-
display: a ===
|
|
1519
|
+
display: a === y ? M ? "flex" : "block" : "none",
|
|
1521
1520
|
height: "100%",
|
|
1522
|
-
...
|
|
1521
|
+
...M ? { flexDirection: "column" } : {}
|
|
1523
1522
|
},
|
|
1524
1523
|
children: g
|
|
1525
1524
|
}
|
|
1526
1525
|
);
|
|
1527
1526
|
return /* @__PURE__ */ s("div", { className: t.container, children: [
|
|
1528
|
-
/* @__PURE__ */ e("aside", { className: t.sidebar, children: /* @__PURE__ */ e("nav", { className: t.menuList, children:
|
|
1527
|
+
/* @__PURE__ */ e("aside", { className: t.sidebar, children: /* @__PURE__ */ e("nav", { className: t.menuList, children: N.map((y) => /* @__PURE__ */ e(W, { title: y.label, placement: "right", children: /* @__PURE__ */ e(
|
|
1529
1528
|
"div",
|
|
1530
1529
|
{
|
|
1531
|
-
className: `${t.menuItem} ${a ===
|
|
1532
|
-
onClick: () => n(
|
|
1533
|
-
children: /* @__PURE__ */ e("span", { className: t.menuIcon, children:
|
|
1530
|
+
className: `${t.menuItem} ${a === y.key ? t.menuItemActive : ""}`,
|
|
1531
|
+
onClick: () => n(y.key),
|
|
1532
|
+
children: /* @__PURE__ */ e("span", { className: t.menuIcon, children: y.icon })
|
|
1534
1533
|
}
|
|
1535
|
-
) },
|
|
1534
|
+
) }, y.key)) }) }),
|
|
1536
1535
|
/* @__PURE__ */ s("main", { className: t.panelArea, children: [
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1536
|
+
v("model-management", /* @__PURE__ */ e(ut, { onStartChat: m })),
|
|
1537
|
+
v("model-chat", /* @__PURE__ */ e(mt, { initialModels: l }), !0),
|
|
1538
|
+
v("ak-management", /* @__PURE__ */ e(ot, {})),
|
|
1539
|
+
v("agent-app", /* @__PURE__ */ e(Ye, {})),
|
|
1540
|
+
v("mcp-service", /* @__PURE__ */ e(Ve, {})),
|
|
1541
|
+
v("skill-market", /* @__PURE__ */ e(Xe, {})),
|
|
1542
|
+
v("model-monitor", /* @__PURE__ */ e(Mt, {}))
|
|
1544
1543
|
] })
|
|
1545
1544
|
] });
|
|
1546
1545
|
}
|