@yuku123/z-team-component 0.2.40 → 0.2.41
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-D2R0AgNC.js → ComponentDoc-BztX6VlY.js} +39 -39
- package/dist/{InvitationManagementPage-CEV7N3zE.js → InvitationManagementPage-Bs9EVx4Z.js} +1 -1
- package/dist/{OnboardingPage-DClNUCVP.js → OnboardingPage-b3GCxnH7.js} +2 -2
- package/dist/{SystemShell-B8mZr4ql.js → SystemShell-j8IxtHjS.js} +1 -1
- package/dist/{api-BrM7h9IZ.js → api-CBB4Fa8N.js} +1 -1
- package/dist/{index-DaVCpPYX.js → index-BapG4vu3.js} +1 -1
- package/dist/index-CcpWacSZ.js +1664 -0
- package/dist/{index-DY6GPSIu.js → index-ClJQ9FRS.js} +1218 -1203
- package/dist/{index-BchBIdvC.js → index-ClibxgPN.js} +1054 -1056
- package/dist/index-Cx9Yfc6I.js +1514 -0
- package/dist/{index-DbFxBDoO.js → index-D-wT2z-O.js} +2 -2
- package/dist/{index-DKSp5bM6.js → index-D-xqQriS.js} +1973 -2005
- package/dist/{index-BAY37t4f.js → index-D4tQ0KN9.js} +1 -1
- package/dist/{index-CR3sbzOU.js → index-DyJp2kSb.js} +3 -3
- package/dist/{index-DpUTAD45.js → index-t109_mPP.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/pages.js +1 -1
- package/dist/{schedule-C-4ksDPw.js → schedule-Dstx5SE_.js} +34 -34
- package/dist/{webide-RsFP9pHM.js → webide-CTvdgMFE.js} +1837 -1840
- package/package.json +1 -1
- package/dist/index-D0emG0lK.js +0 -844
- package/dist/index-a4cM-7bG.js +0 -1433
|
@@ -0,0 +1,1514 @@
|
|
|
1
|
+
import { jsxs as s, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { CopyOutlined as se, ReloadOutlined as Ne, PlusOutlined as ve, DeleteOutlined as Pe, ClearOutlined as Ie, CloseOutlined as Be, SendOutlined as $e, RobotOutlined as Te, CloudServerOutlined as Oe, MessageOutlined as De, KeyOutlined as Le, ApiOutlined as Re, ToolOutlined as ze, BarChartOutlined as qe } from "@ant-design/icons";
|
|
3
|
+
import { Tooltip as Q, Tabs as Ce, Button as z, Modal as ce, Input as Se, Drawer as we, Spin as V, Statistic as $, Table as Ae, message as F, Tag as G, Select as Ue, Checkbox as He } from "antd";
|
|
4
|
+
import { useState as N, useCallback as H, useEffect as ae, useRef as de, useMemo as xe, Suspense as je, lazy as Fe } from "react";
|
|
5
|
+
import { s as t } from "./SmartWorkbench.module-xRRmpTTw.js";
|
|
6
|
+
import { AgentAppList as Ge, McpPage as Je, SkillMarket as Qe } from "@yuku123/z-agent-component";
|
|
7
|
+
const le = "ft_gateway_default_ak", X = "", ue = "";
|
|
8
|
+
function Z(a = {}) {
|
|
9
|
+
const n = { Accept: "application/json", ...a };
|
|
10
|
+
try {
|
|
11
|
+
const l = localStorage.getItem("token");
|
|
12
|
+
l && (n.Authorization = `Bearer ${l}`);
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
return n;
|
|
16
|
+
}
|
|
17
|
+
function We(a) {
|
|
18
|
+
return {
|
|
19
|
+
modelName: String(a.modelName ?? a.model_name ?? a.service ?? ""),
|
|
20
|
+
service: String(a.service ?? a.modelName ?? ""),
|
|
21
|
+
endpoint: String(a.endpoint ?? ""),
|
|
22
|
+
modelProvider: a.modelProvider ?? a.model_provider ?? null,
|
|
23
|
+
apiType: String(a.apiType ?? a.api_type ?? "OpenAPI")
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async function Me() {
|
|
27
|
+
let a;
|
|
28
|
+
try {
|
|
29
|
+
a = await fetch(`${X}/api/scenario-instances/0/models`, {
|
|
30
|
+
credentials: "include",
|
|
31
|
+
headers: Z({
|
|
32
|
+
Accept: "application/json",
|
|
33
|
+
"project-env": window.ENV_TYPE ?? "local"
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
} catch {
|
|
37
|
+
throw new Error("模型列表不可达:模型配置接口请求失败");
|
|
38
|
+
}
|
|
39
|
+
if (!a.ok)
|
|
40
|
+
throw new Error(`模型列表获取失败(HTTP ${a.status})`);
|
|
41
|
+
let n;
|
|
42
|
+
try {
|
|
43
|
+
n = await a.json();
|
|
44
|
+
} catch {
|
|
45
|
+
throw new Error("模型列表返回格式异常(非 JSON)");
|
|
46
|
+
}
|
|
47
|
+
const l = n != null && n.success ? n.data : (n == null ? void 0 : n.data) ?? n;
|
|
48
|
+
if (!Array.isArray(l))
|
|
49
|
+
throw new Error("模型列表返回格式异常(非数组)");
|
|
50
|
+
return l.map(We);
|
|
51
|
+
}
|
|
52
|
+
async function Ye(a, n, l, i) {
|
|
53
|
+
var K, S, C, x;
|
|
54
|
+
const o = await fetch(`${ue}/v1/chat/completions`, {
|
|
55
|
+
method: "POST",
|
|
56
|
+
headers: {
|
|
57
|
+
"Content-Type": "application/json",
|
|
58
|
+
Authorization: `Bearer ${a}`,
|
|
59
|
+
Accept: "text/event-stream"
|
|
60
|
+
},
|
|
61
|
+
body: JSON.stringify({
|
|
62
|
+
model: n,
|
|
63
|
+
messages: l,
|
|
64
|
+
stream: !0
|
|
65
|
+
}),
|
|
66
|
+
signal: i.signal
|
|
67
|
+
});
|
|
68
|
+
if (!o.ok || !o.body) {
|
|
69
|
+
const T = await o.text().catch(() => "");
|
|
70
|
+
if (/<!doctype html/i.test(T.slice(0, 200)))
|
|
71
|
+
throw new Error("模型网关未接入(/v1/chat/completions 落到主壳 SPA,无网关响应)");
|
|
72
|
+
let E = `HTTP ${o.status}`;
|
|
73
|
+
try {
|
|
74
|
+
const f = JSON.parse(T);
|
|
75
|
+
E = ((K = f == null ? void 0 : f.error) == null ? void 0 : K.message) ?? E;
|
|
76
|
+
} catch {
|
|
77
|
+
T && (E = T);
|
|
78
|
+
}
|
|
79
|
+
throw new Error(E);
|
|
80
|
+
}
|
|
81
|
+
const v = o.body.getReader(), d = new TextDecoder();
|
|
82
|
+
let k = "";
|
|
83
|
+
try {
|
|
84
|
+
for (; ; ) {
|
|
85
|
+
const { done: T, value: E } = await v.read();
|
|
86
|
+
if (T) break;
|
|
87
|
+
k += d.decode(E, { stream: !0 });
|
|
88
|
+
const f = k.split(`
|
|
89
|
+
|
|
90
|
+
`);
|
|
91
|
+
k = f.pop() ?? "";
|
|
92
|
+
for (const p of f) {
|
|
93
|
+
let y = "";
|
|
94
|
+
for (const u of p.split(`
|
|
95
|
+
`))
|
|
96
|
+
u.startsWith("data:") && (y += u.slice(5).trim());
|
|
97
|
+
if (!y || y === "[DONE]") {
|
|
98
|
+
if (y === "[DONE]") {
|
|
99
|
+
i.onDone();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const u = JSON.parse(y), _ = u == null ? void 0 : u.choices;
|
|
106
|
+
if (Array.isArray(_) && _.length > 0) {
|
|
107
|
+
const m = (S = _[0]) == null ? void 0 : S.delta;
|
|
108
|
+
if (m != null && m.content && i.onDelta(m.content), (C = _[0]) == null ? void 0 : C.finish_reason) {
|
|
109
|
+
const b = u != null && u.usage ? {
|
|
110
|
+
promptTokens: u.usage.prompt_tokens ?? 0,
|
|
111
|
+
completionTokens: u.usage.completion_tokens ?? 0,
|
|
112
|
+
totalTokens: u.usage.total_tokens ?? 0
|
|
113
|
+
} : void 0;
|
|
114
|
+
i.onDone(b);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (u != null && u.usage) {
|
|
119
|
+
const m = {
|
|
120
|
+
promptTokens: u.usage.prompt_tokens ?? 0,
|
|
121
|
+
completionTokens: u.usage.completion_tokens ?? 0,
|
|
122
|
+
totalTokens: u.usage.total_tokens ?? 0
|
|
123
|
+
};
|
|
124
|
+
i.onDone(m);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
i.onDone();
|
|
132
|
+
} catch (T) {
|
|
133
|
+
if ((x = i.signal) != null && x.aborted) return;
|
|
134
|
+
throw i.onError(T instanceof Error ? T : new Error(String(T))), T;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async function ne(a, n) {
|
|
138
|
+
const l = await a.text();
|
|
139
|
+
if (!a.ok)
|
|
140
|
+
throw new Error(`${n}失败 HTTP ${a.status}${l ? `: ${l.slice(0, 120)}` : ""}`);
|
|
141
|
+
if (/<!doctype html/i.test(l.slice(0, 200)))
|
|
142
|
+
throw new Error("AK 接口落到主壳 SPA(无后端响应)");
|
|
143
|
+
try {
|
|
144
|
+
return JSON.parse(l);
|
|
145
|
+
} catch {
|
|
146
|
+
throw new Error(`${n}返回非 JSON:${l.slice(0, 120)}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function Ve(a) {
|
|
150
|
+
const n = a.status === 1;
|
|
151
|
+
return {
|
|
152
|
+
id: Number(a.id),
|
|
153
|
+
akPrefix: a.access_key ?? "",
|
|
154
|
+
userId: a.owner_user_id ?? "",
|
|
155
|
+
userName: a.owner_user_name ?? "",
|
|
156
|
+
description: a.description || a.ak_name || "",
|
|
157
|
+
status: n ? "active" : "disabled",
|
|
158
|
+
active: n,
|
|
159
|
+
isDeleted: a.is_deleted ?? 0,
|
|
160
|
+
totalRequests: 0,
|
|
161
|
+
totalTokens: Number(a.total_tokens ?? 0),
|
|
162
|
+
tokenQuota: 0,
|
|
163
|
+
rateLimitRpm: 0,
|
|
164
|
+
defaultModel: null,
|
|
165
|
+
lastUsedAt: a.last_used_time ?? null,
|
|
166
|
+
createTime: (a.created_time ?? "").replace("T", " ").slice(0, 19),
|
|
167
|
+
updateTime: (a.updated_time ?? "").replace("T", " ").slice(0, 19),
|
|
168
|
+
secret: a.secret_key
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
async function _e(a, n, l) {
|
|
172
|
+
const i = await fetch(`${X}/api/ak/create`, {
|
|
173
|
+
method: "POST",
|
|
174
|
+
headers: Z({ Accept: "application/json", "Content-Type": "application/json" }),
|
|
175
|
+
credentials: "include",
|
|
176
|
+
body: JSON.stringify({
|
|
177
|
+
akName: l || `AK-${n || a}`,
|
|
178
|
+
description: l,
|
|
179
|
+
akType: "PERSONAL",
|
|
180
|
+
ownerUserId: a,
|
|
181
|
+
ownerUserName: n
|
|
182
|
+
})
|
|
183
|
+
}), o = await ne(i, "创建 AK"), v = (o == null ? void 0 : o.data) ?? {}, d = v.accessKey ?? "", k = v.secretKey ?? "";
|
|
184
|
+
return d && k && pe(d, k), { apiKey: k, akPrefix: d, message: "AK 已创建,secretKey 仅创建时可见" };
|
|
185
|
+
}
|
|
186
|
+
async function ie(a) {
|
|
187
|
+
const n = await fetch(
|
|
188
|
+
`${X}/api/ak/list`,
|
|
189
|
+
{ headers: Z({ Accept: "application/json" }), credentials: "include" }
|
|
190
|
+
), l = await ne(n, "获取 AK 列表"), i = Array.isArray(l == null ? void 0 : l.data) ? l.data : [];
|
|
191
|
+
return (a ? i.filter((v) => !v.owner_user_id || String(v.owner_user_id) === String(a)) : i).filter((v) => (v.is_deleted ?? 0) === 0).map(Ve);
|
|
192
|
+
}
|
|
193
|
+
async function Xe(a) {
|
|
194
|
+
const n = await fetch(`${X}/api/ak/delete?id=${encodeURIComponent(String(a))}`, {
|
|
195
|
+
method: "POST",
|
|
196
|
+
headers: Z({ Accept: "application/json" }),
|
|
197
|
+
credentials: "include"
|
|
198
|
+
});
|
|
199
|
+
await ne(n, "吊销 AK");
|
|
200
|
+
}
|
|
201
|
+
async function Ke(a) {
|
|
202
|
+
var d;
|
|
203
|
+
const n = await fetch(
|
|
204
|
+
`${X}/api/admin/llm-call-monitor/stats?hours=24`,
|
|
205
|
+
{ headers: Z({ Accept: "application/json" }), credentials: "include" }
|
|
206
|
+
), l = await ne(n, "获取调用统计"), o = ((l == null ? void 0 : l.data) ?? {}).summary ?? {};
|
|
207
|
+
let v = [];
|
|
208
|
+
try {
|
|
209
|
+
const k = await fetch(
|
|
210
|
+
`${X}/api/admin/llm-call-monitor/recent?page=1&size=20`,
|
|
211
|
+
{ headers: Z({ Accept: "application/json" }), credentials: "include" }
|
|
212
|
+
), K = await ne(k, "获取调用明细");
|
|
213
|
+
v = (Array.isArray((d = K == null ? void 0 : K.data) == null ? void 0 : d.records) ? K.data.records : []).map((C, x) => ({
|
|
214
|
+
id: Number(C.id ?? x),
|
|
215
|
+
apiKeyId: a,
|
|
216
|
+
protocol: "chat/completions",
|
|
217
|
+
model: String(C.model ?? ""),
|
|
218
|
+
stream: Number(C.stream ?? 0),
|
|
219
|
+
promptTokens: Number(C.promptTokens ?? 0),
|
|
220
|
+
completionTokens: Number(C.completionTokens ?? 0),
|
|
221
|
+
totalTokens: Number(C.totalTokens ?? 0),
|
|
222
|
+
latencyMs: Number(C.durationMs ?? 0),
|
|
223
|
+
statusCode: C.success === !1 || C.success === 0 ? 500 : 200,
|
|
224
|
+
errorMsg: C.errorType ?? null,
|
|
225
|
+
createTime: String(C.createTime ?? "").replace("T", " ").slice(0, 19)
|
|
226
|
+
}));
|
|
227
|
+
} catch {
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
totalRequests: Number(o.totalCount ?? 0),
|
|
231
|
+
totalPromptTokens: 0,
|
|
232
|
+
totalCompletionTokens: 0,
|
|
233
|
+
totalTokens: Number(o.totalTokens ?? 0),
|
|
234
|
+
avgLatencyMs: Number(o.avgDurationMs ?? 0),
|
|
235
|
+
errorCount: Number(o.failCount ?? 0),
|
|
236
|
+
daily: {},
|
|
237
|
+
models: {},
|
|
238
|
+
recent: v
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function Ze() {
|
|
242
|
+
return typeof window < "u" ? `${window.location.origin}${ue}` : ue;
|
|
243
|
+
}
|
|
244
|
+
const he = "ft_gateway_ak_cache";
|
|
245
|
+
function pe(a, n) {
|
|
246
|
+
try {
|
|
247
|
+
const l = JSON.parse(localStorage.getItem(he) || "{}");
|
|
248
|
+
l[a] = n, localStorage.setItem(he, JSON.stringify(l));
|
|
249
|
+
} catch {
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function et(a) {
|
|
253
|
+
try {
|
|
254
|
+
return JSON.parse(localStorage.getItem(he) || "{}")[a] || null;
|
|
255
|
+
} catch {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
async function tt() {
|
|
260
|
+
try {
|
|
261
|
+
const i = localStorage.getItem(le);
|
|
262
|
+
if (i) return i;
|
|
263
|
+
} catch {
|
|
264
|
+
}
|
|
265
|
+
const n = (await ie("").catch(() => [])).find((i) => i.active && i.secret);
|
|
266
|
+
if (n != null && n.secret) {
|
|
267
|
+
try {
|
|
268
|
+
localStorage.setItem(le, n.secret);
|
|
269
|
+
} catch {
|
|
270
|
+
}
|
|
271
|
+
return n.akPrefix && pe(n.akPrefix, n.secret), n.secret;
|
|
272
|
+
}
|
|
273
|
+
const l = await _e(
|
|
274
|
+
"system-default",
|
|
275
|
+
"系统默认",
|
|
276
|
+
"智能工作台默认AK(自动创建)"
|
|
277
|
+
);
|
|
278
|
+
if (!l.apiKey)
|
|
279
|
+
throw new Error("AK 创建成功但未返回 secretKey");
|
|
280
|
+
try {
|
|
281
|
+
localStorage.setItem(le, l.apiKey);
|
|
282
|
+
} catch {
|
|
283
|
+
}
|
|
284
|
+
return l.apiKey;
|
|
285
|
+
}
|
|
286
|
+
function Ee() {
|
|
287
|
+
try {
|
|
288
|
+
localStorage.removeItem(le);
|
|
289
|
+
} catch {
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const ke = 1e7;
|
|
293
|
+
function fe(a) {
|
|
294
|
+
return a >= 1e6 ? `${(a / 1e6).toFixed(1)}M` : a >= 1e3 ? `${(a / 1e3).toFixed(1)}K` : `${a}`;
|
|
295
|
+
}
|
|
296
|
+
function at(a) {
|
|
297
|
+
return `# OpenAI 兼容
|
|
298
|
+
curl -X POST ${a}/v1/chat/completions \\
|
|
299
|
+
-H "Content-Type: application/json" \\
|
|
300
|
+
-H "Authorization: Bearer ft-xxx" \\
|
|
301
|
+
-d '{
|
|
302
|
+
"model": "qwen3.6-flash",
|
|
303
|
+
"messages": [{"role":"user","content":"你好"}],
|
|
304
|
+
"stream": true
|
|
305
|
+
}'`;
|
|
306
|
+
}
|
|
307
|
+
function nt(a) {
|
|
308
|
+
return `# Anthropic 兼容
|
|
309
|
+
curl -X POST ${a}/v1/messages \\
|
|
310
|
+
-H "Content-Type: application/json" \\
|
|
311
|
+
-H "x-api-key: ft-xxx" \\
|
|
312
|
+
-d '{
|
|
313
|
+
"model": "qwen3.6-flash",
|
|
314
|
+
"messages": [{"role":"user","content":"你好"}]
|
|
315
|
+
}'`;
|
|
316
|
+
}
|
|
317
|
+
function st() {
|
|
318
|
+
const [a, n] = N("personal"), [l, i] = N([]), [o, v] = N([]), [d, k] = N(!0), [K, S] = N(!1), [C, x] = N(!1), [T, E] = N(""), [f, p] = N({ open: !1 }), [y, u] = N(null), [_, m] = N(null), [B, b] = N(!1), L = "zifang", P = "zifang", I = Ze(), j = H(async () => {
|
|
319
|
+
k(!0);
|
|
320
|
+
try {
|
|
321
|
+
const [c, M] = await Promise.all([
|
|
322
|
+
ie("system-default").catch(() => []),
|
|
323
|
+
ie(L).catch(() => [])
|
|
324
|
+
]);
|
|
325
|
+
i(c), v(M);
|
|
326
|
+
} finally {
|
|
327
|
+
k(!1);
|
|
328
|
+
}
|
|
329
|
+
}, [L]);
|
|
330
|
+
ae(() => {
|
|
331
|
+
j();
|
|
332
|
+
}, [j]);
|
|
333
|
+
const r = () => {
|
|
334
|
+
E(""), x(!0);
|
|
335
|
+
}, h = async () => {
|
|
336
|
+
if (!T.trim()) {
|
|
337
|
+
F.warning("请输入 AK 名称");
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
S(!0);
|
|
341
|
+
try {
|
|
342
|
+
const c = await _e(L, P, T.trim());
|
|
343
|
+
pe(c.akPrefix, c.apiKey), x(!1), p({
|
|
344
|
+
open: !0,
|
|
345
|
+
apiKey: c.apiKey,
|
|
346
|
+
akPrefix: c.akPrefix
|
|
347
|
+
}), j();
|
|
348
|
+
} catch (c) {
|
|
349
|
+
F.error(c instanceof Error ? c.message : "创建 AK 失败");
|
|
350
|
+
} finally {
|
|
351
|
+
S(!1);
|
|
352
|
+
}
|
|
353
|
+
}, w = (c) => {
|
|
354
|
+
ce.confirm({
|
|
355
|
+
title: "确认吊销此 AK?",
|
|
356
|
+
content: "吊销后此 AK 将立即失效,无法恢复。",
|
|
357
|
+
okText: "确认吊销",
|
|
358
|
+
okType: "danger",
|
|
359
|
+
cancelText: "取消",
|
|
360
|
+
onOk: async () => {
|
|
361
|
+
try {
|
|
362
|
+
await Xe(c), F.success("AK 已吊销"), j(), Ee();
|
|
363
|
+
} catch (M) {
|
|
364
|
+
F.error(M instanceof Error ? M.message : "吊销失败");
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}, A = (c) => {
|
|
369
|
+
navigator.clipboard.writeText(c).then(() => F.success("已复制到剪贴板")).catch(() => F.warning("复制失败,请手动复制"));
|
|
370
|
+
}, J = (c) => {
|
|
371
|
+
const M = et(c.akPrefix);
|
|
372
|
+
M ? A(M) : (A(c.akPrefix), F.info("完整 AK 未在本地缓存(可能在本设备外创建),已复制前缀"));
|
|
373
|
+
}, O = async (c) => {
|
|
374
|
+
u(c), b(!0), m(null);
|
|
375
|
+
try {
|
|
376
|
+
const M = await Ke(c.id);
|
|
377
|
+
m(M);
|
|
378
|
+
} catch (M) {
|
|
379
|
+
F.error(M instanceof Error ? M.message : "获取用量失败");
|
|
380
|
+
} finally {
|
|
381
|
+
b(!1);
|
|
382
|
+
}
|
|
383
|
+
}, W = () => {
|
|
384
|
+
u(null), m(null);
|
|
385
|
+
}, oe = (c) => {
|
|
386
|
+
const M = Object.entries(c);
|
|
387
|
+
if (M.length === 0)
|
|
388
|
+
return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
|
|
389
|
+
const Y = Math.max(...M.map(([, g]) => g[1] + g[2]), 1);
|
|
390
|
+
return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: M.map(([g, U]) => {
|
|
391
|
+
const ge = U[1] + U[2], be = ge / Y * 100;
|
|
392
|
+
return /* @__PURE__ */ s("div", { className: t.usageBarCol, children: [
|
|
393
|
+
/* @__PURE__ */ e(Q, { title: `${g}: ${U[0]}次 / ${ge} tokens`, children: /* @__PURE__ */ e(
|
|
394
|
+
"div",
|
|
395
|
+
{
|
|
396
|
+
className: t.usageBar,
|
|
397
|
+
style: { height: `${Math.max(be, 2)}%` }
|
|
398
|
+
}
|
|
399
|
+
) }),
|
|
400
|
+
/* @__PURE__ */ e("span", { className: t.usageBarLabel, children: g })
|
|
401
|
+
] }, g);
|
|
402
|
+
}) });
|
|
403
|
+
}, R = (c) => {
|
|
404
|
+
const M = Object.entries(c);
|
|
405
|
+
if (M.length === 0)
|
|
406
|
+
return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
|
|
407
|
+
const Y = Math.max(...M.map(([, g]) => g[0]), 1);
|
|
408
|
+
return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: M.sort((g, U) => U[1][0] - g[1][0]).map(([g, U]) => /* @__PURE__ */ s("div", { className: t.modelBreakdownRow, children: [
|
|
409
|
+
/* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: g }),
|
|
410
|
+
/* @__PURE__ */ e("div", { className: t.modelBreakdownBar, children: /* @__PURE__ */ e(
|
|
411
|
+
"div",
|
|
412
|
+
{
|
|
413
|
+
className: t.modelBreakdownFill,
|
|
414
|
+
style: { width: `${U[0] / Y * 100}%` }
|
|
415
|
+
}
|
|
416
|
+
) }),
|
|
417
|
+
/* @__PURE__ */ s("span", { className: t.modelBreakdownCount, children: [
|
|
418
|
+
U[0],
|
|
419
|
+
"次 / ",
|
|
420
|
+
U[1],
|
|
421
|
+
"tokens"
|
|
422
|
+
] })
|
|
423
|
+
] }, g)) });
|
|
424
|
+
}, q = [
|
|
425
|
+
{
|
|
426
|
+
title: "时间",
|
|
427
|
+
dataIndex: "createTime",
|
|
428
|
+
key: "createTime",
|
|
429
|
+
width: 160,
|
|
430
|
+
render: (c) => c ? new Date(c).toLocaleString("zh-CN") : "-"
|
|
431
|
+
},
|
|
432
|
+
{ title: "模型", dataIndex: "model", key: "model", width: 140 },
|
|
433
|
+
{
|
|
434
|
+
title: "协议",
|
|
435
|
+
dataIndex: "protocol",
|
|
436
|
+
key: "protocol",
|
|
437
|
+
width: 90,
|
|
438
|
+
render: (c) => /* @__PURE__ */ e(G, { children: c })
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
title: "输入",
|
|
442
|
+
dataIndex: "promptTokens",
|
|
443
|
+
key: "promptTokens",
|
|
444
|
+
width: 70
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
title: "输出",
|
|
448
|
+
dataIndex: "completionTokens",
|
|
449
|
+
key: "completionTokens",
|
|
450
|
+
width: 70
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
title: "总Token",
|
|
454
|
+
dataIndex: "totalTokens",
|
|
455
|
+
key: "totalTokens",
|
|
456
|
+
width: 80
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
title: "耗时",
|
|
460
|
+
dataIndex: "latencyMs",
|
|
461
|
+
key: "latencyMs",
|
|
462
|
+
width: 70,
|
|
463
|
+
render: (c) => c ? `${c}ms` : "-"
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
title: "状态",
|
|
467
|
+
dataIndex: "statusCode",
|
|
468
|
+
key: "statusCode",
|
|
469
|
+
width: 60,
|
|
470
|
+
render: (c) => c ? /* @__PURE__ */ e(G, { color: c < 400 ? "green" : "red", children: c }) : "-"
|
|
471
|
+
}
|
|
472
|
+
], ee = (c, M) => {
|
|
473
|
+
const Y = Array.isArray(c) ? c : [];
|
|
474
|
+
return d ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 40 }, children: /* @__PURE__ */ e(V, { tip: "加载中..." }) }) : Y.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: M ? "暂无应用 AK" : "暂无个人 AK,点击上方按钮生成" }) : /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: Y.map((g) => /* @__PURE__ */ s(
|
|
475
|
+
"div",
|
|
476
|
+
{
|
|
477
|
+
className: t.akCard,
|
|
478
|
+
onClick: () => O(g),
|
|
479
|
+
children: [
|
|
480
|
+
/* @__PURE__ */ s("div", { className: t.akCardRow, children: [
|
|
481
|
+
/* @__PURE__ */ e("span", { className: t.akTitle, children: g.description || g.akPrefix.replace("...", "**") }),
|
|
482
|
+
/* @__PURE__ */ e("code", { className: t.akPrefixSmall, children: g.akPrefix.replace("...", "**") }),
|
|
483
|
+
/* @__PURE__ */ e(
|
|
484
|
+
"span",
|
|
485
|
+
{
|
|
486
|
+
className: `${t.akStatus} ${g.active ? t.akStatusActive : t.akStatusRevoked}`,
|
|
487
|
+
children: g.active ? "活跃" : "已吊销"
|
|
488
|
+
}
|
|
489
|
+
),
|
|
490
|
+
g.defaultModel && /* @__PURE__ */ s(G, { style: { fontSize: 11 }, children: [
|
|
491
|
+
"默认: ",
|
|
492
|
+
g.defaultModel
|
|
493
|
+
] }),
|
|
494
|
+
/* @__PURE__ */ s(
|
|
495
|
+
"div",
|
|
496
|
+
{
|
|
497
|
+
className: t.akCardActions,
|
|
498
|
+
onClick: (U) => U.stopPropagation(),
|
|
499
|
+
children: [
|
|
500
|
+
/* @__PURE__ */ e(Q, { title: "复制完整 AK", children: /* @__PURE__ */ e(
|
|
501
|
+
z,
|
|
502
|
+
{
|
|
503
|
+
size: "small",
|
|
504
|
+
icon: /* @__PURE__ */ e(se, {}),
|
|
505
|
+
onClick: () => J(g),
|
|
506
|
+
children: "复制"
|
|
507
|
+
}
|
|
508
|
+
) }),
|
|
509
|
+
!M && g.active && /* @__PURE__ */ e(
|
|
510
|
+
z,
|
|
511
|
+
{
|
|
512
|
+
size: "small",
|
|
513
|
+
danger: !0,
|
|
514
|
+
icon: /* @__PURE__ */ e(Pe, {}),
|
|
515
|
+
onClick: () => w(g.id),
|
|
516
|
+
children: "吊销"
|
|
517
|
+
}
|
|
518
|
+
)
|
|
519
|
+
]
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
] }),
|
|
523
|
+
/* @__PURE__ */ s("div", { className: t.akCardRow2, children: [
|
|
524
|
+
/* @__PURE__ */ e("div", { className: t.akMiniBar, children: /* @__PURE__ */ e(
|
|
525
|
+
"div",
|
|
526
|
+
{
|
|
527
|
+
className: t.akMiniBarFill,
|
|
528
|
+
style: {
|
|
529
|
+
width: `${Math.min(
|
|
530
|
+
(g.totalTokens || 0) / (g.tokenQuota || ke) * 100,
|
|
531
|
+
100
|
|
532
|
+
)}%`
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
) }),
|
|
536
|
+
/* @__PURE__ */ s("span", { className: t.akUsageText, children: [
|
|
537
|
+
fe(g.totalTokens || 0),
|
|
538
|
+
" /",
|
|
539
|
+
" ",
|
|
540
|
+
fe(g.tokenQuota || ke)
|
|
541
|
+
] }),
|
|
542
|
+
/* @__PURE__ */ s("span", { className: t.akMetaText, children: [
|
|
543
|
+
g.totalRequests || 0,
|
|
544
|
+
" 次请求"
|
|
545
|
+
] }),
|
|
546
|
+
/* @__PURE__ */ e("span", { className: t.akMetaText, children: new Date(g.createTime).toLocaleDateString("zh-CN") })
|
|
547
|
+
] })
|
|
548
|
+
]
|
|
549
|
+
},
|
|
550
|
+
g.id
|
|
551
|
+
)) });
|
|
552
|
+
};
|
|
553
|
+
return /* @__PURE__ */ s("div", { className: t.akContainer, children: [
|
|
554
|
+
/* @__PURE__ */ s("div", { className: t.akIntegrationPanel, children: [
|
|
555
|
+
/* @__PURE__ */ e("h4", { className: t.akIntegrationTitle, children: "协议接入地址" }),
|
|
556
|
+
/* @__PURE__ */ s("div", { className: t.akBaseUrlRow, children: [
|
|
557
|
+
/* @__PURE__ */ s("div", { className: t.akBaseUrlItem, children: [
|
|
558
|
+
/* @__PURE__ */ e("span", { className: t.akBaseUrlLabel, children: "OpenAI 兼容" }),
|
|
559
|
+
/* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: I }),
|
|
560
|
+
/* @__PURE__ */ e(Q, { title: "复制 Base URL", children: /* @__PURE__ */ e(
|
|
561
|
+
se,
|
|
562
|
+
{
|
|
563
|
+
className: t.akCopyIcon,
|
|
564
|
+
onClick: () => A(I)
|
|
565
|
+
}
|
|
566
|
+
) })
|
|
567
|
+
] }),
|
|
568
|
+
/* @__PURE__ */ s("div", { className: t.akBaseUrlItem, children: [
|
|
569
|
+
/* @__PURE__ */ e("span", { className: t.akBaseUrlLabel, children: "Anthropic 兼容" }),
|
|
570
|
+
/* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: I }),
|
|
571
|
+
/* @__PURE__ */ e(Q, { title: "复制 Base URL", children: /* @__PURE__ */ e(
|
|
572
|
+
se,
|
|
573
|
+
{
|
|
574
|
+
className: t.akCopyIcon,
|
|
575
|
+
onClick: () => A(I)
|
|
576
|
+
}
|
|
577
|
+
) })
|
|
578
|
+
] })
|
|
579
|
+
] }),
|
|
580
|
+
/* @__PURE__ */ s("div", { className: t.akIntegrationGrid, children: [
|
|
581
|
+
/* @__PURE__ */ s("div", { children: [
|
|
582
|
+
/* @__PURE__ */ e("p", { className: t.akCodeLabel, children: "OpenAI 兼容 — curl 示例" }),
|
|
583
|
+
/* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: at(I) })
|
|
584
|
+
] }),
|
|
585
|
+
/* @__PURE__ */ s("div", { children: [
|
|
586
|
+
/* @__PURE__ */ e("p", { className: t.akCodeLabel, children: "Anthropic 兼容 — curl 示例" }),
|
|
587
|
+
/* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: nt(I) })
|
|
588
|
+
] })
|
|
589
|
+
] })
|
|
590
|
+
] }),
|
|
591
|
+
/* @__PURE__ */ s("div", { children: [
|
|
592
|
+
/* @__PURE__ */ s(
|
|
593
|
+
"div",
|
|
594
|
+
{
|
|
595
|
+
style: {
|
|
596
|
+
display: "flex",
|
|
597
|
+
justifyContent: "space-between",
|
|
598
|
+
alignItems: "center",
|
|
599
|
+
marginBottom: 12
|
|
600
|
+
},
|
|
601
|
+
children: [
|
|
602
|
+
/* @__PURE__ */ e(
|
|
603
|
+
Ce,
|
|
604
|
+
{
|
|
605
|
+
activeKey: a,
|
|
606
|
+
onChange: (c) => n(c),
|
|
607
|
+
items: [
|
|
608
|
+
{ key: "app", label: "应用 AK" },
|
|
609
|
+
{ key: "personal", label: "个人 AK" }
|
|
610
|
+
],
|
|
611
|
+
style: { flex: 1 }
|
|
612
|
+
}
|
|
613
|
+
),
|
|
614
|
+
/* @__PURE__ */ s("div", { style: { display: "flex", gap: 8 }, children: [
|
|
615
|
+
/* @__PURE__ */ e(z, { icon: /* @__PURE__ */ e(Ne, {}), onClick: j, size: "small", children: "刷新" }),
|
|
616
|
+
a === "personal" && /* @__PURE__ */ e(
|
|
617
|
+
z,
|
|
618
|
+
{
|
|
619
|
+
type: "primary",
|
|
620
|
+
icon: /* @__PURE__ */ e(ve, {}),
|
|
621
|
+
onClick: r,
|
|
622
|
+
loading: K,
|
|
623
|
+
children: "生成 AK"
|
|
624
|
+
}
|
|
625
|
+
)
|
|
626
|
+
] })
|
|
627
|
+
]
|
|
628
|
+
}
|
|
629
|
+
),
|
|
630
|
+
a === "app" ? ee(l, !0) : ee(o, !1)
|
|
631
|
+
] }),
|
|
632
|
+
/* @__PURE__ */ s(
|
|
633
|
+
ce,
|
|
634
|
+
{
|
|
635
|
+
open: C,
|
|
636
|
+
title: "生成新 AK",
|
|
637
|
+
onCancel: () => x(!1),
|
|
638
|
+
onOk: h,
|
|
639
|
+
okText: "确认生成",
|
|
640
|
+
cancelText: "取消",
|
|
641
|
+
confirmLoading: K,
|
|
642
|
+
children: [
|
|
643
|
+
/* @__PURE__ */ e(
|
|
644
|
+
"div",
|
|
645
|
+
{
|
|
646
|
+
style: {
|
|
647
|
+
marginBottom: 8,
|
|
648
|
+
color: "var(--text-secondary)",
|
|
649
|
+
fontSize: 13
|
|
650
|
+
},
|
|
651
|
+
children: "请输入 AK 名称(用于标识此密钥的用途)"
|
|
652
|
+
}
|
|
653
|
+
),
|
|
654
|
+
/* @__PURE__ */ e(
|
|
655
|
+
Se,
|
|
656
|
+
{
|
|
657
|
+
placeholder: "例如:测试用 AK、生产网关 AK",
|
|
658
|
+
value: T,
|
|
659
|
+
onChange: (c) => E(c.target.value),
|
|
660
|
+
onPressEnter: h,
|
|
661
|
+
maxLength: 50,
|
|
662
|
+
autoFocus: !0
|
|
663
|
+
}
|
|
664
|
+
)
|
|
665
|
+
]
|
|
666
|
+
}
|
|
667
|
+
),
|
|
668
|
+
/* @__PURE__ */ s(
|
|
669
|
+
ce,
|
|
670
|
+
{
|
|
671
|
+
open: f.open,
|
|
672
|
+
title: "AK 创建成功",
|
|
673
|
+
onCancel: () => p({ open: !1 }),
|
|
674
|
+
footer: [
|
|
675
|
+
/* @__PURE__ */ e(
|
|
676
|
+
z,
|
|
677
|
+
{
|
|
678
|
+
icon: /* @__PURE__ */ e(se, {}),
|
|
679
|
+
onClick: () => f.apiKey && A(f.apiKey),
|
|
680
|
+
children: "复制 AK"
|
|
681
|
+
},
|
|
682
|
+
"copy"
|
|
683
|
+
),
|
|
684
|
+
/* @__PURE__ */ e(
|
|
685
|
+
z,
|
|
686
|
+
{
|
|
687
|
+
type: "primary",
|
|
688
|
+
onClick: () => p({ open: !1 }),
|
|
689
|
+
children: "我已保存"
|
|
690
|
+
},
|
|
691
|
+
"close"
|
|
692
|
+
)
|
|
693
|
+
],
|
|
694
|
+
children: [
|
|
695
|
+
/* @__PURE__ */ e("div", { style: { marginBottom: 8, color: "#faad14", fontSize: 14 }, children: "请立即保存此 AK,关闭后将无法再次查看完整密钥。" }),
|
|
696
|
+
/* @__PURE__ */ e(
|
|
697
|
+
"div",
|
|
698
|
+
{
|
|
699
|
+
style: {
|
|
700
|
+
background: "var(--bg-tertiary, #f6f8fa)",
|
|
701
|
+
padding: "12px 14px",
|
|
702
|
+
borderRadius: 8,
|
|
703
|
+
fontFamily: "SF Mono, Fira Code, monospace",
|
|
704
|
+
fontSize: 13,
|
|
705
|
+
wordBreak: "break-all",
|
|
706
|
+
userSelect: "all"
|
|
707
|
+
},
|
|
708
|
+
children: f.apiKey
|
|
709
|
+
}
|
|
710
|
+
),
|
|
711
|
+
/* @__PURE__ */ s("div", { style: { marginTop: 8, fontSize: 12, color: "var(--text-muted)" }, children: [
|
|
712
|
+
"前缀: ",
|
|
713
|
+
f.akPrefix
|
|
714
|
+
] })
|
|
715
|
+
]
|
|
716
|
+
}
|
|
717
|
+
),
|
|
718
|
+
/* @__PURE__ */ e(
|
|
719
|
+
we,
|
|
720
|
+
{
|
|
721
|
+
title: y ? /* @__PURE__ */ s("span", { children: [
|
|
722
|
+
"AK 详情 — ",
|
|
723
|
+
/* @__PURE__ */ e("code", { children: y.akPrefix })
|
|
724
|
+
] }) : "AK 详情",
|
|
725
|
+
open: !!y,
|
|
726
|
+
onClose: W,
|
|
727
|
+
size: "large",
|
|
728
|
+
children: B ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载用量数据..." }) }) : _ ? /* @__PURE__ */ s("div", { className: t.usageDrawerContent, children: [
|
|
729
|
+
/* @__PURE__ */ s("div", { className: t.usageStatsGrid, children: [
|
|
730
|
+
/* @__PURE__ */ e($, { title: "总请求数", value: _.totalRequests }),
|
|
731
|
+
/* @__PURE__ */ e($, { title: "总 Token", value: _.totalTokens }),
|
|
732
|
+
/* @__PURE__ */ e(
|
|
733
|
+
$,
|
|
734
|
+
{
|
|
735
|
+
title: "输入 Token",
|
|
736
|
+
value: _.totalPromptTokens
|
|
737
|
+
}
|
|
738
|
+
),
|
|
739
|
+
/* @__PURE__ */ e(
|
|
740
|
+
$,
|
|
741
|
+
{
|
|
742
|
+
title: "输出 Token",
|
|
743
|
+
value: _.totalCompletionTokens
|
|
744
|
+
}
|
|
745
|
+
),
|
|
746
|
+
/* @__PURE__ */ e(
|
|
747
|
+
$,
|
|
748
|
+
{
|
|
749
|
+
title: "平均耗时",
|
|
750
|
+
value: _.avgLatencyMs,
|
|
751
|
+
suffix: "ms"
|
|
752
|
+
}
|
|
753
|
+
),
|
|
754
|
+
/* @__PURE__ */ e(
|
|
755
|
+
$,
|
|
756
|
+
{
|
|
757
|
+
title: "错误数",
|
|
758
|
+
value: _.errorCount,
|
|
759
|
+
styles: {
|
|
760
|
+
content: {
|
|
761
|
+
color: _.errorCount > 0 ? "#ff4d4f" : void 0
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
)
|
|
766
|
+
] }),
|
|
767
|
+
/* @__PURE__ */ s("div", { className: t.usageSection, children: [
|
|
768
|
+
/* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "每日调用曲线(近 30 天)" }),
|
|
769
|
+
oe(_.daily)
|
|
770
|
+
] }),
|
|
771
|
+
/* @__PURE__ */ s("div", { className: t.usageSection, children: [
|
|
772
|
+
/* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "模型用量分布" }),
|
|
773
|
+
R(_.models)
|
|
774
|
+
] }),
|
|
775
|
+
/* @__PURE__ */ s("div", { className: t.usageSection, children: [
|
|
776
|
+
/* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "最近调用记录" }),
|
|
777
|
+
/* @__PURE__ */ e(
|
|
778
|
+
Ae,
|
|
779
|
+
{
|
|
780
|
+
columns: q,
|
|
781
|
+
dataSource: _.recent,
|
|
782
|
+
rowKey: "id",
|
|
783
|
+
size: "small",
|
|
784
|
+
pagination: {
|
|
785
|
+
pageSize: 10,
|
|
786
|
+
size: "small",
|
|
787
|
+
showSizeChanger: !0,
|
|
788
|
+
pageSizeOptions: ["10", "20", "50", "100"],
|
|
789
|
+
showTotal: (c) => `共 ${c} 条`
|
|
790
|
+
},
|
|
791
|
+
scroll: { x: 760 }
|
|
792
|
+
}
|
|
793
|
+
)
|
|
794
|
+
] })
|
|
795
|
+
] }) : /* @__PURE__ */ e("div", { className: t.usageEmpty, children: "暂无用量数据" })
|
|
796
|
+
}
|
|
797
|
+
)
|
|
798
|
+
] });
|
|
799
|
+
}
|
|
800
|
+
function rt(a) {
|
|
801
|
+
const n = [];
|
|
802
|
+
if (!a) return n;
|
|
803
|
+
const l = /<(think|thinking|reasoning)>([\s\S]*?)<\/\1>/gi;
|
|
804
|
+
let i = 0, o;
|
|
805
|
+
for (; (o = l.exec(a)) !== null; )
|
|
806
|
+
o.index > i && n.push({ type: "text", text: a.slice(i, o.index) }), n.push({ type: "think", text: o[2] }), i = o.index + o[0].length;
|
|
807
|
+
return i < a.length && n.push({ type: "text", text: a.slice(i) }), n;
|
|
808
|
+
}
|
|
809
|
+
const re = 4;
|
|
810
|
+
let lt = 0;
|
|
811
|
+
function it({ initialModels: a }) {
|
|
812
|
+
const [n, l] = N([]), [i, o] = N([]), [v, d] = N(!0), [k, K] = N(null), [S, C] = N(""), [x, T] = N(!1), E = de(""), f = de(/* @__PURE__ */ new Map()), p = de(/* @__PURE__ */ new Map());
|
|
813
|
+
ae(() => {
|
|
814
|
+
(async () => {
|
|
815
|
+
try {
|
|
816
|
+
const r = await Me();
|
|
817
|
+
o(r), d(!1);
|
|
818
|
+
const h = a.length > 0 ? a : r.slice(0, 1).map((w) => w.modelName);
|
|
819
|
+
l(h.slice(0, re).map((w) => me(w)));
|
|
820
|
+
} catch (r) {
|
|
821
|
+
d(!1), K(r instanceof Error ? r.message : "模型列表加载失败");
|
|
822
|
+
}
|
|
823
|
+
})();
|
|
824
|
+
}, []), ae(() => {
|
|
825
|
+
if (a.length > 0 && i.length > 0) {
|
|
826
|
+
const r = a.slice(0, re).map((h) => me(h));
|
|
827
|
+
l(r);
|
|
828
|
+
}
|
|
829
|
+
}, [a.join(",")]);
|
|
830
|
+
const y = H((r) => {
|
|
831
|
+
const h = p.current.get(r);
|
|
832
|
+
h && (h.scrollTop = h.scrollHeight);
|
|
833
|
+
}, []), u = H(
|
|
834
|
+
(r, h) => {
|
|
835
|
+
l((w) => w.map((A) => A.id === r ? h(A) : A));
|
|
836
|
+
},
|
|
837
|
+
[]
|
|
838
|
+
), _ = H(async () => {
|
|
839
|
+
if (E.current) return E.current;
|
|
840
|
+
const r = await tt();
|
|
841
|
+
return E.current = r, r;
|
|
842
|
+
}, []), m = H(async () => {
|
|
843
|
+
const r = S.trim();
|
|
844
|
+
if (!r || x) return;
|
|
845
|
+
let h;
|
|
846
|
+
try {
|
|
847
|
+
h = await _();
|
|
848
|
+
} catch {
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
C(""), T(!0);
|
|
852
|
+
const w = n.map((O) => ({
|
|
853
|
+
...O,
|
|
854
|
+
messages: [
|
|
855
|
+
...O.messages,
|
|
856
|
+
{ role: "user", content: r },
|
|
857
|
+
{ role: "assistant", content: "" }
|
|
858
|
+
],
|
|
859
|
+
streamingContent: "",
|
|
860
|
+
isStreaming: !0,
|
|
861
|
+
error: null,
|
|
862
|
+
usage: null
|
|
863
|
+
}));
|
|
864
|
+
l(w);
|
|
865
|
+
const A = w;
|
|
866
|
+
A.forEach((O) => {
|
|
867
|
+
const W = new AbortController();
|
|
868
|
+
f.current.set(O.id, W);
|
|
869
|
+
const oe = O.messages.slice(0, -1);
|
|
870
|
+
Ye(h, O.model, oe, {
|
|
871
|
+
onDelta: (R) => {
|
|
872
|
+
u(O.id, (q) => ({
|
|
873
|
+
...q,
|
|
874
|
+
streamingContent: q.streamingContent + R,
|
|
875
|
+
messages: q.messages.map(
|
|
876
|
+
(ee, c) => c === q.messages.length - 1 ? { ...ee, content: q.streamingContent + R } : ee
|
|
877
|
+
)
|
|
878
|
+
})), y(O.id);
|
|
879
|
+
},
|
|
880
|
+
onDone: (R) => {
|
|
881
|
+
u(O.id, (q) => ({
|
|
882
|
+
...q,
|
|
883
|
+
isStreaming: !1,
|
|
884
|
+
usage: R ? {
|
|
885
|
+
promptTokens: R.promptTokens,
|
|
886
|
+
completionTokens: R.completionTokens,
|
|
887
|
+
totalTokens: R.totalTokens
|
|
888
|
+
} : null
|
|
889
|
+
})), f.current.delete(O.id);
|
|
890
|
+
},
|
|
891
|
+
onError: (R) => {
|
|
892
|
+
(R.message.includes("401") || R.message.includes("API key")) && (Ee(), E.current = ""), u(O.id, (q) => ({
|
|
893
|
+
...q,
|
|
894
|
+
isStreaming: !1,
|
|
895
|
+
error: R.message
|
|
896
|
+
})), f.current.delete(O.id);
|
|
897
|
+
},
|
|
898
|
+
signal: W.signal
|
|
899
|
+
}).catch(() => {
|
|
900
|
+
});
|
|
901
|
+
});
|
|
902
|
+
const J = setInterval(() => {
|
|
903
|
+
A.every(
|
|
904
|
+
(W) => !f.current.has(W.id)
|
|
905
|
+
) && (clearInterval(J), T(!1));
|
|
906
|
+
}, 200);
|
|
907
|
+
setTimeout(() => {
|
|
908
|
+
clearInterval(J), T(!1);
|
|
909
|
+
}, 300 * 1e3);
|
|
910
|
+
}, [S, x, n, _, u, y]), B = H(() => {
|
|
911
|
+
f.current.forEach((r) => r.abort()), f.current.clear(), l((r) => r.map((h) => ({ ...h, isStreaming: !1 }))), T(!1);
|
|
912
|
+
}, []), b = H(() => {
|
|
913
|
+
var h;
|
|
914
|
+
if (n.length >= re) return;
|
|
915
|
+
const r = (h = i.find((w) => !n.some((A) => A.model === w.modelName))) == null ? void 0 : h.modelName;
|
|
916
|
+
r && l((w) => [...w, me(r)]);
|
|
917
|
+
}, [n, i]), L = H(() => {
|
|
918
|
+
f.current.forEach((r) => r.abort()), f.current.clear(), l(
|
|
919
|
+
(r) => r.map((h) => ({
|
|
920
|
+
...h,
|
|
921
|
+
messages: [],
|
|
922
|
+
streamingContent: "",
|
|
923
|
+
isStreaming: !1,
|
|
924
|
+
error: null,
|
|
925
|
+
usage: null
|
|
926
|
+
}))
|
|
927
|
+
), T(!1);
|
|
928
|
+
}, [x, n]), P = H((r) => {
|
|
929
|
+
const h = f.current.get(r);
|
|
930
|
+
h && h.abort(), f.current.delete(r), l((w) => w.filter((A) => A.id !== r));
|
|
931
|
+
}, []), I = H(
|
|
932
|
+
(r, h) => {
|
|
933
|
+
u(r, (w) => ({ ...w, model: h }));
|
|
934
|
+
},
|
|
935
|
+
[u]
|
|
936
|
+
), j = i.map((r) => ({
|
|
937
|
+
label: r.modelName,
|
|
938
|
+
value: r.modelName
|
|
939
|
+
}));
|
|
940
|
+
return v ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载模型列表..." }) }) : k ? /* @__PURE__ */ s("div", { className: t.chatContainer, children: [
|
|
941
|
+
/* @__PURE__ */ e("div", { className: t.chatHeader, children: /* @__PURE__ */ e("h3", { className: t.chatTitle, children: "模型对话" }) }),
|
|
942
|
+
/* @__PURE__ */ s("div", { className: t.akEmpty, children: [
|
|
943
|
+
"模型列表加载失败:",
|
|
944
|
+
k
|
|
945
|
+
] })
|
|
946
|
+
] }) : /* @__PURE__ */ s("div", { className: t.chatContainer, children: [
|
|
947
|
+
/* @__PURE__ */ s("div", { className: t.chatHeader, children: [
|
|
948
|
+
/* @__PURE__ */ s("h3", { className: t.chatTitle, children: [
|
|
949
|
+
"模型对话",
|
|
950
|
+
n.length > 1 && /* @__PURE__ */ s(G, { color: "blue", style: { marginLeft: 12, fontSize: 12 }, children: [
|
|
951
|
+
n.length,
|
|
952
|
+
" 个模型对比"
|
|
953
|
+
] })
|
|
954
|
+
] }),
|
|
955
|
+
/* @__PURE__ */ e(
|
|
956
|
+
z,
|
|
957
|
+
{
|
|
958
|
+
size: "small",
|
|
959
|
+
icon: /* @__PURE__ */ e(Ie, {}),
|
|
960
|
+
onClick: L,
|
|
961
|
+
disabled: x || n.every((r) => r.messages.length === 0),
|
|
962
|
+
children: "清空重新来"
|
|
963
|
+
}
|
|
964
|
+
)
|
|
965
|
+
] }),
|
|
966
|
+
/* @__PURE__ */ s("div", { className: t.chatPanels, children: [
|
|
967
|
+
n.map((r) => /* @__PURE__ */ s("div", { className: t.chatPanel, children: [
|
|
968
|
+
/* @__PURE__ */ s("div", { className: t.chatPanelHeader, children: [
|
|
969
|
+
/* @__PURE__ */ e(
|
|
970
|
+
Ue,
|
|
971
|
+
{
|
|
972
|
+
size: "small",
|
|
973
|
+
value: r.model,
|
|
974
|
+
onChange: (h) => I(r.id, h),
|
|
975
|
+
options: j,
|
|
976
|
+
style: { minWidth: 140, flex: 1 },
|
|
977
|
+
showSearch: !0,
|
|
978
|
+
optionFilterProp: "label"
|
|
979
|
+
}
|
|
980
|
+
),
|
|
981
|
+
n.length > 1 && /* @__PURE__ */ e(
|
|
982
|
+
"span",
|
|
983
|
+
{
|
|
984
|
+
className: t.chatPanelClose,
|
|
985
|
+
onClick: () => P(r.id),
|
|
986
|
+
children: /* @__PURE__ */ e(Be, {})
|
|
987
|
+
}
|
|
988
|
+
)
|
|
989
|
+
] }),
|
|
990
|
+
/* @__PURE__ */ s(
|
|
991
|
+
"div",
|
|
992
|
+
{
|
|
993
|
+
className: t.chatPanelBody,
|
|
994
|
+
ref: (h) => {
|
|
995
|
+
p.current.set(r.id, h);
|
|
996
|
+
},
|
|
997
|
+
children: [
|
|
998
|
+
r.messages.map((h, w) => /* @__PURE__ */ s(
|
|
999
|
+
"div",
|
|
1000
|
+
{
|
|
1001
|
+
className: h.role === "user" ? t.chatMsgUser : t.chatMsgAI,
|
|
1002
|
+
children: [
|
|
1003
|
+
h.role === "assistant" ? rt(h.content).map(
|
|
1004
|
+
(A, J) => A.type === "think" ? /* @__PURE__ */ s(
|
|
1005
|
+
"details",
|
|
1006
|
+
{
|
|
1007
|
+
className: t.chatThinkBlock,
|
|
1008
|
+
children: [
|
|
1009
|
+
/* @__PURE__ */ e("summary", { children: "思考过程" }),
|
|
1010
|
+
/* @__PURE__ */ e("pre", { children: A.text })
|
|
1011
|
+
]
|
|
1012
|
+
},
|
|
1013
|
+
J
|
|
1014
|
+
) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: A.text }, J)
|
|
1015
|
+
) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: h.content }),
|
|
1016
|
+
r.isStreaming && w === r.messages.length - 1 && h.role === "assistant" && /* @__PURE__ */ e("span", { className: t.chatStreamingCursor })
|
|
1017
|
+
]
|
|
1018
|
+
},
|
|
1019
|
+
w
|
|
1020
|
+
)),
|
|
1021
|
+
r.error && /* @__PURE__ */ e("div", { className: t.chatMsgError, children: r.error }),
|
|
1022
|
+
r.usage && /* @__PURE__ */ s("div", { className: t.chatUsageBar, children: [
|
|
1023
|
+
/* @__PURE__ */ s("span", { children: [
|
|
1024
|
+
"输入: ",
|
|
1025
|
+
r.usage.promptTokens
|
|
1026
|
+
] }),
|
|
1027
|
+
/* @__PURE__ */ s("span", { children: [
|
|
1028
|
+
"输出: ",
|
|
1029
|
+
r.usage.completionTokens
|
|
1030
|
+
] })
|
|
1031
|
+
] })
|
|
1032
|
+
]
|
|
1033
|
+
}
|
|
1034
|
+
)
|
|
1035
|
+
] }, r.id)),
|
|
1036
|
+
n.length < re && /* @__PURE__ */ e(Q, { title: "添加面板", children: /* @__PURE__ */ e("div", { className: t.addPanelBtn, onClick: b, children: /* @__PURE__ */ e(ve, {}) }) })
|
|
1037
|
+
] }),
|
|
1038
|
+
/* @__PURE__ */ s("div", { className: t.chatInputBar, children: [
|
|
1039
|
+
/* @__PURE__ */ e(
|
|
1040
|
+
Se.TextArea,
|
|
1041
|
+
{
|
|
1042
|
+
className: t.chatInput,
|
|
1043
|
+
value: S,
|
|
1044
|
+
onChange: (r) => C(r.target.value),
|
|
1045
|
+
placeholder: "输入消息,所有面板将同时收到并流式输出...",
|
|
1046
|
+
autoSize: { minRows: 1, maxRows: 4 },
|
|
1047
|
+
onPressEnter: (r) => {
|
|
1048
|
+
r.shiftKey || (r.preventDefault(), m());
|
|
1049
|
+
},
|
|
1050
|
+
disabled: x
|
|
1051
|
+
}
|
|
1052
|
+
),
|
|
1053
|
+
x ? /* @__PURE__ */ e(z, { danger: !0, onClick: B, children: "停止" }) : /* @__PURE__ */ s(z, { type: "primary", onClick: m, disabled: !S.trim(), children: [
|
|
1054
|
+
/* @__PURE__ */ e($e, {}),
|
|
1055
|
+
" 发送"
|
|
1056
|
+
] })
|
|
1057
|
+
] })
|
|
1058
|
+
] });
|
|
1059
|
+
}
|
|
1060
|
+
function me(a) {
|
|
1061
|
+
return {
|
|
1062
|
+
id: ++lt,
|
|
1063
|
+
model: a,
|
|
1064
|
+
messages: [],
|
|
1065
|
+
streamingContent: "",
|
|
1066
|
+
isStreaming: !1,
|
|
1067
|
+
error: null,
|
|
1068
|
+
usage: null
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
function ot({ onStartChat: a }) {
|
|
1072
|
+
const [n, l] = N([]), [i, o] = N(!0), [v, d] = N(null), [k, K] = N(/* @__PURE__ */ new Set()), S = () => {
|
|
1073
|
+
o(!0), d(null), Me().then((p) => {
|
|
1074
|
+
l(p), o(!1);
|
|
1075
|
+
}).catch((p) => {
|
|
1076
|
+
l([]), d(p instanceof Error ? p.message : "加载失败"), o(!1);
|
|
1077
|
+
});
|
|
1078
|
+
};
|
|
1079
|
+
ae(() => {
|
|
1080
|
+
S();
|
|
1081
|
+
}, []);
|
|
1082
|
+
const C = (p) => {
|
|
1083
|
+
K((y) => {
|
|
1084
|
+
const u = new Set(y);
|
|
1085
|
+
return u.has(p) ? u.delete(p) : u.add(p), u;
|
|
1086
|
+
});
|
|
1087
|
+
}, x = Array.from(k), T = (p) => {
|
|
1088
|
+
a([p]);
|
|
1089
|
+
}, E = () => {
|
|
1090
|
+
x.length > 0 && a(x);
|
|
1091
|
+
}, f = (p) => {
|
|
1092
|
+
if (!p) return "default";
|
|
1093
|
+
const y = p.toLowerCase();
|
|
1094
|
+
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";
|
|
1095
|
+
};
|
|
1096
|
+
return i ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载模型列表..." }) }) : v ? /* @__PURE__ */ s("div", { children: [
|
|
1097
|
+
/* @__PURE__ */ s("div", { className: t.modelMgmtHeader, children: [
|
|
1098
|
+
/* @__PURE__ */ e("h3", { className: t.modelMgmtTitle, children: "模型管理" }),
|
|
1099
|
+
/* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "数据库管理的可用模型,可选择单个或多个模型发起对话对比" })
|
|
1100
|
+
] }),
|
|
1101
|
+
/* @__PURE__ */ s("div", { className: t.akEmpty, children: [
|
|
1102
|
+
"模型列表加载失败:",
|
|
1103
|
+
v,
|
|
1104
|
+
/* @__PURE__ */ e("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ e(z, { type: "primary", onClick: S, children: "重试" }) })
|
|
1105
|
+
] })
|
|
1106
|
+
] }) : /* @__PURE__ */ s("div", { children: [
|
|
1107
|
+
/* @__PURE__ */ s("div", { className: t.modelMgmtHeader, children: [
|
|
1108
|
+
/* @__PURE__ */ e("h3", { className: t.modelMgmtTitle, children: "模型管理" }),
|
|
1109
|
+
/* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "数据库管理的可用模型,可选择单个或多个模型发起对话对比" })
|
|
1110
|
+
] }),
|
|
1111
|
+
n.length === 0 && /* @__PURE__ */ e("div", { className: t.akEmpty, children: "后端暂无启用模型(z_team_model_config 中 enable=1 的行),请先在数据库或网关配置中启用" }),
|
|
1112
|
+
/* @__PURE__ */ e("div", { className: t.modelGrid, children: n.map((p) => {
|
|
1113
|
+
const y = k.has(p.modelName);
|
|
1114
|
+
return /* @__PURE__ */ s(
|
|
1115
|
+
"div",
|
|
1116
|
+
{
|
|
1117
|
+
className: `${t.modelCard} ${y ? t.modelCardSelected : ""}`,
|
|
1118
|
+
onClick: () => C(p.modelName),
|
|
1119
|
+
children: [
|
|
1120
|
+
/* @__PURE__ */ e(
|
|
1121
|
+
He,
|
|
1122
|
+
{
|
|
1123
|
+
className: t.modelCheckbox,
|
|
1124
|
+
checked: y,
|
|
1125
|
+
onChange: (u) => {
|
|
1126
|
+
u.stopPropagation(), C(p.modelName);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
),
|
|
1130
|
+
/* @__PURE__ */ s("div", { className: t.modelCardHeader, children: [
|
|
1131
|
+
/* @__PURE__ */ e("div", { className: t.modelIconWrap, children: /* @__PURE__ */ e(Te, {}) }),
|
|
1132
|
+
/* @__PURE__ */ s("div", { className: t.modelCardInfo, children: [
|
|
1133
|
+
/* @__PURE__ */ e("h4", { className: t.modelName, children: p.modelName }),
|
|
1134
|
+
/* @__PURE__ */ s("div", { className: t.modelTags, children: [
|
|
1135
|
+
p.modelProvider && /* @__PURE__ */ e(
|
|
1136
|
+
G,
|
|
1137
|
+
{
|
|
1138
|
+
color: f(p.modelProvider),
|
|
1139
|
+
style: { fontSize: 11, margin: 0 },
|
|
1140
|
+
children: p.modelProvider
|
|
1141
|
+
}
|
|
1142
|
+
),
|
|
1143
|
+
/* @__PURE__ */ e(G, { style: { fontSize: 11, margin: 0 }, children: p.apiType })
|
|
1144
|
+
] })
|
|
1145
|
+
] })
|
|
1146
|
+
] }),
|
|
1147
|
+
/* @__PURE__ */ e("p", { className: t.modelEndpoint, children: p.endpoint }),
|
|
1148
|
+
/* @__PURE__ */ e("div", { className: t.modelCardFooter, children: /* @__PURE__ */ e(
|
|
1149
|
+
z,
|
|
1150
|
+
{
|
|
1151
|
+
type: "link",
|
|
1152
|
+
size: "small",
|
|
1153
|
+
onClick: (u) => {
|
|
1154
|
+
u.stopPropagation(), T(p.modelName);
|
|
1155
|
+
},
|
|
1156
|
+
children: "发起对话"
|
|
1157
|
+
}
|
|
1158
|
+
) })
|
|
1159
|
+
]
|
|
1160
|
+
},
|
|
1161
|
+
p.modelName
|
|
1162
|
+
);
|
|
1163
|
+
}) }),
|
|
1164
|
+
x.length > 0 && /* @__PURE__ */ s("div", { className: t.modelActionBar, children: [
|
|
1165
|
+
/* @__PURE__ */ s("span", { className: t.modelSelectionCount, children: [
|
|
1166
|
+
"已选择 ",
|
|
1167
|
+
x.length,
|
|
1168
|
+
" 个模型"
|
|
1169
|
+
] }),
|
|
1170
|
+
/* @__PURE__ */ e(
|
|
1171
|
+
z,
|
|
1172
|
+
{
|
|
1173
|
+
type: "primary",
|
|
1174
|
+
onClick: E,
|
|
1175
|
+
disabled: x.length === 0,
|
|
1176
|
+
children: "批量对比"
|
|
1177
|
+
}
|
|
1178
|
+
)
|
|
1179
|
+
] })
|
|
1180
|
+
] });
|
|
1181
|
+
}
|
|
1182
|
+
const ct = "_container_15pgq_5", dt = "_page_15pgq_10", mt = "_kpiGrid_15pgq_16", ut = "_kpiCard_15pgq_22", ht = "_sectionCard_15pgq_29", pt = "_sectionHead_15pgq_36", gt = "_sectionHint_15pgq_42", kt = "_akList_15pgq_47", ft = "_errorState_15pgq_54", yt = "_errorTitle_15pgq_66", Nt = "_errorDetail_15pgq_72", D = {
|
|
1183
|
+
container: ct,
|
|
1184
|
+
page: dt,
|
|
1185
|
+
kpiGrid: mt,
|
|
1186
|
+
kpiCard: ut,
|
|
1187
|
+
sectionCard: ht,
|
|
1188
|
+
sectionHead: pt,
|
|
1189
|
+
sectionHint: gt,
|
|
1190
|
+
akList: kt,
|
|
1191
|
+
errorState: ft,
|
|
1192
|
+
errorTitle: yt,
|
|
1193
|
+
errorDetail: Nt
|
|
1194
|
+
}, vt = Fe(
|
|
1195
|
+
() => import("@yuku123/z-agent-component").then((a) => ({ default: a.AgentDashboard }))
|
|
1196
|
+
), Tt = ["zifang", "system-default"];
|
|
1197
|
+
function te(a) {
|
|
1198
|
+
return a >= 1e6 ? `${(a / 1e6).toFixed(2)}M` : a >= 1e3 ? `${(a / 1e3).toFixed(1)}K` : String(a ?? 0);
|
|
1199
|
+
}
|
|
1200
|
+
function Ct({ daily: a }) {
|
|
1201
|
+
const n = Object.entries(a);
|
|
1202
|
+
if (n.length === 0) return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
|
|
1203
|
+
const l = Math.max(...n.map(([, i]) => i[1] + i[2]), 1);
|
|
1204
|
+
return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: n.map(([i, o]) => {
|
|
1205
|
+
const v = o[1] + o[2];
|
|
1206
|
+
return /* @__PURE__ */ s("div", { className: t.usageBarCol, children: [
|
|
1207
|
+
/* @__PURE__ */ e(Q, { title: `${i}: ${o[0]}次 / ${v} tokens`, children: /* @__PURE__ */ e(
|
|
1208
|
+
"div",
|
|
1209
|
+
{
|
|
1210
|
+
className: t.usageBar,
|
|
1211
|
+
style: { height: `${Math.max(v / l * 100, 2)}%` }
|
|
1212
|
+
}
|
|
1213
|
+
) }),
|
|
1214
|
+
/* @__PURE__ */ e("span", { className: t.usageBarLabel, children: i })
|
|
1215
|
+
] }, i);
|
|
1216
|
+
}) });
|
|
1217
|
+
}
|
|
1218
|
+
function ye({ models: a }) {
|
|
1219
|
+
const n = Object.entries(a);
|
|
1220
|
+
if (n.length === 0) return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
|
|
1221
|
+
const l = Math.max(...n.map(([, i]) => i[0]), 1);
|
|
1222
|
+
return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: n.sort((i, o) => o[1][0] - i[1][0]).map(([i, o]) => /* @__PURE__ */ s("div", { className: t.modelBreakdownRow, children: [
|
|
1223
|
+
/* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: i }),
|
|
1224
|
+
/* @__PURE__ */ e("div", { className: t.modelBreakdownBar, children: /* @__PURE__ */ e(
|
|
1225
|
+
"div",
|
|
1226
|
+
{
|
|
1227
|
+
className: t.modelBreakdownFill,
|
|
1228
|
+
style: { width: `${o[0] / l * 100}%` }
|
|
1229
|
+
}
|
|
1230
|
+
) }),
|
|
1231
|
+
/* @__PURE__ */ s("span", { className: t.modelBreakdownCount, children: [
|
|
1232
|
+
o[0],
|
|
1233
|
+
"次 / ",
|
|
1234
|
+
te(o[1]),
|
|
1235
|
+
"tokens"
|
|
1236
|
+
] })
|
|
1237
|
+
] }, i)) });
|
|
1238
|
+
}
|
|
1239
|
+
const St = [
|
|
1240
|
+
{
|
|
1241
|
+
title: "时间",
|
|
1242
|
+
dataIndex: "createTime",
|
|
1243
|
+
key: "createTime",
|
|
1244
|
+
width: 160,
|
|
1245
|
+
render: (a) => a ? new Date(a).toLocaleString("zh-CN") : "-"
|
|
1246
|
+
},
|
|
1247
|
+
{ title: "模型", dataIndex: "model", key: "model", width: 150 },
|
|
1248
|
+
{ title: "协议", dataIndex: "protocol", key: "protocol", width: 90, render: (a) => /* @__PURE__ */ e(G, { children: a }) },
|
|
1249
|
+
{ title: "输入", dataIndex: "promptTokens", key: "promptTokens", width: 70 },
|
|
1250
|
+
{ title: "输出", dataIndex: "completionTokens", key: "completionTokens", width: 70 },
|
|
1251
|
+
{ title: "总Token", dataIndex: "totalTokens", key: "totalTokens", width: 80 },
|
|
1252
|
+
{ title: "耗时", dataIndex: "latencyMs", key: "latencyMs", width: 70, render: (a) => a ? `${a}ms` : "-" },
|
|
1253
|
+
{
|
|
1254
|
+
title: "状态",
|
|
1255
|
+
dataIndex: "statusCode",
|
|
1256
|
+
key: "statusCode",
|
|
1257
|
+
width: 60,
|
|
1258
|
+
render: (a) => a ? /* @__PURE__ */ e(G, { color: a < 400 ? "green" : "red", children: a }) : "-"
|
|
1259
|
+
}
|
|
1260
|
+
];
|
|
1261
|
+
function wt(a) {
|
|
1262
|
+
var n;
|
|
1263
|
+
return ((n = a == null ? void 0 : a.stats) == null ? void 0 : n.recent) ?? [];
|
|
1264
|
+
}
|
|
1265
|
+
function At() {
|
|
1266
|
+
var T, E, f, p, y, u, _;
|
|
1267
|
+
const [a, n] = N(!0), [l, i] = N(null), [o, v] = N([]), [d, k] = N(null), K = H(async () => {
|
|
1268
|
+
n(!0), i(null);
|
|
1269
|
+
try {
|
|
1270
|
+
const m = await Promise.allSettled(
|
|
1271
|
+
Tt.map((P) => ie(P))
|
|
1272
|
+
), B = [];
|
|
1273
|
+
let b = 0;
|
|
1274
|
+
for (const P of m)
|
|
1275
|
+
P.status === "fulfilled" ? B.push(...P.value) : b += 1;
|
|
1276
|
+
if (b === m.length)
|
|
1277
|
+
throw new Error("网关不可达:无法获取 AK 列表");
|
|
1278
|
+
B.sort((P, I) => (P.id ?? 0) - (I.id ?? 0));
|
|
1279
|
+
const L = await Promise.all(
|
|
1280
|
+
B.map(async (P) => {
|
|
1281
|
+
try {
|
|
1282
|
+
return { key: P, stats: await Ke(P.id), statsError: null };
|
|
1283
|
+
} catch (I) {
|
|
1284
|
+
return {
|
|
1285
|
+
key: P,
|
|
1286
|
+
stats: null,
|
|
1287
|
+
statsError: I instanceof Error ? I.message : "获取用量失败"
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
})
|
|
1291
|
+
);
|
|
1292
|
+
v(L);
|
|
1293
|
+
} catch (m) {
|
|
1294
|
+
i(m instanceof Error ? m.message : "加载失败");
|
|
1295
|
+
} finally {
|
|
1296
|
+
n(!1);
|
|
1297
|
+
}
|
|
1298
|
+
}, []);
|
|
1299
|
+
ae(() => {
|
|
1300
|
+
K();
|
|
1301
|
+
}, [K]);
|
|
1302
|
+
const S = xe(() => {
|
|
1303
|
+
let m = 0, B = 0, b = 0, L = 0, P = 0;
|
|
1304
|
+
const I = {};
|
|
1305
|
+
for (const j of o) {
|
|
1306
|
+
const r = j.stats;
|
|
1307
|
+
if (r) {
|
|
1308
|
+
m += r.totalRequests ?? 0, B += r.totalTokens ?? 0, r.avgLatencyMs != null && r.totalRequests > 0 && (b += r.avgLatencyMs * r.totalRequests, L += r.totalRequests), P += r.errorCount ?? 0;
|
|
1309
|
+
for (const [h, w] of Object.entries(r.models ?? {})) {
|
|
1310
|
+
const A = I[h] ?? [0, 0];
|
|
1311
|
+
A[0] += w[0], A[1] += w[1], I[h] = A;
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
return {
|
|
1316
|
+
requests: m,
|
|
1317
|
+
tokens: B,
|
|
1318
|
+
avgLatency: L > 0 ? Math.round(b / L) : 0,
|
|
1319
|
+
errors: P,
|
|
1320
|
+
models: I
|
|
1321
|
+
};
|
|
1322
|
+
}, [o]), C = o.reduce((m, B) => m + (B.key.tokenQuota || 0), 0), x = () => a ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载监控数据..." }) }) : l ? /* @__PURE__ */ s("div", { className: D.errorState, children: [
|
|
1323
|
+
/* @__PURE__ */ e("div", { className: D.errorTitle, children: "模型监控数据加载失败" }),
|
|
1324
|
+
/* @__PURE__ */ e("div", { className: D.errorDetail, children: l }),
|
|
1325
|
+
/* @__PURE__ */ e(z, { icon: /* @__PURE__ */ e(Ne, {}), onClick: K, type: "primary", children: "重试" })
|
|
1326
|
+
] }) : /* @__PURE__ */ s("div", { className: D.page, children: [
|
|
1327
|
+
/* @__PURE__ */ s("div", { className: D.kpiGrid, children: [
|
|
1328
|
+
/* @__PURE__ */ e("div", { className: D.kpiCard, children: /* @__PURE__ */ e($, { title: "总请求(近30天)", value: S.requests }) }),
|
|
1329
|
+
/* @__PURE__ */ e("div", { className: D.kpiCard, children: /* @__PURE__ */ e($, { title: "总 Tokens", value: te(S.tokens) }) }),
|
|
1330
|
+
/* @__PURE__ */ e("div", { className: D.kpiCard, children: /* @__PURE__ */ e($, { title: "平均延迟", value: S.avgLatency, suffix: "ms" }) }),
|
|
1331
|
+
/* @__PURE__ */ e("div", { className: D.kpiCard, children: /* @__PURE__ */ e(
|
|
1332
|
+
$,
|
|
1333
|
+
{
|
|
1334
|
+
title: "错误数",
|
|
1335
|
+
value: S.errors,
|
|
1336
|
+
valueStyle: S.errors > 0 ? { color: "#ff4d4f" } : void 0
|
|
1337
|
+
}
|
|
1338
|
+
) })
|
|
1339
|
+
] }),
|
|
1340
|
+
/* @__PURE__ */ s("div", { className: D.sectionCard, children: [
|
|
1341
|
+
/* @__PURE__ */ s("div", { className: D.sectionHead, children: [
|
|
1342
|
+
/* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "AK 用量" }),
|
|
1343
|
+
C > 0 && /* @__PURE__ */ s("span", { className: D.sectionHint, children: [
|
|
1344
|
+
"合计额度 ",
|
|
1345
|
+
te(C),
|
|
1346
|
+
" tokens"
|
|
1347
|
+
] })
|
|
1348
|
+
] }),
|
|
1349
|
+
o.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: "网关下暂无 AK" }) : /* @__PURE__ */ e("div", { className: D.akList, children: o.map((m) => {
|
|
1350
|
+
const B = m.key.totalTokens ?? 0, b = m.key.tokenQuota || 0, L = b > 0 ? Math.min(B / b * 100, 100) : 0;
|
|
1351
|
+
return /* @__PURE__ */ s(
|
|
1352
|
+
"div",
|
|
1353
|
+
{
|
|
1354
|
+
className: t.akCard,
|
|
1355
|
+
onClick: () => k(m),
|
|
1356
|
+
children: [
|
|
1357
|
+
/* @__PURE__ */ s("div", { className: t.akCardRow, children: [
|
|
1358
|
+
/* @__PURE__ */ e("span", { className: t.akTitle, children: m.key.description || m.key.userName || `AK #${m.key.id}` }),
|
|
1359
|
+
/* @__PURE__ */ e("span", { className: t.akPrefixSmall, children: m.key.akPrefix }),
|
|
1360
|
+
/* @__PURE__ */ e(
|
|
1361
|
+
"span",
|
|
1362
|
+
{
|
|
1363
|
+
className: `${t.akStatus} ${m.key.active ? t.akStatusActive : t.akStatusRevoked}`,
|
|
1364
|
+
children: m.key.active ? "启用" : "吊销"
|
|
1365
|
+
}
|
|
1366
|
+
),
|
|
1367
|
+
/* @__PURE__ */ e("span", { className: t.akMetaText, children: m.key.userId === "system-default" ? "系统对话" : m.key.userId })
|
|
1368
|
+
] }),
|
|
1369
|
+
/* @__PURE__ */ s("div", { className: t.akCardRow2, children: [
|
|
1370
|
+
/* @__PURE__ */ e("div", { className: t.akMiniBar, children: /* @__PURE__ */ e(
|
|
1371
|
+
"div",
|
|
1372
|
+
{
|
|
1373
|
+
className: t.akMiniBarFill,
|
|
1374
|
+
style: { width: `${L}%` }
|
|
1375
|
+
}
|
|
1376
|
+
) }),
|
|
1377
|
+
/* @__PURE__ */ s("span", { className: t.akUsageText, children: [
|
|
1378
|
+
te(B),
|
|
1379
|
+
b > 0 ? ` / ${te(b)}` : "",
|
|
1380
|
+
" tokens"
|
|
1381
|
+
] }),
|
|
1382
|
+
/* @__PURE__ */ e("span", { className: t.akMetaText, children: m.stats ? `${m.stats.totalRequests} 次请求` : m.statsError ?? "" })
|
|
1383
|
+
] })
|
|
1384
|
+
]
|
|
1385
|
+
},
|
|
1386
|
+
m.key.id
|
|
1387
|
+
);
|
|
1388
|
+
}) })
|
|
1389
|
+
] }),
|
|
1390
|
+
/* @__PURE__ */ s("div", { className: D.sectionCard, children: [
|
|
1391
|
+
/* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "模型用量分布(全 AK 聚合)" }),
|
|
1392
|
+
/* @__PURE__ */ e(ye, { models: S.models })
|
|
1393
|
+
] })
|
|
1394
|
+
] });
|
|
1395
|
+
return /* @__PURE__ */ s("div", { className: D.container, children: [
|
|
1396
|
+
/* @__PURE__ */ s("div", { className: t.modelMgmtHeader, children: [
|
|
1397
|
+
/* @__PURE__ */ e("h2", { className: t.modelMgmtTitle, children: "模型监控" }),
|
|
1398
|
+
/* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "大模型网关管控视图 — 按 AK / 模型聚合调用量、Tokens 与延迟(近 30 天)" })
|
|
1399
|
+
] }),
|
|
1400
|
+
/* @__PURE__ */ e(
|
|
1401
|
+
Ce,
|
|
1402
|
+
{
|
|
1403
|
+
defaultActiveKey: "usage",
|
|
1404
|
+
items: [
|
|
1405
|
+
{ key: "usage", label: "模型用量", children: x() },
|
|
1406
|
+
{
|
|
1407
|
+
key: "sessions",
|
|
1408
|
+
label: "会话统计",
|
|
1409
|
+
children: /* @__PURE__ */ e(je, { fallback: /* @__PURE__ */ e(V, { tip: "加载会话统计..." }), children: /* @__PURE__ */ e(vt, {}) })
|
|
1410
|
+
}
|
|
1411
|
+
]
|
|
1412
|
+
}
|
|
1413
|
+
),
|
|
1414
|
+
/* @__PURE__ */ e(
|
|
1415
|
+
we,
|
|
1416
|
+
{
|
|
1417
|
+
title: d ? `AK 用量 — ${d.key.description || d.key.akPrefix}` : "",
|
|
1418
|
+
width: 860,
|
|
1419
|
+
open: !!d,
|
|
1420
|
+
onClose: () => k(null),
|
|
1421
|
+
destroyOnHidden: !0,
|
|
1422
|
+
children: d && /* @__PURE__ */ s("div", { className: t.usageDrawerContent, children: [
|
|
1423
|
+
/* @__PURE__ */ s("div", { className: t.usageStatsGrid, children: [
|
|
1424
|
+
/* @__PURE__ */ e($, { title: "总请求", value: ((T = d.stats) == null ? void 0 : T.totalRequests) ?? 0 }),
|
|
1425
|
+
/* @__PURE__ */ e($, { title: "总 Tokens", value: ((E = d.stats) == null ? void 0 : E.totalTokens) ?? 0 }),
|
|
1426
|
+
/* @__PURE__ */ e($, { title: "平均延迟", value: ((f = d.stats) == null ? void 0 : f.avgLatencyMs) ?? 0, suffix: "ms" }),
|
|
1427
|
+
/* @__PURE__ */ e($, { title: "输入 Tokens", value: ((p = d.stats) == null ? void 0 : p.totalPromptTokens) ?? 0 }),
|
|
1428
|
+
/* @__PURE__ */ e($, { title: "输出 Tokens", value: ((y = d.stats) == null ? void 0 : y.totalCompletionTokens) ?? 0 }),
|
|
1429
|
+
/* @__PURE__ */ e(
|
|
1430
|
+
$,
|
|
1431
|
+
{
|
|
1432
|
+
title: "错误数",
|
|
1433
|
+
value: ((u = d.stats) == null ? void 0 : u.errorCount) ?? 0,
|
|
1434
|
+
valueStyle: (((_ = d.stats) == null ? void 0 : _.errorCount) ?? 0) > 0 ? { color: "#ff4d4f" } : void 0
|
|
1435
|
+
}
|
|
1436
|
+
)
|
|
1437
|
+
] }),
|
|
1438
|
+
/* @__PURE__ */ s("div", { className: t.usageSection, children: [
|
|
1439
|
+
/* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "每日用量(近 30 天)" }),
|
|
1440
|
+
d.stats ? /* @__PURE__ */ e(Ct, { daily: d.stats.daily ?? {} }) : /* @__PURE__ */ e("span", { className: t.usageEmpty, children: d.statsError ?? "暂无数据" })
|
|
1441
|
+
] }),
|
|
1442
|
+
/* @__PURE__ */ s("div", { className: t.usageSection, children: [
|
|
1443
|
+
/* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "模型用量分布" }),
|
|
1444
|
+
d.stats ? /* @__PURE__ */ e(ye, { models: d.stats.models ?? {} }) : /* @__PURE__ */ e("span", { className: t.usageEmpty, children: d.statsError ?? "暂无数据" })
|
|
1445
|
+
] }),
|
|
1446
|
+
/* @__PURE__ */ s("div", { className: t.usageSection, children: [
|
|
1447
|
+
/* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "最近调用" }),
|
|
1448
|
+
/* @__PURE__ */ e(
|
|
1449
|
+
Ae,
|
|
1450
|
+
{
|
|
1451
|
+
size: "small",
|
|
1452
|
+
columns: St,
|
|
1453
|
+
dataSource: wt(d),
|
|
1454
|
+
rowKey: "id",
|
|
1455
|
+
pagination: {
|
|
1456
|
+
pageSize: 8,
|
|
1457
|
+
showSizeChanger: !0,
|
|
1458
|
+
pageSizeOptions: ["8", "20", "50", "100"],
|
|
1459
|
+
showTotal: (m) => `共 ${m} 条`
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
)
|
|
1463
|
+
] })
|
|
1464
|
+
] })
|
|
1465
|
+
}
|
|
1466
|
+
)
|
|
1467
|
+
] });
|
|
1468
|
+
}
|
|
1469
|
+
const xt = [
|
|
1470
|
+
{ key: "model-management", label: "模型管理", icon: /* @__PURE__ */ e(Oe, {}) },
|
|
1471
|
+
{ key: "model-chat", label: "模型对话", icon: /* @__PURE__ */ e(De, {}) },
|
|
1472
|
+
{ key: "ak-management", label: "AK 管理", icon: /* @__PURE__ */ e(Le, {}) },
|
|
1473
|
+
{ key: "agent-app", label: "Agent 应用", icon: /* @__PURE__ */ e(Te, {}) },
|
|
1474
|
+
{ key: "mcp-service", label: "MCP 服务", icon: /* @__PURE__ */ e(Re, {}) },
|
|
1475
|
+
{ key: "skill-market", label: "技能市场", icon: /* @__PURE__ */ e(ze, {}) },
|
|
1476
|
+
{ key: "model-monitor", label: "模型监控", icon: /* @__PURE__ */ e(qe, {}) }
|
|
1477
|
+
];
|
|
1478
|
+
function It() {
|
|
1479
|
+
const [a, n] = N("model-management"), [l, i] = N([]), o = (k) => {
|
|
1480
|
+
i(k), n("model-chat");
|
|
1481
|
+
}, v = xe(() => xt, []), d = (k, K, S = !1) => /* @__PURE__ */ e(
|
|
1482
|
+
"div",
|
|
1483
|
+
{
|
|
1484
|
+
style: {
|
|
1485
|
+
display: a === k ? S ? "flex" : "block" : "none",
|
|
1486
|
+
height: "100%",
|
|
1487
|
+
...S ? { flexDirection: "column" } : {}
|
|
1488
|
+
},
|
|
1489
|
+
children: K
|
|
1490
|
+
}
|
|
1491
|
+
);
|
|
1492
|
+
return /* @__PURE__ */ s("div", { className: t.container, children: [
|
|
1493
|
+
/* @__PURE__ */ e("aside", { className: t.sidebar, children: /* @__PURE__ */ e("nav", { className: t.menuList, children: v.map((k) => /* @__PURE__ */ e(Q, { title: k.label, placement: "right", children: /* @__PURE__ */ e(
|
|
1494
|
+
"div",
|
|
1495
|
+
{
|
|
1496
|
+
className: `${t.menuItem} ${a === k.key ? t.menuItemActive : ""}`,
|
|
1497
|
+
onClick: () => n(k.key),
|
|
1498
|
+
children: /* @__PURE__ */ e("span", { className: t.menuIcon, children: k.icon })
|
|
1499
|
+
}
|
|
1500
|
+
) }, k.key)) }) }),
|
|
1501
|
+
/* @__PURE__ */ s("main", { className: t.panelArea, children: [
|
|
1502
|
+
d("model-management", /* @__PURE__ */ e(ot, { onStartChat: o })),
|
|
1503
|
+
d("model-chat", /* @__PURE__ */ e(it, { initialModels: l }), !0),
|
|
1504
|
+
d("ak-management", /* @__PURE__ */ e(st, {})),
|
|
1505
|
+
d("agent-app", /* @__PURE__ */ e(Ge, {})),
|
|
1506
|
+
d("mcp-service", /* @__PURE__ */ e(Je, {})),
|
|
1507
|
+
d("skill-market", /* @__PURE__ */ e(Qe, {})),
|
|
1508
|
+
d("model-monitor", /* @__PURE__ */ e(At, {}))
|
|
1509
|
+
] })
|
|
1510
|
+
] });
|
|
1511
|
+
}
|
|
1512
|
+
export {
|
|
1513
|
+
It as default
|
|
1514
|
+
};
|