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