@abpjs/ui 0.2.0-next.1 → 0.2.0-next.10
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 +107 -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 +116 -25
- package/dist/ai.js +251 -114
- package/dist/ai.js.map +1 -1
- package/dist/index.d.ts +83 -6
- package/dist/index.js +1762 -1118
- package/dist/index.js.map +1 -1
- package/package.json +8 -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);
|
|
@@ -420,7 +429,7 @@ function modelRows(connections) {
|
|
|
420
429
|
const price = c.modelPrices?.[model];
|
|
421
430
|
const input = price ? num(price.input) : num(c.inputPrice);
|
|
422
431
|
const output = price ? num(price.output) : num(c.outputPrice);
|
|
423
|
-
const priced =
|
|
432
|
+
const priced = input !== 0 || output !== 0;
|
|
424
433
|
return {
|
|
425
434
|
key: modelKey(c.id, model),
|
|
426
435
|
connectionId: c.id,
|
|
@@ -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();
|
|
@@ -821,7 +882,7 @@ function ExportsPanel({ scopeId }) {
|
|
|
821
882
|
// src/areas/ai/ModelsPanel.tsx
|
|
822
883
|
import { useState as useState5 } from "react";
|
|
823
884
|
import { HStack as HStack4, Input as Input4, Stack as Stack5, Text as Text5 } from "@chakra-ui/react";
|
|
824
|
-
import { Button as Button5, CheckboxField as CheckboxField2, DataTable as DataTable3, Field as Field4, FormDialog as FormDialog2, HostSlot as HostSlot2, notify as notify3, Panel as Panel4, SelectField as SelectField3, StatusPill as StatusPill2, SwitchField as SwitchField2, errorText as errorText2, useApiAction as useApiAction4, useAreaRequest as useAreaRequest4, useFormatters as useFormatters4 } from "@abpjs/ui";
|
|
885
|
+
import { Button as Button5, CheckboxField as CheckboxField2, DataTable as DataTable3, Field as Field4, FormDialog as FormDialog2, HostSlot as HostSlot2, notify as notify3, Panel as Panel4, SelectField as SelectField3, StatusPill as StatusPill2, SwitchField as SwitchField2, errorText as errorText2, useApiAction as useApiAction4, useAreaRequest as useAreaRequest4, useFormatters as useFormatters4, useOptionalHost as useOptionalHost2 } from "@abpjs/ui";
|
|
825
886
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
826
887
|
function ModelsPanel({ scopeId, connections, rows, loading, hostKeeps, onChanged, title, description }) {
|
|
827
888
|
const t = useAiTexts();
|
|
@@ -834,6 +895,8 @@ function ModelsPanel({ scopeId, connections, rows, loading, hostKeeps, onChanged
|
|
|
834
895
|
const shown = rows ?? (connections ? modelRows(connections) : void 0);
|
|
835
896
|
const source = list.find((c) => c.id === picked) ?? list[0];
|
|
836
897
|
const own = (m) => list.some((c) => c.id === m.connectionId);
|
|
898
|
+
const host = useOptionalHost2();
|
|
899
|
+
const hostSaysCan = hostKeeps && Boolean(host?.slots?.["ai.models.can"]);
|
|
837
900
|
async function discover(c) {
|
|
838
901
|
setFinding(c.id);
|
|
839
902
|
try {
|
|
@@ -893,7 +956,7 @@ function ModelsPanel({ scopeId, connections, rows, loading, hostKeeps, onChanged
|
|
|
893
956
|
{
|
|
894
957
|
id: "can",
|
|
895
958
|
header: t("can"),
|
|
896
|
-
cell: (m) => /* @__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: [
|
|
897
960
|
m.tools && /* @__PURE__ */ jsx5(StatusPill2, { tone: "neutral", dot: false, children: t("tools") }),
|
|
898
961
|
m.images && /* @__PURE__ */ jsx5(StatusPill2, { tone: "neutral", dot: false, children: t("images") }),
|
|
899
962
|
m.structuredOutput && /* @__PURE__ */ jsx5(StatusPill2, { tone: "neutral", dot: false, children: t("structured") })
|
|
@@ -989,22 +1052,62 @@ function ModelEditor({ connection, model, onClose, onSaved }) {
|
|
|
989
1052
|
);
|
|
990
1053
|
}
|
|
991
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
|
+
|
|
992
1095
|
// src/areas/ai/UsagePanel.tsx
|
|
993
|
-
import { useMemo as useMemo3, useState as
|
|
994
|
-
import { HStack as
|
|
995
|
-
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";
|
|
996
1099
|
|
|
997
1100
|
// src/areas/ai/usePostQuery.ts
|
|
998
|
-
import { useCallback, useEffect as useEffect2, useRef, useState as
|
|
999
|
-
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";
|
|
1000
1103
|
function usePostQuery(path, body) {
|
|
1001
|
-
const request =
|
|
1104
|
+
const request = useAreaRequest6("ai");
|
|
1002
1105
|
const key = JSON.stringify(body);
|
|
1003
|
-
const [data, setData] =
|
|
1004
|
-
const [error, setError] =
|
|
1005
|
-
const [loading, setLoading] =
|
|
1006
|
-
const seq =
|
|
1007
|
-
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 () => {
|
|
1008
1111
|
const id = ++seq.current;
|
|
1009
1112
|
setLoading(true);
|
|
1010
1113
|
try {
|
|
@@ -1026,7 +1129,7 @@ function usePostQuery(path, body) {
|
|
|
1026
1129
|
}
|
|
1027
1130
|
|
|
1028
1131
|
// src/areas/ai/UsagePanel.tsx
|
|
1029
|
-
import { jsx as
|
|
1132
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1030
1133
|
var USAGE_BY = { project: "scope", model: "model", purpose: "purpose", account: "account" };
|
|
1031
1134
|
var outcomeOf = (state) => state === "done" ? "ok" : state;
|
|
1032
1135
|
var OUTCOME_TONES = { ok: "success", refused: "warning", failed: "danger", reserved: "info" };
|
|
@@ -1038,32 +1141,36 @@ function monthRange(offset) {
|
|
|
1038
1141
|
}
|
|
1039
1142
|
function UsagePanel({ scopeId, by: byOptions }) {
|
|
1040
1143
|
const t = useAiTexts();
|
|
1041
|
-
const fmt =
|
|
1042
|
-
const [by, setBy] =
|
|
1043
|
-
const [month, setMonth] =
|
|
1144
|
+
const fmt = useFormatters6();
|
|
1145
|
+
const [by, setBy] = useState8(byOptions[0]);
|
|
1146
|
+
const [month, setMonth] = useState8(0);
|
|
1044
1147
|
const { from, to } = monthRange(month);
|
|
1045
1148
|
const usage = usePostQuery("/usage", { from, to, scopeId: scopeId ?? null, groupBy: USAGE_BY[by] });
|
|
1046
1149
|
const recent = usePostQuery("/usage/recent", { from, to, scopeId: scopeId ?? null, count: 50 });
|
|
1047
1150
|
const rows = usage.data?.rows;
|
|
1048
1151
|
const people = useNames2("people", useMemo3(() => [
|
|
1049
1152
|
...by === "account" ? (rows ?? []).filter((r) => !r.title && r.key).map((r) => r.key) : [],
|
|
1050
|
-
...(recent.data ?? []).flatMap((c) =>
|
|
1153
|
+
...(recent.data ?? []).flatMap((c) => [
|
|
1154
|
+
...c.accountId && !c.accountName ? [c.accountId] : [],
|
|
1155
|
+
...c.onBehalfOf && !c.onBehalfOfName ? [c.onBehalfOf] : []
|
|
1156
|
+
])
|
|
1051
1157
|
], [by, rows, recent.data]));
|
|
1158
|
+
const nameOf = (id, name) => name || (id ? people[id] : void 0) || id || EMPTY_VALUE;
|
|
1052
1159
|
const scopes = useNames2("scopes", useMemo3(() => by === "project" ? (rows ?? []).filter((r) => !r.title && r.key).map((r) => r.key) : [], [by, rows]));
|
|
1053
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" }) }));
|
|
1054
1161
|
const total = (rows ?? []).reduce((sum, r) => sum + num(r.cost), 0);
|
|
1055
1162
|
const money = (v) => fmt.number(num(v), { maximumFractionDigits: 6 });
|
|
1056
1163
|
const label = (key, title) => key === "" && by === "project" ? t("siteCalls") : title || (by === "account" ? people[key] : by === "project" ? scopes[key] : void 0) || key;
|
|
1057
|
-
return /* @__PURE__ */
|
|
1058
|
-
/* @__PURE__ */
|
|
1059
|
-
|
|
1164
|
+
return /* @__PURE__ */ jsxs7(Stack7, { gap: "section", children: [
|
|
1165
|
+
/* @__PURE__ */ jsx7(
|
|
1166
|
+
Panel6,
|
|
1060
1167
|
{
|
|
1061
1168
|
title: t("usageTitle"),
|
|
1062
1169
|
description: t("usageTotal", { cost: money(total) }),
|
|
1063
1170
|
flush: true,
|
|
1064
1171
|
"data-testid": "ai-usage",
|
|
1065
|
-
actions: /* @__PURE__ */
|
|
1066
|
-
/* @__PURE__ */
|
|
1172
|
+
actions: /* @__PURE__ */ jsxs7(HStack6, { gap: "2", children: [
|
|
1173
|
+
/* @__PURE__ */ jsx7(
|
|
1067
1174
|
SelectField4,
|
|
1068
1175
|
{
|
|
1069
1176
|
size: "sm",
|
|
@@ -1074,9 +1181,9 @@ function UsagePanel({ scopeId, by: byOptions }) {
|
|
|
1074
1181
|
onChange: (e) => setBy(e.target.value)
|
|
1075
1182
|
}
|
|
1076
1183
|
),
|
|
1077
|
-
/* @__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)) })
|
|
1078
1185
|
] }),
|
|
1079
|
-
children: /* @__PURE__ */
|
|
1186
|
+
children: /* @__PURE__ */ jsx7(
|
|
1080
1187
|
DataTable4,
|
|
1081
1188
|
{
|
|
1082
1189
|
"aria-label": t("usageTitle"),
|
|
@@ -1086,7 +1193,7 @@ function UsagePanel({ scopeId, by: byOptions }) {
|
|
|
1086
1193
|
getRowId: (r) => r.key,
|
|
1087
1194
|
empty: t("noUsage"),
|
|
1088
1195
|
columns: [
|
|
1089
|
-
{ 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) }) },
|
|
1090
1197
|
{ id: "calls", header: t("calls"), numeric: true, cell: (r) => fmt.number(num(r.calls)) },
|
|
1091
1198
|
{ id: "in", header: t("tokensIn"), numeric: true, cell: (r) => fmt.number(num(r.inputTokens)) },
|
|
1092
1199
|
{ id: "out", header: t("tokensOut"), numeric: true, cell: (r) => fmt.number(num(r.outputTokens)) },
|
|
@@ -1098,7 +1205,7 @@ function UsagePanel({ scopeId, by: byOptions }) {
|
|
|
1098
1205
|
)
|
|
1099
1206
|
}
|
|
1100
1207
|
),
|
|
1101
|
-
/* @__PURE__ */
|
|
1208
|
+
/* @__PURE__ */ jsx7(Panel6, { title: t("recentTitle"), flush: true, "data-testid": "ai-recent", children: /* @__PURE__ */ jsx7(
|
|
1102
1209
|
DataTable4,
|
|
1103
1210
|
{
|
|
1104
1211
|
"aria-label": t("recentTitle"),
|
|
@@ -1112,21 +1219,23 @@ function UsagePanel({ scopeId, by: byOptions }) {
|
|
|
1112
1219
|
{
|
|
1113
1220
|
id: "who",
|
|
1114
1221
|
header: t("who"),
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
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 })
|
|
1118
1227
|
] })
|
|
1119
1228
|
},
|
|
1120
|
-
{ id: "purpose", header: t("purpose"), cell: (u) => /* @__PURE__ */
|
|
1121
|
-
{ 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 }) },
|
|
1122
1231
|
{ id: "tokens", header: t("tokens"), numeric: true, cell: (u) => `${fmt.number(num(u.inputTokens))} / ${fmt.number(num(u.outputTokens))}` },
|
|
1123
1232
|
{ id: "cost", header: t("cost"), numeric: true, cell: (u) => money(u.cost) },
|
|
1124
1233
|
{
|
|
1125
1234
|
id: "outcome",
|
|
1126
1235
|
header: t("outcome"),
|
|
1127
|
-
cell: (u) => /* @__PURE__ */
|
|
1128
|
-
/* @__PURE__ */
|
|
1129
|
-
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 })
|
|
1130
1239
|
] })
|
|
1131
1240
|
}
|
|
1132
1241
|
]
|
|
@@ -1136,22 +1245,20 @@ function UsagePanel({ scopeId, by: byOptions }) {
|
|
|
1136
1245
|
}
|
|
1137
1246
|
|
|
1138
1247
|
// src/areas/ai/AiAdmin.tsx
|
|
1139
|
-
import { jsx as
|
|
1140
|
-
function useHostKeepsConnections(
|
|
1248
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1249
|
+
function useHostKeepsConnections(told, scopeId) {
|
|
1141
1250
|
const can = useCan();
|
|
1142
|
-
const told = site?.connectionsKeptByHost;
|
|
1143
1251
|
return told ?? !can("ai.connections.edit", scopeId);
|
|
1144
1252
|
}
|
|
1145
1253
|
function AiAdmin() {
|
|
1146
1254
|
const t = useAiTexts();
|
|
1147
|
-
const request =
|
|
1255
|
+
const request = useAreaRequest7("ai");
|
|
1148
1256
|
const site = useApiQuery3("ai", "/site");
|
|
1149
1257
|
const connections = useApiQuery3("ai", "/connections");
|
|
1150
1258
|
const aliases = useApiQuery3("ai", "/aliases");
|
|
1151
1259
|
const limits = useApiQuery3("ai", "/limits");
|
|
1152
|
-
const saving =
|
|
1153
|
-
const hostKeeps = useHostKeepsConnections(site.data);
|
|
1154
|
-
const tryHere = Boolean(useOptionalHost2()?.slots?.["ai.try"]);
|
|
1260
|
+
const saving = useApiAction6();
|
|
1261
|
+
const hostKeeps = useHostKeepsConnections(site.data?.connectionsKeptByHost);
|
|
1155
1262
|
const models = useMemo4(() => modelRows(connections.data ?? []), [connections.data]);
|
|
1156
1263
|
async function saveSiteLimits(rows) {
|
|
1157
1264
|
if (await saving.run(() => saveLimits(request, null, limits.data ?? [], rows).then(() => true)) !== void 0) {
|
|
@@ -1159,20 +1266,20 @@ function AiAdmin() {
|
|
|
1159
1266
|
await limits.reload();
|
|
1160
1267
|
}
|
|
1161
1268
|
}
|
|
1162
|
-
return /* @__PURE__ */
|
|
1163
|
-
/* @__PURE__ */
|
|
1164
|
-
/* @__PURE__ */
|
|
1165
|
-
/* @__PURE__ */
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */
|
|
1169
|
-
|
|
1170
|
-
/* @__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") })
|
|
1171
1278
|
] }),
|
|
1172
|
-
/* @__PURE__ */
|
|
1173
|
-
/* @__PURE__ */
|
|
1174
|
-
connections.data && connections.data.length === 0 && /* @__PURE__ */
|
|
1175
|
-
/* @__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(
|
|
1176
1283
|
ModelsPanel,
|
|
1177
1284
|
{
|
|
1178
1285
|
connections: connections.data,
|
|
@@ -1184,22 +1291,22 @@ function AiAdmin() {
|
|
|
1184
1291
|
}
|
|
1185
1292
|
)
|
|
1186
1293
|
] }) }),
|
|
1187
|
-
/* @__PURE__ */
|
|
1188
|
-
/* @__PURE__ */
|
|
1189
|
-
/* @__PURE__ */
|
|
1190
|
-
/* @__PURE__ */
|
|
1191
|
-
|
|
1192
|
-
/* @__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, {}) })
|
|
1193
1300
|
] });
|
|
1194
1301
|
}
|
|
1195
1302
|
|
|
1196
1303
|
// src/areas/ai/pages.tsx
|
|
1197
|
-
import { jsx as
|
|
1304
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1198
1305
|
function AiAdminPage() {
|
|
1199
1306
|
const t = useAiTexts();
|
|
1200
|
-
return /* @__PURE__ */
|
|
1201
|
-
/* @__PURE__ */
|
|
1202
|
-
/* @__PURE__ */
|
|
1307
|
+
return /* @__PURE__ */ jsxs9(Stack9, { gap: "section", children: [
|
|
1308
|
+
/* @__PURE__ */ jsx9(PageHeader, { title: t("pageTitle"), description: t("pageSubtitle") }),
|
|
1309
|
+
/* @__PURE__ */ jsx9(AiAdmin, {})
|
|
1203
1310
|
] });
|
|
1204
1311
|
}
|
|
1205
1312
|
function aiPages(options) {
|
|
@@ -1220,59 +1327,87 @@ function aiPages(options) {
|
|
|
1220
1327
|
|
|
1221
1328
|
// src/areas/ai/AiScopeScreen.tsx
|
|
1222
1329
|
import { useMemo as useMemo5 } from "react";
|
|
1223
|
-
import { Stack as
|
|
1224
|
-
import {
|
|
1225
|
-
import { jsx as
|
|
1226
|
-
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 }) {
|
|
1227
1334
|
const t = useAiTexts();
|
|
1228
1335
|
const limitText = useLimitText();
|
|
1229
|
-
const
|
|
1230
|
-
const
|
|
1231
|
-
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);
|
|
1232
1341
|
const aliases = useApiQuery4("ai", `/aliases${scopeQuery(scopeId)}`);
|
|
1233
1342
|
const limits = useApiQuery4("ai", `/limits${scopeQuery(scopeId)}`);
|
|
1234
|
-
const
|
|
1235
|
-
const
|
|
1343
|
+
const hostKeeps = useHostKeepsConnections(v?.connectionsKeptByHost, scopeId);
|
|
1344
|
+
const rows = useMemo5(() => v ? scopeModelRows(v) : void 0, [v]);
|
|
1236
1345
|
const a = access.data;
|
|
1237
|
-
const
|
|
1238
|
-
const
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
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
|
+
}
|
|
1243
1364
|
const opened = a && (a.allSiteModels ? t("allModels") : a.siteModels.length ? t("someModels", { count: a.siteModels.length }) : t("noModelsOpen"));
|
|
1244
|
-
const lines = (list) =>
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
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")) }) })
|
|
1249
1380
|
] }) }),
|
|
1250
|
-
/* @__PURE__ */
|
|
1381
|
+
/* @__PURE__ */ jsx10(
|
|
1251
1382
|
ModelsPanel,
|
|
1252
1383
|
{
|
|
1253
1384
|
scopeId,
|
|
1254
|
-
connections:
|
|
1385
|
+
connections: v?.mayConnect ? own.data ?? [] : [],
|
|
1255
1386
|
rows,
|
|
1256
|
-
loading:
|
|
1387
|
+
loading: view.loading,
|
|
1257
1388
|
hostKeeps,
|
|
1258
|
-
onChanged: () => Promise.all([own.reload(), aliases.reload()]).then(() => void 0),
|
|
1389
|
+
onChanged: () => Promise.all([view.reload(), own.reload(), aliases.reload()]).then(() => void 0),
|
|
1259
1390
|
title: t("projectModelsTitle"),
|
|
1260
|
-
description:
|
|
1391
|
+
description: v?.mayConnect ? t("projectModelsOwnHint") : t("projectModelsHint")
|
|
1261
1392
|
}
|
|
1262
1393
|
),
|
|
1263
|
-
/* @__PURE__ */
|
|
1264
|
-
/* @__PURE__ */
|
|
1265
|
-
/* @__PURE__ */
|
|
1266
|
-
/* @__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") }),
|
|
1267
1398
|
lines(limits.data)
|
|
1268
1399
|
] }),
|
|
1269
|
-
!
|
|
1270
|
-
/* @__PURE__ */
|
|
1271
|
-
lines(
|
|
1272
|
-
] })
|
|
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"))
|
|
1273
1408
|
] }) }),
|
|
1274
|
-
/* @__PURE__ */
|
|
1275
|
-
/* @__PURE__ */
|
|
1409
|
+
/* @__PURE__ */ jsx10(UsagePanel, { scopeId, by: ["model", "purpose", "account"] }),
|
|
1410
|
+
/* @__PURE__ */ jsx10(TryPanel, { scopeId, aliases: aliasNames }, aliases.data && v ? "loaded" : "loading")
|
|
1276
1411
|
] }) });
|
|
1277
1412
|
}
|
|
1278
1413
|
export {
|
|
@@ -1286,6 +1421,7 @@ export {
|
|
|
1286
1421
|
LIMIT_PERIODS,
|
|
1287
1422
|
LimitsEditor,
|
|
1288
1423
|
ModelsPanel,
|
|
1424
|
+
TryPanel,
|
|
1289
1425
|
USAGE_BY,
|
|
1290
1426
|
UsagePanel,
|
|
1291
1427
|
aiPages,
|
|
@@ -1295,6 +1431,7 @@ export {
|
|
|
1295
1431
|
modelRows,
|
|
1296
1432
|
num,
|
|
1297
1433
|
saveLimits,
|
|
1434
|
+
scopeModelRows,
|
|
1298
1435
|
useAiTexts,
|
|
1299
1436
|
useHostKeepsConnections,
|
|
1300
1437
|
useLimitText,
|