@abpjs/ui 0.2.0-next.2 → 0.2.0-next.20
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/CHANGELOG.md +193 -0
- package/dist/agent.d.ts +742 -0
- package/dist/agent.js +2170 -0
- package/dist/agent.js.map +1 -0
- package/dist/ai.d.ts +113 -23
- package/dist/ai.js +247 -112
- package/dist/ai.js.map +1 -1
- package/dist/guard.d.ts +1608 -0
- package/dist/guard.js +3639 -0
- package/dist/guard.js.map +1 -0
- package/dist/index.d.ts +348 -22
- package/dist/index.js +2398 -1209
- package/dist/index.js.map +1 -1
- package/dist/rules.d.ts +23 -1
- package/dist/rules.js +35 -0
- package/dist/rules.js.map +1 -1
- package/package.json +14 -1
package/dist/ai.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/areas/ai/pages.tsx
|
|
4
|
-
import { Stack as
|
|
4
|
+
import { Stack as Stack9 } from "@chakra-ui/react";
|
|
5
5
|
import { PageHeader } from "@abpjs/ui";
|
|
6
6
|
|
|
7
7
|
// src/areas/ai/AiAdmin.tsx
|
|
8
8
|
import { useMemo as useMemo4 } from "react";
|
|
9
|
-
import { Stack as
|
|
10
|
-
import {
|
|
9
|
+
import { Stack as Stack8, Tabs } from "@chakra-ui/react";
|
|
10
|
+
import { InlineAlert as InlineAlert6, notify as notify4, Panel as Panel7, useApiAction as useApiAction6, useApiQuery as useApiQuery3, useAreaRequest as useAreaRequest7, useCan } from "@abpjs/ui";
|
|
11
11
|
|
|
12
12
|
// src/areas/ai/AccessPanel.tsx
|
|
13
|
-
import { useEffect, useMemo, useState as useState2 } from "react";
|
|
13
|
+
import { useCallback, useEffect, useMemo, useRef, useState as useState2 } from "react";
|
|
14
14
|
import { Stack as Stack2, Text as Text2 } from "@chakra-ui/react";
|
|
15
15
|
import { Button as Button2, CheckboxField, DataTable, FormDialog, HostSlot, InlineAlert as InlineAlert2, notify, Panel, SearchInput, StatusPill, SwitchField, useApiAction, useApiQuery, useAreaRequest, useFormatters as useFormatters2, useHost, useNames, useOptionalHost, useSlotSaves } from "@abpjs/ui";
|
|
16
16
|
|
|
@@ -118,6 +118,8 @@ var ar_default = {
|
|
|
118
118
|
"periods.month": "\u0634\u0647\u0631",
|
|
119
119
|
limitText: "{kind} \u0644\u0643\u0644 {period}: {amount}",
|
|
120
120
|
limitCallTokens: "\u0627\u0644\u0631\u0645\u0648\u0632 \u0644\u0643\u0644 \u0631\u062F: {amount}",
|
|
121
|
+
limitEachPerson: "{kind} \u0644\u0643\u0644 {period} \u0644\u0643\u0644 \u0634\u062E\u0635: {amount}",
|
|
122
|
+
limitsOfTheirOwn: "{count, plural, zero {\u0644\u0627 \u062D\u0633\u0627\u0628\u0627\u062A \u0623\u0648 \u0645\u062C\u0645\u0648\u0639\u0627\u062A \u0644\u0647\u0627 \u062D\u062F\u0648\u062F \u062E\u0627\u0635\u0629.} one {\u0644\u062D\u0633\u0627\u0628 \u0623\u0648 \u0645\u062C\u0645\u0648\u0639\u0629 \u0648\u0627\u062D\u062F\u0629 \u062D\u062F\u0651 \u062E\u0627\u0635.} two {\u0644\u062D\u0633\u0627\u0628\u064A\u0646 \u0623\u0648 \u0645\u062C\u0645\u0648\u0639\u062A\u064A\u0646 \u062D\u062F\u0648\u062F \u062E\u0627\u0635\u0629.} few {\u0644\u0640# \u062D\u0633\u0627\u0628\u0627\u062A \u0648\u0645\u062C\u0645\u0648\u0639\u0627\u062A \u062D\u062F\u0648\u062F \u062E\u0627\u0635\u0629.} many {\u0644\u0640# \u062D\u0633\u0627\u0628\u064B\u0627 \u0648\u0645\u062C\u0645\u0648\u0639\u0629 \u062D\u062F\u0648\u062F \u062E\u0627\u0635\u0629.} other {\u0644\u0640# \u062D\u0633\u0627\u0628 \u0648\u0645\u062C\u0645\u0648\u0639\u0629 \u062D\u062F\u0648\u062F \u062E\u0627\u0635\u0629.}}",
|
|
121
123
|
usageTitle: "\u0627\u0644\u0627\u0633\u062A\u062E\u062F\u0627\u0645",
|
|
122
124
|
usageTotal: "\u0627\u0644\u0643\u0644\u0641\u0629 \u0627\u0644\u0625\u062C\u0645\u0627\u0644\u064A\u0629: {cost}",
|
|
123
125
|
by: "\u0627\u0644\u062A\u062C\u0645\u064A\u0639 \u062D\u0633\u0628",
|
|
@@ -177,7 +179,8 @@ var ar_default = {
|
|
|
177
179
|
exportDownload: "\u062A\u0646\u0632\u064A\u0644",
|
|
178
180
|
exportDelete: "\u062D\u0630\u0641",
|
|
179
181
|
exportDeleteTitle: "\u0623\u062A\u062D\u0630\u0641 \u0647\u0630\u0627 \u0627\u0644\u062A\u0635\u062F\u064A\u0631\u061F",
|
|
180
|
-
exportDeleteHint: "\u064A\u064F\u062D\u0630\u0641 \u0645\u0644\u0641\u0647 \u0627\u0644\u0622\u0646\u060C \u0642\u0628\u0644 \u0627\u0646\u0642\u0636\u0627\u0621 \u0623\u0633\u0628\u0648\u0639\u0647."
|
|
182
|
+
exportDeleteHint: "\u064A\u064F\u062D\u0630\u0641 \u0645\u0644\u0641\u0647 \u0627\u0644\u0622\u0646\u060C \u0642\u0628\u0644 \u0627\u0646\u0642\u0636\u0627\u0621 \u0623\u0633\u0628\u0648\u0639\u0647.",
|
|
183
|
+
callThrough: "\u0639\u0628\u0631 {name}"
|
|
181
184
|
};
|
|
182
185
|
|
|
183
186
|
// src/areas/ai/texts/en.json
|
|
@@ -275,6 +278,8 @@ var en_default = {
|
|
|
275
278
|
"periods.month": "month",
|
|
276
279
|
limitText: "{kind} per {period}: {amount}",
|
|
277
280
|
limitCallTokens: "Tokens per reply: {amount}",
|
|
281
|
+
limitEachPerson: "{kind} per {period} for each person: {amount}",
|
|
282
|
+
limitsOfTheirOwn: "{count, plural, one {One account or group has a limit of its own.} other {# accounts and groups have limits of their own.}}",
|
|
278
283
|
usageTitle: "Usage",
|
|
279
284
|
usageTotal: "Total cost: {cost}",
|
|
280
285
|
by: "Sum by",
|
|
@@ -334,7 +339,8 @@ var en_default = {
|
|
|
334
339
|
exportDownload: "Download",
|
|
335
340
|
exportDelete: "Delete",
|
|
336
341
|
exportDeleteTitle: "Delete this export?",
|
|
337
|
-
exportDeleteHint: "Its file goes now, before its week is up."
|
|
342
|
+
exportDeleteHint: "Its file goes now, before its week is up.",
|
|
343
|
+
callThrough: "through {name}"
|
|
338
344
|
};
|
|
339
345
|
|
|
340
346
|
// src/areas/ai/texts.ts
|
|
@@ -368,9 +374,12 @@ function useLimitText() {
|
|
|
368
374
|
const fmt = useFormatters();
|
|
369
375
|
return (l) => {
|
|
370
376
|
const r = limitRow(l);
|
|
371
|
-
|
|
377
|
+
if (r.kind === "call-tokens") return t("limitCallTokens", { amount: fmt.number(num(l.amount)) });
|
|
378
|
+
const values = { kind: t(`kinds.${r.kind}`), period: t(`periods.${r.period}`), amount: fmt.number(num(l.amount), { maximumFractionDigits: 6 }) };
|
|
379
|
+
return t(l.kind === "person" ? "limitEachPerson" : "limitText", values);
|
|
372
380
|
};
|
|
373
381
|
}
|
|
382
|
+
var namedLimit = (l) => !!l.accountId || !!l.groupId || l.kind === "account" || l.kind === "group";
|
|
374
383
|
function LimitsEditor({ limits, onSave, onChange, busy, error }) {
|
|
375
384
|
const t = useAiTexts();
|
|
376
385
|
const [draft, setDraftRows] = useState(null);
|
|
@@ -440,6 +449,31 @@ function modelRows(connections) {
|
|
|
440
449
|
})
|
|
441
450
|
);
|
|
442
451
|
}
|
|
452
|
+
function scopeModelRows(view) {
|
|
453
|
+
return view.models.map((m) => {
|
|
454
|
+
const s = m.settings ?? {};
|
|
455
|
+
const input = num(m.price?.input);
|
|
456
|
+
const output = num(m.price?.output);
|
|
457
|
+
const priced = input !== 0 || output !== 0;
|
|
458
|
+
return {
|
|
459
|
+
key: modelKey(m.connectionId, m.model),
|
|
460
|
+
connectionId: m.connectionId,
|
|
461
|
+
connection: m.connection,
|
|
462
|
+
scopeId: m.setOnScopeId ?? null,
|
|
463
|
+
modelId: m.model,
|
|
464
|
+
name: s.name || m.model,
|
|
465
|
+
enabled: s.enabled ?? true,
|
|
466
|
+
tools: s.tools ?? true,
|
|
467
|
+
images: s.images ?? false,
|
|
468
|
+
structuredOutput: s.structuredOutput ?? false,
|
|
469
|
+
contextTokens: s.contextTokens == null ? null : num(s.contextTokens),
|
|
470
|
+
inputPrice: priced ? input : null,
|
|
471
|
+
outputPrice: priced ? output : null,
|
|
472
|
+
priceSetAt: s.priceSetAt ?? null,
|
|
473
|
+
own: m.own
|
|
474
|
+
};
|
|
475
|
+
});
|
|
476
|
+
}
|
|
443
477
|
function withModel(c, model, settings, price) {
|
|
444
478
|
const modelPrices = { ...c.modelPrices ?? {} };
|
|
445
479
|
if (price) modelPrices[model] = { ...modelPrices[model], input: price.input, output: price.output };
|
|
@@ -464,7 +498,7 @@ function withModel(c, model, settings, price) {
|
|
|
464
498
|
}
|
|
465
499
|
|
|
466
500
|
// src/areas/ai/AccessPanel.tsx
|
|
467
|
-
import {
|
|
501
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
468
502
|
function useAllScopes() {
|
|
469
503
|
const host = useHost();
|
|
470
504
|
const [scopes, setScopes] = useState2(void 0);
|
|
@@ -498,6 +532,8 @@ function AccessPanel({ models }) {
|
|
|
498
532
|
const more = unnamed.map((id) => ({ scopeId: id, name: names[id] ?? id, access: access.get(id) }));
|
|
499
533
|
return [...listed, ...more];
|
|
500
534
|
}, [list.data, scopes, unnamed, names]);
|
|
535
|
+
const { counts, refresh } = useLimitCounts(useMemo(() => (rows ?? []).map((r) => r.scopeId), [rows]));
|
|
536
|
+
const fmt = useFormatters2();
|
|
501
537
|
const needle = search.trim().toLowerCase();
|
|
502
538
|
const shown = rows?.filter((p) => !needle || `${p.name} ${p.code ?? ""}`.toLowerCase().includes(needle));
|
|
503
539
|
const opened = (a) => a?.allSiteModels ? t("allModels") : a?.siteModels.length ? t("someModels", { count: a.siteModels.length }) : t("noModelsOpen");
|
|
@@ -535,12 +571,13 @@ function AccessPanel({ models }) {
|
|
|
535
571
|
},
|
|
536
572
|
{ id: "own", header: t("ownConnections"), cell: (p) => p.access?.mayConnect ? t("allowed") : t("notAllowed") },
|
|
537
573
|
...extraCell ? [{ id: "host", header: t("ownSkills"), cell: (p) => /* @__PURE__ */ jsx2(HostSlot, { name: "ai.access.cell", context: { scopeId: p.scopeId } }) }] : [],
|
|
538
|
-
{ id: "limits", header: t("tabs.limits"), numeric: true, cell: (p) =>
|
|
574
|
+
{ id: "limits", header: t("tabs.limits"), numeric: true, cell: (p) => counts[p.scopeId] === void 0 ? "" : fmt.number(counts[p.scopeId]) },
|
|
539
575
|
{ id: "edit", header: /* @__PURE__ */ jsx2(Text2, { srOnly: true, children: t("edit") }), align: "end", cell: (p) => /* @__PURE__ */ jsx2(Button2, { size: "sm", variant: "ghost", onClick: () => setEditing(p), children: t("edit") }) }
|
|
540
576
|
]
|
|
541
577
|
}
|
|
542
578
|
),
|
|
543
579
|
editing && /* @__PURE__ */ jsx2(AccessEditor, { scope: editing, models, onClose: () => setEditing(null), onSaved: async () => {
|
|
580
|
+
refresh(editing.scopeId);
|
|
544
581
|
setEditing(null);
|
|
545
582
|
await list.reload();
|
|
546
583
|
} })
|
|
@@ -548,10 +585,34 @@ function AccessPanel({ models }) {
|
|
|
548
585
|
}
|
|
549
586
|
);
|
|
550
587
|
}
|
|
551
|
-
function
|
|
552
|
-
const
|
|
553
|
-
const
|
|
554
|
-
|
|
588
|
+
function useLimitCounts(scopeIds) {
|
|
589
|
+
const request = useAreaRequest("ai");
|
|
590
|
+
const asked = useRef(/* @__PURE__ */ new Set());
|
|
591
|
+
const [counts, setCounts] = useState2({});
|
|
592
|
+
const [round, setRound] = useState2(0);
|
|
593
|
+
const key = scopeIds.join(",");
|
|
594
|
+
useEffect(() => {
|
|
595
|
+
const wanted = (key ? key.split(",") : []).filter((id) => !asked.current.has(id));
|
|
596
|
+
wanted.forEach((id) => asked.current.add(id));
|
|
597
|
+
void (async () => {
|
|
598
|
+
for (let i = 0; i < wanted.length; i += 4) {
|
|
599
|
+
const found = await Promise.all(wanted.slice(i, i + 4).map(async (id) => {
|
|
600
|
+
try {
|
|
601
|
+
return [id, (await request(`/limits${scopeQuery(id)}`)).length];
|
|
602
|
+
} catch {
|
|
603
|
+
asked.current.delete(id);
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
}));
|
|
607
|
+
setCounts((c) => ({ ...c, ...Object.fromEntries(found.filter((f) => f !== null)) }));
|
|
608
|
+
}
|
|
609
|
+
})();
|
|
610
|
+
}, [key, request, round]);
|
|
611
|
+
const refresh = useCallback((scopeId) => {
|
|
612
|
+
asked.current.delete(scopeId);
|
|
613
|
+
setRound((r) => r + 1);
|
|
614
|
+
}, []);
|
|
615
|
+
return { counts, refresh };
|
|
555
616
|
}
|
|
556
617
|
function AccessEditor({ scope, models, onClose, onSaved }) {
|
|
557
618
|
const t = useAiTexts();
|
|
@@ -895,7 +956,7 @@ function ModelsPanel({ scopeId, connections, rows, loading, hostKeeps, onChanged
|
|
|
895
956
|
{
|
|
896
957
|
id: "can",
|
|
897
958
|
header: t("can"),
|
|
898
|
-
cell: (m) => hostSaysCan ? /* @__PURE__ */ jsx5(HostSlot2, { name: "ai.models.can", context: { connectionId: m.connectionId, modelId: m.modelId } }) : /* @__PURE__ */ jsxs5(HStack4, { gap: "1", flexWrap: "wrap", children: [
|
|
959
|
+
cell: (m) => hostSaysCan ? /* @__PURE__ */ jsx5(HostSlot2, { name: "ai.models.can", context: { connectionId: m.connectionId, modelId: m.modelId, scopeId } }) : /* @__PURE__ */ jsxs5(HStack4, { gap: "1", flexWrap: "wrap", children: [
|
|
899
960
|
m.tools && /* @__PURE__ */ jsx5(StatusPill2, { tone: "neutral", dot: false, children: t("tools") }),
|
|
900
961
|
m.images && /* @__PURE__ */ jsx5(StatusPill2, { tone: "neutral", dot: false, children: t("images") }),
|
|
901
962
|
m.structuredOutput && /* @__PURE__ */ jsx5(StatusPill2, { tone: "neutral", dot: false, children: t("structured") })
|
|
@@ -991,22 +1052,62 @@ function ModelEditor({ connection, model, onClose, onSaved }) {
|
|
|
991
1052
|
);
|
|
992
1053
|
}
|
|
993
1054
|
|
|
1055
|
+
// src/areas/ai/TryPanel.tsx
|
|
1056
|
+
import { useId, useState as useState6 } from "react";
|
|
1057
|
+
import { HStack as HStack5, Input as Input5, Stack as Stack6, Text as Text6, Textarea } from "@chakra-ui/react";
|
|
1058
|
+
import { Button as Button6, Field as Field5, InlineAlert as InlineAlert5, Panel as Panel5, useApiAction as useApiAction5, useAreaRequest as useAreaRequest5, useFormatters as useFormatters5 } from "@abpjs/ui";
|
|
1059
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1060
|
+
function TryPanel({ scopeId, aliases }) {
|
|
1061
|
+
const t = useAiTexts();
|
|
1062
|
+
const fmt = useFormatters5();
|
|
1063
|
+
const request = useAreaRequest5("ai");
|
|
1064
|
+
const action = useApiAction5();
|
|
1065
|
+
const [alias, setAlias] = useState6(aliases[0] ?? "");
|
|
1066
|
+
const [prompt, setPrompt] = useState6("");
|
|
1067
|
+
const [result, setResult] = useState6(null);
|
|
1068
|
+
const listId = useId();
|
|
1069
|
+
async function run() {
|
|
1070
|
+
setResult(null);
|
|
1071
|
+
const body = { alias: alias.trim(), prompt, scopeId: scopeId ?? null };
|
|
1072
|
+
const answer = await action.run(() => request("/try", { method: "POST", body }));
|
|
1073
|
+
if (answer) setResult(answer);
|
|
1074
|
+
}
|
|
1075
|
+
return /* @__PURE__ */ jsx6(Panel5, { title: t("tryTitle"), description: t("tryHint"), "data-testid": "ai-try", children: /* @__PURE__ */ jsxs6(Stack6, { gap: "field", children: [
|
|
1076
|
+
/* @__PURE__ */ jsxs6(Field5, { label: t("alias"), children: [
|
|
1077
|
+
/* @__PURE__ */ jsx6(Input5, { value: alias, dir: "ltr", list: listId, onChange: (e) => setAlias(e.target.value) }),
|
|
1078
|
+
/* @__PURE__ */ jsx6("datalist", { id: listId, children: aliases.map((a) => /* @__PURE__ */ jsx6("option", { value: a }, a)) })
|
|
1079
|
+
] }),
|
|
1080
|
+
/* @__PURE__ */ jsx6(Field5, { label: t("prompt"), children: /* @__PURE__ */ jsx6(Textarea, { value: prompt, rows: 3, onChange: (e) => setPrompt(e.target.value) }) }),
|
|
1081
|
+
/* @__PURE__ */ jsx6(HStack5, { children: /* @__PURE__ */ jsx6(Button6, { onClick: () => void run(), loading: action.busy, disabled: !alias.trim() || !prompt.trim(), children: t("run") }) }),
|
|
1082
|
+
/* @__PURE__ */ jsx6(InlineAlert5, { tone: "danger", children: action.error }),
|
|
1083
|
+
result && /* @__PURE__ */ jsxs6(Stack6, { gap: "1", "data-testid": "ai-try-answer", children: [
|
|
1084
|
+
/* @__PURE__ */ jsx6(Text6, { whiteSpace: "pre-wrap", dir: "auto", children: result.text }),
|
|
1085
|
+
/* @__PURE__ */ jsx6(Text6, { textStyle: "caption", color: "fg.muted", children: t("answered", {
|
|
1086
|
+
model: result.model,
|
|
1087
|
+
input: fmt.number(num(result.usage.inputTokens)),
|
|
1088
|
+
output: fmt.number(num(result.usage.outputTokens)),
|
|
1089
|
+
cost: fmt.number(num(result.usage.cost), { maximumFractionDigits: 6 })
|
|
1090
|
+
}) })
|
|
1091
|
+
] })
|
|
1092
|
+
] }) });
|
|
1093
|
+
}
|
|
1094
|
+
|
|
994
1095
|
// src/areas/ai/UsagePanel.tsx
|
|
995
|
-
import { useMemo as useMemo3, useState as
|
|
996
|
-
import { HStack as
|
|
997
|
-
import { DataTable as DataTable4, EMPTY_VALUE, Panel as
|
|
1096
|
+
import { useMemo as useMemo3, useState as useState8 } from "react";
|
|
1097
|
+
import { HStack as HStack6, Stack as Stack7, Text as Text7 } from "@chakra-ui/react";
|
|
1098
|
+
import { DataTable as DataTable4, EMPTY_VALUE, Panel as Panel6, SelectField as SelectField4, StatusPill as StatusPill3, useFormatters as useFormatters6, useNames as useNames2 } from "@abpjs/ui";
|
|
998
1099
|
|
|
999
1100
|
// src/areas/ai/usePostQuery.ts
|
|
1000
|
-
import { useCallback, useEffect as useEffect2, useRef, useState as
|
|
1001
|
-
import { errorText as errorText3, useAreaRequest as
|
|
1101
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState as useState7 } from "react";
|
|
1102
|
+
import { errorText as errorText3, useAreaRequest as useAreaRequest6 } from "@abpjs/ui";
|
|
1002
1103
|
function usePostQuery(path, body) {
|
|
1003
|
-
const request =
|
|
1104
|
+
const request = useAreaRequest6("ai");
|
|
1004
1105
|
const key = JSON.stringify(body);
|
|
1005
|
-
const [data, setData] =
|
|
1006
|
-
const [error, setError] =
|
|
1007
|
-
const [loading, setLoading] =
|
|
1008
|
-
const seq =
|
|
1009
|
-
const reload =
|
|
1106
|
+
const [data, setData] = useState7(void 0);
|
|
1107
|
+
const [error, setError] = useState7(null);
|
|
1108
|
+
const [loading, setLoading] = useState7(true);
|
|
1109
|
+
const seq = useRef2(0);
|
|
1110
|
+
const reload = useCallback2(async () => {
|
|
1010
1111
|
const id = ++seq.current;
|
|
1011
1112
|
setLoading(true);
|
|
1012
1113
|
try {
|
|
@@ -1028,7 +1129,7 @@ function usePostQuery(path, body) {
|
|
|
1028
1129
|
}
|
|
1029
1130
|
|
|
1030
1131
|
// src/areas/ai/UsagePanel.tsx
|
|
1031
|
-
import { jsx as
|
|
1132
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1032
1133
|
var USAGE_BY = { project: "scope", model: "model", purpose: "purpose", account: "account" };
|
|
1033
1134
|
var outcomeOf = (state) => state === "done" ? "ok" : state;
|
|
1034
1135
|
var OUTCOME_TONES = { ok: "success", refused: "warning", failed: "danger", reserved: "info" };
|
|
@@ -1040,32 +1141,36 @@ function monthRange(offset) {
|
|
|
1040
1141
|
}
|
|
1041
1142
|
function UsagePanel({ scopeId, by: byOptions }) {
|
|
1042
1143
|
const t = useAiTexts();
|
|
1043
|
-
const fmt =
|
|
1044
|
-
const [by, setBy] =
|
|
1045
|
-
const [month, setMonth] =
|
|
1144
|
+
const fmt = useFormatters6();
|
|
1145
|
+
const [by, setBy] = useState8(byOptions[0]);
|
|
1146
|
+
const [month, setMonth] = useState8(0);
|
|
1046
1147
|
const { from, to } = monthRange(month);
|
|
1047
1148
|
const usage = usePostQuery("/usage", { from, to, scopeId: scopeId ?? null, groupBy: USAGE_BY[by] });
|
|
1048
1149
|
const recent = usePostQuery("/usage/recent", { from, to, scopeId: scopeId ?? null, count: 50 });
|
|
1049
1150
|
const rows = usage.data?.rows;
|
|
1050
1151
|
const people = useNames2("people", useMemo3(() => [
|
|
1051
1152
|
...by === "account" ? (rows ?? []).filter((r) => !r.title && r.key).map((r) => r.key) : [],
|
|
1052
|
-
...(recent.data ?? []).flatMap((c) =>
|
|
1153
|
+
...(recent.data ?? []).flatMap((c) => [
|
|
1154
|
+
...c.accountId && !c.accountName ? [c.accountId] : [],
|
|
1155
|
+
...c.onBehalfOf && !c.onBehalfOfName ? [c.onBehalfOf] : []
|
|
1156
|
+
])
|
|
1053
1157
|
], [by, rows, recent.data]));
|
|
1158
|
+
const nameOf = (id, name) => name || (id ? people[id] : void 0) || id || EMPTY_VALUE;
|
|
1054
1159
|
const scopes = useNames2("scopes", useMemo3(() => by === "project" ? (rows ?? []).filter((r) => !r.title && r.key).map((r) => r.key) : [], [by, rows]));
|
|
1055
1160
|
const months = [0, 1, 2, 3, 4, 5].map((m) => ({ value: String(m), label: fmt.dateTime(monthRange(m).from, { year: "numeric", month: "long", timeZone: "UTC" }) }));
|
|
1056
1161
|
const total = (rows ?? []).reduce((sum, r) => sum + num(r.cost), 0);
|
|
1057
1162
|
const money = (v) => fmt.number(num(v), { maximumFractionDigits: 6 });
|
|
1058
1163
|
const label = (key, title) => key === "" && by === "project" ? t("siteCalls") : title || (by === "account" ? people[key] : by === "project" ? scopes[key] : void 0) || key;
|
|
1059
|
-
return /* @__PURE__ */
|
|
1060
|
-
/* @__PURE__ */
|
|
1061
|
-
|
|
1164
|
+
return /* @__PURE__ */ jsxs7(Stack7, { gap: "section", children: [
|
|
1165
|
+
/* @__PURE__ */ jsx7(
|
|
1166
|
+
Panel6,
|
|
1062
1167
|
{
|
|
1063
1168
|
title: t("usageTitle"),
|
|
1064
1169
|
description: t("usageTotal", { cost: money(total) }),
|
|
1065
1170
|
flush: true,
|
|
1066
1171
|
"data-testid": "ai-usage",
|
|
1067
|
-
actions: /* @__PURE__ */
|
|
1068
|
-
/* @__PURE__ */
|
|
1172
|
+
actions: /* @__PURE__ */ jsxs7(HStack6, { gap: "2", children: [
|
|
1173
|
+
/* @__PURE__ */ jsx7(
|
|
1069
1174
|
SelectField4,
|
|
1070
1175
|
{
|
|
1071
1176
|
size: "sm",
|
|
@@ -1076,9 +1181,9 @@ function UsagePanel({ scopeId, by: byOptions }) {
|
|
|
1076
1181
|
onChange: (e) => setBy(e.target.value)
|
|
1077
1182
|
}
|
|
1078
1183
|
),
|
|
1079
|
-
/* @__PURE__ */
|
|
1184
|
+
/* @__PURE__ */ jsx7(SelectField4, { size: "sm", width: "auto", value: String(month), "aria-label": t("month"), options: months, onChange: (e) => setMonth(Number(e.target.value)) })
|
|
1080
1185
|
] }),
|
|
1081
|
-
children: /* @__PURE__ */
|
|
1186
|
+
children: /* @__PURE__ */ jsx7(
|
|
1082
1187
|
DataTable4,
|
|
1083
1188
|
{
|
|
1084
1189
|
"aria-label": t("usageTitle"),
|
|
@@ -1088,7 +1193,7 @@ function UsagePanel({ scopeId, by: byOptions }) {
|
|
|
1088
1193
|
getRowId: (r) => r.key,
|
|
1089
1194
|
empty: t("noUsage"),
|
|
1090
1195
|
columns: [
|
|
1091
|
-
{ id: "label", header: t(`byOptions.${by}`), cell: (r) => /* @__PURE__ */
|
|
1196
|
+
{ id: "label", header: t(`byOptions.${by}`), cell: (r) => /* @__PURE__ */ jsx7(Text7, { dir: "auto", children: label(r.key, r.title) }) },
|
|
1092
1197
|
{ id: "calls", header: t("calls"), numeric: true, cell: (r) => fmt.number(num(r.calls)) },
|
|
1093
1198
|
{ id: "in", header: t("tokensIn"), numeric: true, cell: (r) => fmt.number(num(r.inputTokens)) },
|
|
1094
1199
|
{ id: "out", header: t("tokensOut"), numeric: true, cell: (r) => fmt.number(num(r.outputTokens)) },
|
|
@@ -1100,7 +1205,7 @@ function UsagePanel({ scopeId, by: byOptions }) {
|
|
|
1100
1205
|
)
|
|
1101
1206
|
}
|
|
1102
1207
|
),
|
|
1103
|
-
/* @__PURE__ */
|
|
1208
|
+
/* @__PURE__ */ jsx7(Panel6, { title: t("recentTitle"), flush: true, "data-testid": "ai-recent", children: /* @__PURE__ */ jsx7(
|
|
1104
1209
|
DataTable4,
|
|
1105
1210
|
{
|
|
1106
1211
|
"aria-label": t("recentTitle"),
|
|
@@ -1114,21 +1219,23 @@ function UsagePanel({ scopeId, by: byOptions }) {
|
|
|
1114
1219
|
{
|
|
1115
1220
|
id: "who",
|
|
1116
1221
|
header: t("who"),
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1222
|
+
// An agent's call is the person's it acted for, the agent beside it.
|
|
1223
|
+
cell: (u) => /* @__PURE__ */ jsxs7(Stack7, { gap: "0", children: [
|
|
1224
|
+
/* @__PURE__ */ jsx7(Text7, { children: u.onBehalfOf ? nameOf(u.onBehalfOf, u.onBehalfOfName) : nameOf(u.accountId, u.accountName) }),
|
|
1225
|
+
u.onBehalfOf && /* @__PURE__ */ jsx7(Text7, { textStyle: "caption", color: "fg.muted", children: t("callThrough", { name: nameOf(u.accountId, u.accountName) }) }),
|
|
1226
|
+
u.scope && /* @__PURE__ */ jsx7(Text7, { textStyle: "caption", color: "fg.muted", dir: "ltr", children: u.scope })
|
|
1120
1227
|
] })
|
|
1121
1228
|
},
|
|
1122
|
-
{ id: "purpose", header: t("purpose"), cell: (u) => /* @__PURE__ */
|
|
1123
|
-
{ id: "model", header: t("model"), cell: (u) => /* @__PURE__ */
|
|
1229
|
+
{ id: "purpose", header: t("purpose"), cell: (u) => /* @__PURE__ */ jsx7(Text7, { fontFamily: "mono", textStyle: "sm", dir: "ltr", children: u.purpose || EMPTY_VALUE }) },
|
|
1230
|
+
{ id: "model", header: t("model"), cell: (u) => /* @__PURE__ */ jsx7(Text7, { fontFamily: "mono", textStyle: "sm", dir: "ltr", children: u.model }) },
|
|
1124
1231
|
{ id: "tokens", header: t("tokens"), numeric: true, cell: (u) => `${fmt.number(num(u.inputTokens))} / ${fmt.number(num(u.outputTokens))}` },
|
|
1125
1232
|
{ id: "cost", header: t("cost"), numeric: true, cell: (u) => money(u.cost) },
|
|
1126
1233
|
{
|
|
1127
1234
|
id: "outcome",
|
|
1128
1235
|
header: t("outcome"),
|
|
1129
|
-
cell: (u) => /* @__PURE__ */
|
|
1130
|
-
/* @__PURE__ */
|
|
1131
|
-
u.error && /* @__PURE__ */
|
|
1236
|
+
cell: (u) => /* @__PURE__ */ jsxs7(Stack7, { gap: "0.5", children: [
|
|
1237
|
+
/* @__PURE__ */ jsx7(StatusPill3, { tone: OUTCOME_TONES[outcomeOf(u.state)] ?? "neutral", children: t(`outcomes.${outcomeOf(u.state)}`) }),
|
|
1238
|
+
u.error && /* @__PURE__ */ jsx7(Text7, { textStyle: "caption", color: "fg.muted", lineClamp: 2, title: u.error, children: u.error })
|
|
1132
1239
|
] })
|
|
1133
1240
|
}
|
|
1134
1241
|
]
|
|
@@ -1138,22 +1245,20 @@ function UsagePanel({ scopeId, by: byOptions }) {
|
|
|
1138
1245
|
}
|
|
1139
1246
|
|
|
1140
1247
|
// src/areas/ai/AiAdmin.tsx
|
|
1141
|
-
import { jsx as
|
|
1142
|
-
function useHostKeepsConnections(
|
|
1248
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1249
|
+
function useHostKeepsConnections(told, scopeId) {
|
|
1143
1250
|
const can = useCan();
|
|
1144
|
-
const told = site?.connectionsKeptByHost;
|
|
1145
1251
|
return told ?? !can("ai.connections.edit", scopeId);
|
|
1146
1252
|
}
|
|
1147
1253
|
function AiAdmin() {
|
|
1148
1254
|
const t = useAiTexts();
|
|
1149
|
-
const request =
|
|
1255
|
+
const request = useAreaRequest7("ai");
|
|
1150
1256
|
const site = useApiQuery3("ai", "/site");
|
|
1151
1257
|
const connections = useApiQuery3("ai", "/connections");
|
|
1152
1258
|
const aliases = useApiQuery3("ai", "/aliases");
|
|
1153
1259
|
const limits = useApiQuery3("ai", "/limits");
|
|
1154
|
-
const saving =
|
|
1155
|
-
const hostKeeps = useHostKeepsConnections(site.data);
|
|
1156
|
-
const tryHere = Boolean(useOptionalHost3()?.slots?.["ai.try"]);
|
|
1260
|
+
const saving = useApiAction6();
|
|
1261
|
+
const hostKeeps = useHostKeepsConnections(site.data?.connectionsKeptByHost);
|
|
1157
1262
|
const models = useMemo4(() => modelRows(connections.data ?? []), [connections.data]);
|
|
1158
1263
|
async function saveSiteLimits(rows) {
|
|
1159
1264
|
if (await saving.run(() => saveLimits(request, null, limits.data ?? [], rows).then(() => true)) !== void 0) {
|
|
@@ -1161,20 +1266,20 @@ function AiAdmin() {
|
|
|
1161
1266
|
await limits.reload();
|
|
1162
1267
|
}
|
|
1163
1268
|
}
|
|
1164
|
-
return /* @__PURE__ */
|
|
1165
|
-
/* @__PURE__ */
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */
|
|
1169
|
-
/* @__PURE__ */
|
|
1170
|
-
/* @__PURE__ */
|
|
1171
|
-
|
|
1172
|
-
/* @__PURE__ */
|
|
1269
|
+
return /* @__PURE__ */ jsxs8(Tabs.Root, { defaultValue: "models", variant: "line", lazyMount: true, children: [
|
|
1270
|
+
/* @__PURE__ */ jsxs8(Tabs.List, { mb: "section", overflowX: "auto", overflowY: "hidden", children: [
|
|
1271
|
+
/* @__PURE__ */ jsx8(Tabs.Trigger, { value: "models", children: t("tabs.models") }),
|
|
1272
|
+
/* @__PURE__ */ jsx8(Tabs.Trigger, { value: "aliases", children: t("tabs.aliases") }),
|
|
1273
|
+
/* @__PURE__ */ jsx8(Tabs.Trigger, { value: "access", children: t("tabs.access") }),
|
|
1274
|
+
/* @__PURE__ */ jsx8(Tabs.Trigger, { value: "limits", children: t("tabs.limits") }),
|
|
1275
|
+
/* @__PURE__ */ jsx8(Tabs.Trigger, { value: "usage", children: t("tabs.usage") }),
|
|
1276
|
+
/* @__PURE__ */ jsx8(Tabs.Trigger, { value: "try", children: t("tabs.try") }),
|
|
1277
|
+
/* @__PURE__ */ jsx8(Tabs.Trigger, { value: "exports", children: t("tabs.exports") })
|
|
1173
1278
|
] }),
|
|
1174
|
-
/* @__PURE__ */
|
|
1175
|
-
/* @__PURE__ */
|
|
1176
|
-
connections.data && connections.data.length === 0 && /* @__PURE__ */
|
|
1177
|
-
/* @__PURE__ */
|
|
1279
|
+
/* @__PURE__ */ jsx8(Tabs.Content, { value: "models", children: /* @__PURE__ */ jsxs8(Stack8, { gap: "section", children: [
|
|
1280
|
+
/* @__PURE__ */ jsx8(InlineAlert6, { tone: "danger", children: connections.error }),
|
|
1281
|
+
connections.data && connections.data.length === 0 && /* @__PURE__ */ jsx8(InlineAlert6, { tone: "info", children: t("noProviders") }),
|
|
1282
|
+
/* @__PURE__ */ jsx8(
|
|
1178
1283
|
ModelsPanel,
|
|
1179
1284
|
{
|
|
1180
1285
|
connections: connections.data,
|
|
@@ -1186,22 +1291,22 @@ function AiAdmin() {
|
|
|
1186
1291
|
}
|
|
1187
1292
|
)
|
|
1188
1293
|
] }) }),
|
|
1189
|
-
/* @__PURE__ */
|
|
1190
|
-
/* @__PURE__ */
|
|
1191
|
-
/* @__PURE__ */
|
|
1192
|
-
/* @__PURE__ */
|
|
1193
|
-
|
|
1194
|
-
/* @__PURE__ */
|
|
1294
|
+
/* @__PURE__ */ jsx8(Tabs.Content, { value: "aliases", children: /* @__PURE__ */ jsx8(AliasesPanel, { aliases: aliases.data, models, onSaved: aliases.reload }) }),
|
|
1295
|
+
/* @__PURE__ */ jsx8(Tabs.Content, { value: "access", children: /* @__PURE__ */ jsx8(AccessPanel, { models }) }),
|
|
1296
|
+
/* @__PURE__ */ jsx8(Tabs.Content, { value: "limits", children: /* @__PURE__ */ jsx8(Panel7, { title: t("siteLimitsTitle"), description: t("siteLimitsHint"), children: limits.data && /* @__PURE__ */ jsx8(LimitsEditor, { limits: limits.data, onSave: saveSiteLimits, busy: saving.busy, error: saving.error ?? limits.error }) }) }),
|
|
1297
|
+
/* @__PURE__ */ jsx8(Tabs.Content, { value: "usage", children: /* @__PURE__ */ jsx8(UsagePanel, { by: ["project", "model", "purpose", "account"] }) }),
|
|
1298
|
+
/* @__PURE__ */ jsx8(Tabs.Content, { value: "try", children: /* @__PURE__ */ jsx8(TryPanel, { aliases: (aliases.data ?? []).map((a) => a.name) }) }),
|
|
1299
|
+
/* @__PURE__ */ jsx8(Tabs.Content, { value: "exports", children: /* @__PURE__ */ jsx8(ExportsPanel, {}) })
|
|
1195
1300
|
] });
|
|
1196
1301
|
}
|
|
1197
1302
|
|
|
1198
1303
|
// src/areas/ai/pages.tsx
|
|
1199
|
-
import { jsx as
|
|
1304
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1200
1305
|
function AiAdminPage() {
|
|
1201
1306
|
const t = useAiTexts();
|
|
1202
|
-
return /* @__PURE__ */
|
|
1203
|
-
/* @__PURE__ */
|
|
1204
|
-
/* @__PURE__ */
|
|
1307
|
+
return /* @__PURE__ */ jsxs9(Stack9, { gap: "section", children: [
|
|
1308
|
+
/* @__PURE__ */ jsx9(PageHeader, { title: t("pageTitle"), description: t("pageSubtitle") }),
|
|
1309
|
+
/* @__PURE__ */ jsx9(AiAdmin, {})
|
|
1205
1310
|
] });
|
|
1206
1311
|
}
|
|
1207
1312
|
function aiPages(options) {
|
|
@@ -1222,59 +1327,87 @@ function aiPages(options) {
|
|
|
1222
1327
|
|
|
1223
1328
|
// src/areas/ai/AiScopeScreen.tsx
|
|
1224
1329
|
import { useMemo as useMemo5 } from "react";
|
|
1225
|
-
import { Stack as
|
|
1226
|
-
import {
|
|
1227
|
-
import { jsx as
|
|
1228
|
-
function AiScopeScreen({ scopeId }) {
|
|
1330
|
+
import { Stack as Stack10, Text as Text8 } from "@chakra-ui/react";
|
|
1331
|
+
import { InlineAlert as InlineAlert7, Loading, Panel as Panel8, StatusPill as StatusPill4, TextBone, TextSlot, useApiQuery as useApiQuery4, useNames as useNames3 } from "@abpjs/ui";
|
|
1332
|
+
import { Fragment, jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1333
|
+
function AiScopeScreen({ scopeId, header }) {
|
|
1229
1334
|
const t = useAiTexts();
|
|
1230
1335
|
const limitText = useLimitText();
|
|
1231
|
-
const
|
|
1232
|
-
const
|
|
1233
|
-
const
|
|
1336
|
+
const id = encodeURIComponent(scopeId);
|
|
1337
|
+
const view = useApiQuery4("ai", `/scopes/${id}/view`);
|
|
1338
|
+
const access = useApiQuery4("ai", `/scopes/${id}/access`);
|
|
1339
|
+
const v = view.data;
|
|
1340
|
+
const own = useApiQuery4("ai", v?.mayConnect ? `/connections${scopeQuery(scopeId)}` : null);
|
|
1234
1341
|
const aliases = useApiQuery4("ai", `/aliases${scopeQuery(scopeId)}`);
|
|
1235
1342
|
const limits = useApiQuery4("ai", `/limits${scopeQuery(scopeId)}`);
|
|
1236
|
-
const
|
|
1237
|
-
const
|
|
1343
|
+
const hostKeeps = useHostKeepsConnections(v?.connectionsKeptByHost, scopeId);
|
|
1344
|
+
const rows = useMemo5(() => v ? scopeModelRows(v) : void 0, [v]);
|
|
1238
1345
|
const a = access.data;
|
|
1239
|
-
const
|
|
1240
|
-
const
|
|
1241
|
-
const
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1346
|
+
const above = useMemo5(() => {
|
|
1347
|
+
const groups = [];
|
|
1348
|
+
for (const l of v?.limitsFromAbove ?? []) {
|
|
1349
|
+
const at = l.scopeId ?? null;
|
|
1350
|
+
const group = groups.find((g) => g.scopeId === at);
|
|
1351
|
+
if (group) group.limits.push(l);
|
|
1352
|
+
else groups.push({ scopeId: at, limits: [l] });
|
|
1353
|
+
}
|
|
1354
|
+
return groups;
|
|
1355
|
+
}, [v]);
|
|
1356
|
+
const scopeNames = useNames3("scopes", useMemo5(() => above.flatMap((g) => g.scopeId ? [g.scopeId] : []), [above]));
|
|
1357
|
+
const aliasNames = useMemo5(() => [...new Set([...aliases.data ?? [], ...v?.aliasesFromAbove ?? []].map((x) => x.name))], [aliases.data, v]);
|
|
1358
|
+
if (view.error && !v || access.error && !a) {
|
|
1359
|
+
return /* @__PURE__ */ jsxs10(Stack10, { gap: "section", children: [
|
|
1360
|
+
header,
|
|
1361
|
+
/* @__PURE__ */ jsx10(InlineAlert7, { tone: "danger", children: view.error ?? access.error })
|
|
1362
|
+
] });
|
|
1363
|
+
}
|
|
1245
1364
|
const opened = a && (a.allSiteModels ? t("allModels") : a.siteModels.length ? t("someModels", { count: a.siteModels.length }) : t("noModelsOpen"));
|
|
1246
|
-
const lines = (list) =>
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1365
|
+
const lines = (list) => {
|
|
1366
|
+
if (!list) return /* @__PURE__ */ jsx10(Text8, { textStyle: "sm", children: /* @__PURE__ */ jsx10(TextBone, { width: 24 }) });
|
|
1367
|
+
const own2 = list.filter((l) => !namedLimit(l));
|
|
1368
|
+
const named = new Set(list.filter(namedLimit).map((l) => l.accountId ?? l.groupId ?? l.id)).size;
|
|
1369
|
+
if (!own2.length && !named) return /* @__PURE__ */ jsx10(Text8, { textStyle: "sm", color: "fg.muted", children: t("noLimits") });
|
|
1370
|
+
return /* @__PURE__ */ jsxs10(Fragment, { children: [
|
|
1371
|
+
own2.map((l) => /* @__PURE__ */ jsx10(Text8, { textStyle: "sm", children: limitText(l) }, l.id)),
|
|
1372
|
+
named > 0 && /* @__PURE__ */ jsx10(Text8, { textStyle: "sm", color: "fg.muted", children: t("limitsOfTheirOwn", { count: named }) })
|
|
1373
|
+
] });
|
|
1374
|
+
};
|
|
1375
|
+
return /* @__PURE__ */ jsx10(Loading, { when: !v || !a, children: /* @__PURE__ */ jsxs10(Stack10, { gap: "section", children: [
|
|
1376
|
+
header,
|
|
1377
|
+
/* @__PURE__ */ jsx10(Panel8, { title: t("projectAccessTitle"), description: t("projectAccessHint"), "data-testid": "ai-project-access", children: /* @__PURE__ */ jsxs10(Stack10, { gap: "2", children: [
|
|
1378
|
+
/* @__PURE__ */ jsx10(Text8, { children: /* @__PURE__ */ jsx10(StatusPill4, { tone: a?.allSiteModels || a?.siteModels.length ? "success" : "neutral", children: opened }) }),
|
|
1379
|
+
/* @__PURE__ */ jsx10(Text8, { textStyle: "sm", children: /* @__PURE__ */ jsx10(TextSlot, { width: 44, children: v && (v.mayConnect ? t("ownAllowed") : t("ownNotAllowed")) }) })
|
|
1251
1380
|
] }) }),
|
|
1252
|
-
/* @__PURE__ */
|
|
1381
|
+
/* @__PURE__ */ jsx10(
|
|
1253
1382
|
ModelsPanel,
|
|
1254
1383
|
{
|
|
1255
1384
|
scopeId,
|
|
1256
|
-
connections:
|
|
1385
|
+
connections: v?.mayConnect ? own.data ?? [] : [],
|
|
1257
1386
|
rows,
|
|
1258
|
-
loading:
|
|
1387
|
+
loading: view.loading,
|
|
1259
1388
|
hostKeeps,
|
|
1260
|
-
onChanged: () => Promise.all([own.reload(), aliases.reload()]).then(() => void 0),
|
|
1389
|
+
onChanged: () => Promise.all([view.reload(), own.reload(), aliases.reload()]).then(() => void 0),
|
|
1261
1390
|
title: t("projectModelsTitle"),
|
|
1262
|
-
description:
|
|
1391
|
+
description: v?.mayConnect ? t("projectModelsOwnHint") : t("projectModelsHint")
|
|
1263
1392
|
}
|
|
1264
1393
|
),
|
|
1265
|
-
/* @__PURE__ */
|
|
1266
|
-
/* @__PURE__ */
|
|
1267
|
-
/* @__PURE__ */
|
|
1268
|
-
/* @__PURE__ */
|
|
1394
|
+
/* @__PURE__ */ jsx10(AliasesPanel, { scopeId, aliases: aliases.data, inherited: v?.aliasesFromAbove, models: rows ?? [], onSaved: aliases.reload }),
|
|
1395
|
+
/* @__PURE__ */ jsx10(Panel8, { title: t("tabs.limits"), description: t("projectLimitsReadHint"), "data-testid": "ai-project-limits", children: /* @__PURE__ */ jsxs10(Stack10, { gap: "3", children: [
|
|
1396
|
+
/* @__PURE__ */ jsxs10(Stack10, { gap: "1", children: [
|
|
1397
|
+
/* @__PURE__ */ jsx10(Text8, { textStyle: "sm", fontWeight: "medium", children: t("thisProject") }),
|
|
1269
1398
|
lines(limits.data)
|
|
1270
1399
|
] }),
|
|
1271
|
-
!
|
|
1272
|
-
/* @__PURE__ */
|
|
1273
|
-
lines(
|
|
1274
|
-
] })
|
|
1400
|
+
!v || !above.some((g) => g.scopeId === null) ? /* @__PURE__ */ jsxs10(Stack10, { gap: "1", children: [
|
|
1401
|
+
/* @__PURE__ */ jsx10(Text8, { textStyle: "sm", fontWeight: "medium", children: t("theSite") }),
|
|
1402
|
+
lines(v ? [] : void 0)
|
|
1403
|
+
] }) : null,
|
|
1404
|
+
above.map((g) => /* @__PURE__ */ jsxs10(Stack10, { gap: "1", children: [
|
|
1405
|
+
/* @__PURE__ */ jsx10(Text8, { textStyle: "sm", fontWeight: "medium", children: g.scopeId ? scopeNames[g.scopeId] ?? g.scopeId : t("theSite") }),
|
|
1406
|
+
lines(g.limits)
|
|
1407
|
+
] }, g.scopeId ?? "site"))
|
|
1275
1408
|
] }) }),
|
|
1276
|
-
/* @__PURE__ */
|
|
1277
|
-
/* @__PURE__ */
|
|
1409
|
+
/* @__PURE__ */ jsx10(UsagePanel, { scopeId, by: ["model", "purpose", "account"] }),
|
|
1410
|
+
/* @__PURE__ */ jsx10(TryPanel, { scopeId, aliases: aliasNames }, aliases.data && v ? "loaded" : "loading")
|
|
1278
1411
|
] }) });
|
|
1279
1412
|
}
|
|
1280
1413
|
export {
|
|
@@ -1288,6 +1421,7 @@ export {
|
|
|
1288
1421
|
LIMIT_PERIODS,
|
|
1289
1422
|
LimitsEditor,
|
|
1290
1423
|
ModelsPanel,
|
|
1424
|
+
TryPanel,
|
|
1291
1425
|
USAGE_BY,
|
|
1292
1426
|
UsagePanel,
|
|
1293
1427
|
aiPages,
|
|
@@ -1297,6 +1431,7 @@ export {
|
|
|
1297
1431
|
modelRows,
|
|
1298
1432
|
num,
|
|
1299
1433
|
saveLimits,
|
|
1434
|
+
scopeModelRows,
|
|
1300
1435
|
useAiTexts,
|
|
1301
1436
|
useHostKeepsConnections,
|
|
1302
1437
|
useLimitText,
|