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