@dolfinhos/studio 0.1.0 → 0.3.0
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/index.cjs +468 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -3
- package/dist/index.d.ts +67 -3
- package/dist/index.js +464 -153
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -28,7 +28,9 @@ __export(index_exports, {
|
|
|
28
28
|
DolfinhosStudio: () => DolfinhosStudio,
|
|
29
29
|
KnowledgeBase: () => KnowledgeBase,
|
|
30
30
|
MemoryBrowser: () => MemoryBrowser,
|
|
31
|
+
ModelSettings: () => ModelSettings,
|
|
31
32
|
MyMemory: () => MyMemory,
|
|
33
|
+
ProviderKeys: () => ProviderKeys,
|
|
32
34
|
StudioError: () => StudioError,
|
|
33
35
|
StudioProvider: () => StudioProvider,
|
|
34
36
|
UsageReport: () => UsageReport,
|
|
@@ -36,7 +38,7 @@ __export(index_exports, {
|
|
|
36
38
|
useStudio: () => useStudio
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(index_exports);
|
|
39
|
-
var
|
|
41
|
+
var import_react13 = require("react");
|
|
40
42
|
|
|
41
43
|
// src/api.ts
|
|
42
44
|
var import_react = require("react");
|
|
@@ -98,7 +100,14 @@ function createStudioClient(options = {}) {
|
|
|
98
100
|
searchKnowledge: (query, audience) => request("GET", `/knowledge/search${q({ q: query, audience })}`),
|
|
99
101
|
factSubjects: (type) => request("GET", `/facts${q({ type })}`),
|
|
100
102
|
facts: (subject) => request("GET", `/facts${q({ type: subject.type, id: subject.id })}`),
|
|
101
|
-
forget: (id) => request("DELETE", `/facts/${encodeURIComponent(id)}`)
|
|
103
|
+
forget: (id) => request("DELETE", `/facts/${encodeURIComponent(id)}`),
|
|
104
|
+
credentials: () => request("GET", "/credentials"),
|
|
105
|
+
saveCredential: (name, value) => request("PUT", `/credentials/${encodeURIComponent(name)}`, { value }),
|
|
106
|
+
removeCredential: (name) => request("DELETE", `/credentials/${encodeURIComponent(name)}`),
|
|
107
|
+
models: () => request("GET", "/models"),
|
|
108
|
+
availableModels: (provider) => request("GET", `/models/${encodeURIComponent(provider)}/available`),
|
|
109
|
+
chooseModels: (choice) => request("PUT", "/models", choice),
|
|
110
|
+
resetModels: () => request("DELETE", "/models")
|
|
102
111
|
};
|
|
103
112
|
}
|
|
104
113
|
var StudioContext = (0, import_react.createContext)(null);
|
|
@@ -713,20 +722,320 @@ function BehaviorSettings({ currency }) {
|
|
|
713
722
|
] });
|
|
714
723
|
}
|
|
715
724
|
|
|
716
|
-
// src/
|
|
725
|
+
// src/Keys.tsx
|
|
717
726
|
var import_react7 = require("react");
|
|
727
|
+
var import_react8 = require("react");
|
|
718
728
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
729
|
+
function ProviderKey({
|
|
730
|
+
provider,
|
|
731
|
+
onChanged,
|
|
732
|
+
children,
|
|
733
|
+
compact
|
|
734
|
+
}) {
|
|
735
|
+
const { client, locale } = useStudio();
|
|
736
|
+
const id = (0, import_react7.useId)();
|
|
737
|
+
const [editing, setEditing] = (0, import_react7.useState)(!provider.configured);
|
|
738
|
+
const [value, setValue] = (0, import_react7.useState)("");
|
|
739
|
+
const [busy, setBusy] = (0, import_react7.useState)(null);
|
|
740
|
+
const [message, setMessage] = (0, import_react7.useState)(null);
|
|
741
|
+
async function save() {
|
|
742
|
+
setBusy("save");
|
|
743
|
+
setMessage(null);
|
|
744
|
+
try {
|
|
745
|
+
await client.saveCredential(provider.name, value.trim());
|
|
746
|
+
setValue("");
|
|
747
|
+
setEditing(false);
|
|
748
|
+
setMessage({ tone: "success", text: "Chave testada e salva." });
|
|
749
|
+
await onChanged("saved");
|
|
750
|
+
} catch (e) {
|
|
751
|
+
setMessage({
|
|
752
|
+
tone: "error",
|
|
753
|
+
text: e instanceof Error ? e.message : String(e)
|
|
754
|
+
});
|
|
755
|
+
} finally {
|
|
756
|
+
setBusy(null);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
async function remove() {
|
|
760
|
+
if (!window.confirm(`Remover a chave da ${provider.label}? O assistente e o bot deixam de usar esta conta.${provider.whenMissing ? ` ${provider.whenMissing}` : ""}`)) return;
|
|
761
|
+
setBusy("remove");
|
|
762
|
+
setMessage(null);
|
|
763
|
+
try {
|
|
764
|
+
await client.removeCredential(provider.name);
|
|
765
|
+
setEditing(true);
|
|
766
|
+
setMessage({ tone: "success", text: "Chave removida." });
|
|
767
|
+
await onChanged("removed");
|
|
768
|
+
} catch (e) {
|
|
769
|
+
setMessage({
|
|
770
|
+
tone: "error",
|
|
771
|
+
text: e instanceof Error ? e.message : String(e)
|
|
772
|
+
});
|
|
773
|
+
} finally {
|
|
774
|
+
setBusy(null);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "dlf-item", children: [
|
|
778
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-item-row", children: [
|
|
779
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { minWidth: 0 }, children: [
|
|
780
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dlf-item-title", children: provider.label }),
|
|
781
|
+
provider.configured && provider.updatedAt ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "dlf-item-meta", children: [
|
|
782
|
+
"Chave terminada em",
|
|
783
|
+
" ",
|
|
784
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { translate: "no", style: { fontVariantNumeric: "tabular-nums" }, children: [
|
|
785
|
+
"\u2026",
|
|
786
|
+
provider.last4
|
|
787
|
+
] }),
|
|
788
|
+
" ",
|
|
789
|
+
"\xB7 salva em ",
|
|
790
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("time", { dateTime: provider.updatedAt, children: formatDateTime(provider.updatedAt, locale) })
|
|
791
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
792
|
+
provider.description && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dlf-item-meta", children: provider.description }),
|
|
793
|
+
provider.whenMissing && !compact && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dlf-item-meta", children: provider.whenMissing })
|
|
794
|
+
] })
|
|
795
|
+
] }),
|
|
796
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-actions", children: [
|
|
797
|
+
provider.configured ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Badge, { tone: "success", children: "Configurada" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Badge, { children: "Sem chave" }),
|
|
798
|
+
provider.configured && !editing && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
799
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { variant: "ghost", disabled: !!busy, onClick: () => setEditing(true), children: "Trocar" }),
|
|
800
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { variant: "ghost", loading: busy === "remove", disabled: !!busy, onClick: remove, children: "Remover" })
|
|
801
|
+
] })
|
|
802
|
+
] })
|
|
803
|
+
] }),
|
|
804
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: message.tone, children: message.text }),
|
|
805
|
+
editing && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
806
|
+
"form",
|
|
807
|
+
{
|
|
808
|
+
className: "dlf-field",
|
|
809
|
+
style: { gap: "0.75rem", maxWidth: "32rem" },
|
|
810
|
+
onSubmit: (e) => {
|
|
811
|
+
e.preventDefault();
|
|
812
|
+
void save();
|
|
813
|
+
},
|
|
814
|
+
children: [
|
|
815
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
816
|
+
Field,
|
|
817
|
+
{
|
|
818
|
+
label: provider.configured ? "Nova chave" : "Chave de API",
|
|
819
|
+
htmlFor: `${id}-chave`,
|
|
820
|
+
hint: "A chave \xE9 testada no provedor antes de salvar e fica criptografada. Ningu\xE9m consegue v\xEA-la depois, nem aqui.",
|
|
821
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
822
|
+
"input",
|
|
823
|
+
{
|
|
824
|
+
id: `${id}-chave`,
|
|
825
|
+
className: "dlf-input",
|
|
826
|
+
type: "password",
|
|
827
|
+
autoComplete: "off",
|
|
828
|
+
spellCheck: false,
|
|
829
|
+
maxLength: 500,
|
|
830
|
+
placeholder: "sk-\u2026",
|
|
831
|
+
value,
|
|
832
|
+
onChange: (e) => setValue(e.target.value)
|
|
833
|
+
}
|
|
834
|
+
)
|
|
835
|
+
}
|
|
836
|
+
),
|
|
837
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-actions", children: [
|
|
838
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { type: "submit", variant: "primary", loading: busy === "save", disabled: value.trim().length < 8, children: "Testar e salvar" }),
|
|
839
|
+
provider.configured && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { variant: "ghost", onClick: () => setEditing(false), children: "Cancelar" })
|
|
840
|
+
] })
|
|
841
|
+
]
|
|
842
|
+
}
|
|
843
|
+
),
|
|
844
|
+
children
|
|
845
|
+
] });
|
|
846
|
+
}
|
|
847
|
+
function ProviderKeys() {
|
|
848
|
+
const { client } = useStudio();
|
|
849
|
+
const list = useResource(() => client.credentials(), [client]);
|
|
850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
851
|
+
Section,
|
|
852
|
+
{
|
|
853
|
+
title: "Chave de IA",
|
|
854
|
+
description: "A conta do provedor de IA que esta empresa usa. O gasto do assistente, do bot e das automa\xE7\xF5es vai para ela, e a aba Custos mostra quanto.",
|
|
855
|
+
children: [
|
|
856
|
+
list.error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: list.error }),
|
|
857
|
+
list.loading && !list.data && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Loading, {}),
|
|
858
|
+
list.data && !list.data.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Empty, { title: "A aplica\xE7\xE3o n\xE3o usa chaves por empresa" }),
|
|
859
|
+
!!list.data?.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "dlf-list", children: list.data.map((p) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ProviderKey, { provider: p, onChanged: () => list.reload() }, p.name)) })
|
|
860
|
+
]
|
|
861
|
+
}
|
|
862
|
+
);
|
|
863
|
+
}
|
|
864
|
+
function ModelChooser({ overview, provider, onSaved, onCancel }) {
|
|
865
|
+
const { client } = useStudio();
|
|
866
|
+
const id = (0, import_react7.useId)();
|
|
867
|
+
const label = overview.providers.find((p) => p.name === provider)?.label ?? provider;
|
|
868
|
+
const list = useResource(() => client.availableModels(provider), [client, provider]);
|
|
869
|
+
const suggested = overview.providers.find((p) => p.name === provider)?.defaults ?? {};
|
|
870
|
+
const start = overview.chosen?.provider === provider ? overview.chosen.models : overview.active?.provider === provider ? overview.active.models : suggested;
|
|
871
|
+
const [models, setModels] = (0, import_react7.useState)(start);
|
|
872
|
+
const [saving, setSaving] = (0, import_react7.useState)(false);
|
|
873
|
+
const [error, setError] = (0, import_react7.useState)(null);
|
|
874
|
+
(0, import_react8.useEffect)(() => {
|
|
875
|
+
if (!list.data?.length) return;
|
|
876
|
+
const inList = (id2) => !!id2 && list.data.some((m) => m.id === id2);
|
|
877
|
+
setModels(
|
|
878
|
+
(current) => Object.fromEntries(overview.roles.map((r) => [r.name, inList(current[r.name]) ? current[r.name] : inList(suggested[r.name]) ? suggested[r.name] : list.data[0].id]))
|
|
879
|
+
);
|
|
880
|
+
}, [list.data, overview.roles]);
|
|
881
|
+
async function save() {
|
|
882
|
+
setSaving(true);
|
|
883
|
+
setError(null);
|
|
884
|
+
try {
|
|
885
|
+
await client.chooseModels({ provider, models });
|
|
886
|
+
await onSaved();
|
|
887
|
+
} catch (e) {
|
|
888
|
+
setError(e instanceof Error ? e.message : String(e));
|
|
889
|
+
} finally {
|
|
890
|
+
setSaving(false);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
894
|
+
"form",
|
|
895
|
+
{
|
|
896
|
+
className: "dlf-form",
|
|
897
|
+
"aria-label": `Modelos do ${label}`,
|
|
898
|
+
onSubmit: (e) => {
|
|
899
|
+
e.preventDefault();
|
|
900
|
+
void save();
|
|
901
|
+
},
|
|
902
|
+
children: [
|
|
903
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "dlf-item-title", children: [
|
|
904
|
+
"Usar ",
|
|
905
|
+
label
|
|
906
|
+
] }),
|
|
907
|
+
list.error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: list.error }),
|
|
908
|
+
list.loading && !list.data && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Loading, { label: "Buscando os modelos desta chave\u2026" }),
|
|
909
|
+
list.data && !list.data.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: "A chave n\xE3o enxerga nenhum modelo de texto neste provedor." }),
|
|
910
|
+
!!list.data?.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "dlf-row", children: overview.roles.map((role) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Field, { label: role.label, htmlFor: `${id}-${role.name}`, hint: role.description, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { id: `${id}-${role.name}`, className: "dlf-select", value: models[role.name] ?? "", onChange: (e) => setModels({ ...models, [role.name]: e.target.value }), children: list.data.map((m) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: m.id, children: m.label ? `${m.label} (${m.id})` : m.id }, m.id)) }) }, role.name)) }),
|
|
911
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: error }),
|
|
912
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-actions", children: [
|
|
913
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { type: "submit", variant: "primary", loading: saving, disabled: !list.data?.length, children: "Usar estes modelos" }),
|
|
914
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { variant: "ghost", onClick: onCancel, children: "Cancelar" })
|
|
915
|
+
] })
|
|
916
|
+
]
|
|
917
|
+
}
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
function ModelSettings() {
|
|
921
|
+
const { client } = useStudio();
|
|
922
|
+
const overview = useResource(() => client.models(), [client]);
|
|
923
|
+
const keys = useResource(() => client.credentials(), [client]);
|
|
924
|
+
const [choosing, setChoosing] = (0, import_react7.useState)(null);
|
|
925
|
+
const [message, setMessage] = (0, import_react7.useState)(null);
|
|
926
|
+
const refresh = async () => {
|
|
927
|
+
await Promise.all([overview.reload(), keys.reload()]);
|
|
928
|
+
};
|
|
929
|
+
const o = overview.data;
|
|
930
|
+
const labelOf = (name) => o?.providers.find((p) => p.name === name)?.label ?? name;
|
|
931
|
+
const roleLabel = (name) => o?.roles.find((r) => r.name === name)?.label ?? name;
|
|
932
|
+
async function reset() {
|
|
933
|
+
if (!window.confirm("Voltar ao autom\xE1tico? A empresa passa a usar a primeira chave cadastrada com os modelos sugeridos, ou a conta da plataforma.")) return;
|
|
934
|
+
try {
|
|
935
|
+
await client.resetModels();
|
|
936
|
+
setMessage({ tone: "success", text: "Voltou ao autom\xE1tico." });
|
|
937
|
+
await refresh();
|
|
938
|
+
} catch (e) {
|
|
939
|
+
setMessage({
|
|
940
|
+
tone: "error",
|
|
941
|
+
text: e instanceof Error ? e.message : String(e)
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
if (!o || !keys.data) {
|
|
946
|
+
const failure = overview.error ?? keys.error;
|
|
947
|
+
return failure ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: failure }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Loading, {});
|
|
948
|
+
}
|
|
949
|
+
const whenMissing = keys.data.find((k) => k.whenMissing)?.whenMissing;
|
|
950
|
+
const chosenKeySaved = !!o.chosen && !!keys.data.find((k) => k.name === o.chosen.provider)?.configured;
|
|
951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-stack", children: [
|
|
952
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
953
|
+
Section,
|
|
954
|
+
{
|
|
955
|
+
title: "Modelo de IA",
|
|
956
|
+
description: "Qual provedor de IA esta empresa usa, com a chave dela, e o modelo de cada parte do assistente. O gasto vai para a conta do provedor, e a aba Custos mostra quanto.",
|
|
957
|
+
children: [
|
|
958
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: message.tone, children: message.text }),
|
|
959
|
+
o.active ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-notice", children: [
|
|
960
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "dlf-item-title", children: [
|
|
961
|
+
"Em uso: ",
|
|
962
|
+
labelOf(o.active.provider),
|
|
963
|
+
" ",
|
|
964
|
+
o.active.source === "empresa" ? "(chave da empresa)" : "(conta de IA da plataforma)"
|
|
965
|
+
] }),
|
|
966
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("dl", { className: "dlf-dl", children: Object.entries(o.active.models).map(([role, model]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "contents" }, children: [
|
|
967
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("dt", { children: roleLabel(role) }),
|
|
968
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("dd", { translate: "no", children: model })
|
|
969
|
+
] }, role)) }),
|
|
970
|
+
o.chosen && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "dlf-actions", style: { marginTop: "0.75rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { variant: "ghost", onClick: reset, children: "Voltar ao autom\xE1tico" }) })
|
|
971
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Notice, { tone: "error", children: "Esta empresa est\xE1 sem IA: cadastre a chave de um provedor abaixo." }),
|
|
972
|
+
o.active?.source === "plataforma" && whenMissing && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "dlf-muted dlf-measure", children: whenMissing }),
|
|
973
|
+
o.chosen && !chosenKeySaved && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Notice, { tone: "error", children: [
|
|
974
|
+
"A chave do ",
|
|
975
|
+
labelOf(o.chosen.provider),
|
|
976
|
+
" foi removida: a empresa voltou para o que est\xE1 em uso acima."
|
|
977
|
+
] })
|
|
978
|
+
]
|
|
979
|
+
}
|
|
980
|
+
),
|
|
981
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Section, { title: "Provedores", description: "Cadastre a chave de um ou mais provedores e escolha qual usar.", children: [
|
|
982
|
+
!keys.data.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Empty, { title: "A aplica\xE7\xE3o n\xE3o usa chaves por empresa" }),
|
|
983
|
+
!!keys.data.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "dlf-list", children: keys.data.map((p) => {
|
|
984
|
+
const inUse = o.active?.source === "empresa" && o.active.provider === p.name;
|
|
985
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
986
|
+
ProviderKey,
|
|
987
|
+
{
|
|
988
|
+
provider: p,
|
|
989
|
+
compact: true,
|
|
990
|
+
onChanged: async (change) => {
|
|
991
|
+
await refresh();
|
|
992
|
+
if (change === "saved" && !inUse) setChoosing(p.name);
|
|
993
|
+
if (change === "removed" && choosing === p.name) setChoosing(null);
|
|
994
|
+
},
|
|
995
|
+
children: [
|
|
996
|
+
p.configured && choosing !== p.name && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "dlf-actions", children: [
|
|
997
|
+
inUse && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Badge, { tone: "accent", children: "Em uso" }),
|
|
998
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { variant: inUse ? "ghost" : "secondary", onClick: () => setChoosing(p.name), children: inUse ? "Trocar os modelos" : `Usar ${p.label}` })
|
|
999
|
+
] }),
|
|
1000
|
+
choosing === p.name && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1001
|
+
ModelChooser,
|
|
1002
|
+
{
|
|
1003
|
+
overview: o,
|
|
1004
|
+
provider: p.name,
|
|
1005
|
+
onCancel: () => setChoosing(null),
|
|
1006
|
+
onSaved: async () => {
|
|
1007
|
+
setChoosing(null);
|
|
1008
|
+
setMessage({
|
|
1009
|
+
tone: "success",
|
|
1010
|
+
text: `Pronto: esta empresa agora usa ${p.label}.`
|
|
1011
|
+
});
|
|
1012
|
+
await refresh();
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
)
|
|
1016
|
+
]
|
|
1017
|
+
},
|
|
1018
|
+
p.name
|
|
1019
|
+
);
|
|
1020
|
+
}) })
|
|
1021
|
+
] })
|
|
1022
|
+
] });
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// src/Knowledge.tsx
|
|
1026
|
+
var import_react9 = require("react");
|
|
1027
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
719
1028
|
function KnowledgeBase() {
|
|
720
1029
|
const { client, locale } = useStudio();
|
|
721
|
-
const ids = (0,
|
|
1030
|
+
const ids = (0, import_react9.useId)();
|
|
722
1031
|
const docs = useResource(() => client.knowledge(), [client]);
|
|
723
|
-
const [draft, setDraft] = (0,
|
|
724
|
-
const [saving, setSaving] = (0,
|
|
725
|
-
const [message, setMessage] = (0,
|
|
726
|
-
const [query, setQuery] = (0,
|
|
727
|
-
const [queryAudience, setQueryAudience] = (0,
|
|
728
|
-
const [hits, setHits] = (0,
|
|
729
|
-
const [searching, setSearching] = (0,
|
|
1032
|
+
const [draft, setDraft] = (0, import_react9.useState)(null);
|
|
1033
|
+
const [saving, setSaving] = (0, import_react9.useState)(null);
|
|
1034
|
+
const [message, setMessage] = (0, import_react9.useState)(null);
|
|
1035
|
+
const [query, setQuery] = (0, import_react9.useState)("");
|
|
1036
|
+
const [queryAudience, setQueryAudience] = (0, import_react9.useState)("all");
|
|
1037
|
+
const [hits, setHits] = (0, import_react9.useState)(null);
|
|
1038
|
+
const [searching, setSearching] = (0, import_react9.useState)(false);
|
|
730
1039
|
async function save() {
|
|
731
1040
|
if (!draft) return;
|
|
732
1041
|
setSaving("form");
|
|
@@ -767,34 +1076,34 @@ function KnowledgeBase() {
|
|
|
767
1076
|
setSearching(false);
|
|
768
1077
|
}
|
|
769
1078
|
}
|
|
770
|
-
return /* @__PURE__ */ (0,
|
|
771
|
-
/* @__PURE__ */ (0,
|
|
1079
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dlf-stack", children: [
|
|
1080
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
772
1081
|
Section,
|
|
773
1082
|
{
|
|
774
1083
|
title: "Base de conhecimento",
|
|
775
1084
|
description: "O que o assistente e o bot consultam antes de responder: perguntas frequentes, pol\xEDticas, explica\xE7\xF5es de produtos. Documentos internos nunca chegam ao bot de atendimento.",
|
|
776
|
-
actions: !draft && /* @__PURE__ */ (0,
|
|
1085
|
+
actions: !draft && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { onClick: () => setDraft({ title: "", content: "", audience: "internal", tags: [] }), disabled: !!saving, children: "Novo documento" }),
|
|
777
1086
|
children: [
|
|
778
|
-
message && /* @__PURE__ */ (0,
|
|
779
|
-
docs.error && /* @__PURE__ */ (0,
|
|
780
|
-
docs.loading && !docs.data && /* @__PURE__ */ (0,
|
|
781
|
-
docs.data && !docs.data.length && !draft && /* @__PURE__ */ (0,
|
|
782
|
-
!!docs.data?.length && /* @__PURE__ */ (0,
|
|
783
|
-
/* @__PURE__ */ (0,
|
|
784
|
-
/* @__PURE__ */ (0,
|
|
785
|
-
/* @__PURE__ */ (0,
|
|
1087
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Notice, { tone: message.tone, children: message.text }),
|
|
1088
|
+
docs.error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Notice, { tone: "error", children: docs.error }),
|
|
1089
|
+
docs.loading && !docs.data && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Loading, {}),
|
|
1090
|
+
docs.data && !docs.data.length && !draft && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Empty, { title: "Nenhum documento", children: "Comece pelas perguntas que os clientes mais fazem e pela pol\xEDtica de trocas e pagamentos." }),
|
|
1091
|
+
!!docs.data?.length && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "dlf-list", children: docs.data.map((doc) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { className: "dlf-item", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dlf-item-row", children: [
|
|
1092
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { minWidth: 0 }, children: [
|
|
1093
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dlf-item-title", children: doc.title }),
|
|
1094
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { className: "dlf-item-meta", children: [
|
|
786
1095
|
doc.content.length.toLocaleString(locale),
|
|
787
1096
|
" caracteres \xB7 atualizado em ",
|
|
788
|
-
/* @__PURE__ */ (0,
|
|
1097
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: doc.updatedAt, children: formatDateTime(doc.updatedAt, locale) })
|
|
789
1098
|
] })
|
|
790
1099
|
] }),
|
|
791
|
-
/* @__PURE__ */ (0,
|
|
792
|
-
doc.audience === "all" ? /* @__PURE__ */ (0,
|
|
793
|
-
/* @__PURE__ */ (0,
|
|
794
|
-
/* @__PURE__ */ (0,
|
|
1100
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dlf-actions", children: [
|
|
1101
|
+
doc.audience === "all" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Badge, { tone: "accent", children: "Equipe e clientes" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Badge, { children: "S\xF3 a equipe" }),
|
|
1102
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { variant: "ghost", disabled: !!saving, onClick: () => setDraft({ id: doc.id, title: doc.title, content: doc.content, audience: doc.audience, tags: doc.tags }), children: "Editar" }),
|
|
1103
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { variant: "ghost", loading: saving === doc.id, disabled: !!saving, onClick: () => remove(doc), children: "Excluir" })
|
|
795
1104
|
] })
|
|
796
1105
|
] }) }, doc.id)) }),
|
|
797
|
-
draft && /* @__PURE__ */ (0,
|
|
1106
|
+
draft && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
798
1107
|
"form",
|
|
799
1108
|
{
|
|
800
1109
|
className: "dlf-form",
|
|
@@ -804,28 +1113,28 @@ function KnowledgeBase() {
|
|
|
804
1113
|
void save();
|
|
805
1114
|
},
|
|
806
1115
|
children: [
|
|
807
|
-
/* @__PURE__ */ (0,
|
|
808
|
-
/* @__PURE__ */ (0,
|
|
809
|
-
/* @__PURE__ */ (0,
|
|
810
|
-
/* @__PURE__ */ (0,
|
|
811
|
-
/* @__PURE__ */ (0,
|
|
812
|
-
/* @__PURE__ */ (0,
|
|
813
|
-
/* @__PURE__ */ (0,
|
|
1116
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Field, { label: "T\xEDtulo", htmlFor: `${ids}-titulo`, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { id: `${ids}-titulo`, className: "dlf-input", required: true, maxLength: 200, autoComplete: "off", placeholder: "Ex.: Pol\xEDtica de trocas\u2026", value: draft.title, onChange: (e) => setDraft({ ...draft, title: e.target.value }) }) }),
|
|
1117
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Field, { label: "Conte\xFAdo", htmlFor: `${ids}-conteudo`, hint: "Texto simples. Separe assuntos em par\xE1grafos: a busca devolve o trecho mais relevante.", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("textarea", { id: `${ids}-conteudo`, className: "dlf-textarea", required: true, rows: 12, maxLength: 1e5, value: draft.content, onChange: (e) => setDraft({ ...draft, content: e.target.value }) }) }),
|
|
1118
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("fieldset", { className: "dlf-field", style: { border: 0, padding: 0, margin: 0 }, children: [
|
|
1119
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("legend", { className: "dlf-label", children: "Quem pode ler" }),
|
|
1120
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "dlf-choice", children: [
|
|
1121
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { type: "radio", name: `${ids}-publico`, checked: draft.audience === "internal", onChange: () => setDraft({ ...draft, audience: "internal" }) }),
|
|
1122
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
814
1123
|
"S\xF3 a equipe ",
|
|
815
|
-
/* @__PURE__ */ (0,
|
|
1124
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "dlf-muted", children: "(o assistente do painel)" })
|
|
816
1125
|
] })
|
|
817
1126
|
] }),
|
|
818
|
-
/* @__PURE__ */ (0,
|
|
819
|
-
/* @__PURE__ */ (0,
|
|
820
|
-
/* @__PURE__ */ (0,
|
|
1127
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "dlf-choice", children: [
|
|
1128
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { type: "radio", name: `${ids}-publico`, checked: draft.audience === "all", onChange: () => setDraft({ ...draft, audience: "all" }) }),
|
|
1129
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
821
1130
|
"Equipe e clientes ",
|
|
822
|
-
/* @__PURE__ */ (0,
|
|
1131
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "dlf-muted", children: "(o bot de atendimento tamb\xE9m usa nas respostas)" })
|
|
823
1132
|
] })
|
|
824
1133
|
] })
|
|
825
1134
|
] }),
|
|
826
|
-
/* @__PURE__ */ (0,
|
|
827
|
-
/* @__PURE__ */ (0,
|
|
828
|
-
/* @__PURE__ */ (0,
|
|
1135
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dlf-actions", children: [
|
|
1136
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { type: "submit", variant: "primary", loading: saving === "form", disabled: !draft.title.trim() || !draft.content.trim(), children: "Salvar documento" }),
|
|
1137
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { variant: "ghost", onClick: () => setDraft(null), children: "Cancelar" })
|
|
829
1138
|
] })
|
|
830
1139
|
]
|
|
831
1140
|
}
|
|
@@ -833,8 +1142,8 @@ function KnowledgeBase() {
|
|
|
833
1142
|
]
|
|
834
1143
|
}
|
|
835
1144
|
),
|
|
836
|
-
/* @__PURE__ */ (0,
|
|
837
|
-
/* @__PURE__ */ (0,
|
|
1145
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Section, { title: "Testar a busca", description: "Veja o que o assistente encontra para uma pergunta.", children: [
|
|
1146
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
838
1147
|
"form",
|
|
839
1148
|
{
|
|
840
1149
|
className: "dlf-row",
|
|
@@ -844,32 +1153,32 @@ function KnowledgeBase() {
|
|
|
844
1153
|
void search();
|
|
845
1154
|
},
|
|
846
1155
|
children: [
|
|
847
|
-
/* @__PURE__ */ (0,
|
|
848
|
-
/* @__PURE__ */ (0,
|
|
849
|
-
/* @__PURE__ */ (0,
|
|
850
|
-
/* @__PURE__ */ (0,
|
|
1156
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Field, { label: "Pergunta", htmlFor: `${ids}-busca`, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { id: `${ids}-busca`, className: "dlf-input", type: "search", autoComplete: "off", maxLength: 300, placeholder: "Ex.: qual o prazo para trocar?\u2026", value: query, onChange: (e) => setQuery(e.target.value) }) }),
|
|
1157
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Field, { label: "Como", htmlFor: `${ids}-como`, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("select", { id: `${ids}-como`, className: "dlf-select", value: queryAudience, onChange: (e) => setQueryAudience(e.target.value), children: [
|
|
1158
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "all", children: "O bot de atendimento veria" }),
|
|
1159
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "internal", children: "O assistente da equipe veria" })
|
|
851
1160
|
] }) }),
|
|
852
|
-
/* @__PURE__ */ (0,
|
|
1161
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { type: "submit", loading: searching, disabled: !query.trim(), children: "Buscar" }) })
|
|
853
1162
|
]
|
|
854
1163
|
}
|
|
855
1164
|
),
|
|
856
|
-
hits && !hits.length && /* @__PURE__ */ (0,
|
|
857
|
-
!!hits?.length && /* @__PURE__ */ (0,
|
|
858
|
-
/* @__PURE__ */ (0,
|
|
859
|
-
/* @__PURE__ */ (0,
|
|
1165
|
+
hits && !hits.length && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Empty, { title: "Nada encontrado", children: "Nesse caso o assistente diz que vai verificar, em vez de inventar." }),
|
|
1166
|
+
!!hits?.length && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "dlf-list", "aria-live": "polite", children: hits.map((h) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { className: "dlf-item", children: [
|
|
1167
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dlf-item-title", children: h.title }),
|
|
1168
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dlf-item-meta dlf-measure", style: { whiteSpace: "pre-line" }, children: h.excerpt.length > 600 ? `${h.excerpt.slice(0, 600)}\u2026` : h.excerpt })
|
|
860
1169
|
] }, h.docId)) })
|
|
861
1170
|
] })
|
|
862
1171
|
] });
|
|
863
1172
|
}
|
|
864
1173
|
|
|
865
1174
|
// src/Memory.tsx
|
|
866
|
-
var
|
|
867
|
-
var
|
|
1175
|
+
var import_react10 = require("react");
|
|
1176
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
868
1177
|
function FactList({ subject, emptyText }) {
|
|
869
1178
|
const { client, locale } = useStudio();
|
|
870
1179
|
const facts = useResource(() => client.facts(subject), [client, subject.type, subject.id]);
|
|
871
|
-
const [removing, setRemoving] = (0,
|
|
872
|
-
const [error, setError] = (0,
|
|
1180
|
+
const [removing, setRemoving] = (0, import_react10.useState)(null);
|
|
1181
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
873
1182
|
async function forget(fact) {
|
|
874
1183
|
if (!window.confirm(`Esquecer \u201C${fact.text}\u201D? O assistente deixa de usar isso nas pr\xF3ximas conversas.`)) return;
|
|
875
1184
|
setRemoving(fact.id);
|
|
@@ -883,35 +1192,35 @@ function FactList({ subject, emptyText }) {
|
|
|
883
1192
|
setRemoving(null);
|
|
884
1193
|
}
|
|
885
1194
|
}
|
|
886
|
-
if (facts.error) return /* @__PURE__ */ (0,
|
|
887
|
-
if (!facts.data) return /* @__PURE__ */ (0,
|
|
888
|
-
if (!facts.data.length) return /* @__PURE__ */ (0,
|
|
889
|
-
return /* @__PURE__ */ (0,
|
|
890
|
-
error && /* @__PURE__ */ (0,
|
|
891
|
-
/* @__PURE__ */ (0,
|
|
892
|
-
/* @__PURE__ */ (0,
|
|
893
|
-
/* @__PURE__ */ (0,
|
|
894
|
-
/* @__PURE__ */ (0,
|
|
895
|
-
/* @__PURE__ */ (0,
|
|
1195
|
+
if (facts.error) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Notice, { tone: "error", children: facts.error });
|
|
1196
|
+
if (!facts.data) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Loading, {});
|
|
1197
|
+
if (!facts.data.length) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Empty, { title: "Nada guardado", children: emptyText });
|
|
1198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1199
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Notice, { tone: "error", children: error }),
|
|
1200
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "dlf-list", children: facts.data.map((f) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { className: "dlf-item", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dlf-item-row", children: [
|
|
1201
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { minWidth: 0 }, children: [
|
|
1202
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dlf-item-title", style: { fontWeight: 400 }, children: f.text }),
|
|
1203
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { className: "dlf-item-meta", children: [
|
|
1204
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: f.createdAt, children: formatDateTime(f.createdAt, locale) }),
|
|
896
1205
|
f.createdBy?.name ? ` \xB7 por ${f.createdBy.name}` : f.createdBy?.type === "service" ? " \xB7 pelo bot" : ""
|
|
897
1206
|
] })
|
|
898
1207
|
] }),
|
|
899
|
-
/* @__PURE__ */ (0,
|
|
1208
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Button, { variant: "ghost", loading: removing === f.id, disabled: !!removing, onClick: () => forget(f), "aria-label": `Esquecer: ${f.text}`, children: "Esquecer" })
|
|
900
1209
|
] }) }, f.id)) })
|
|
901
1210
|
] });
|
|
902
1211
|
}
|
|
903
1212
|
function MemoryBrowser() {
|
|
904
1213
|
const { client, labels, locale } = useStudio();
|
|
905
1214
|
const subjects = useResource(() => client.factSubjects(), [client]);
|
|
906
|
-
const [open, setOpen] = (0,
|
|
1215
|
+
const [open, setOpen] = (0, import_react10.useState)(null);
|
|
907
1216
|
const typeLabel = (type) => labels.subjects?.[type] ?? type;
|
|
908
1217
|
if (open) {
|
|
909
|
-
return /* @__PURE__ */ (0,
|
|
1218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
910
1219
|
Section,
|
|
911
1220
|
{
|
|
912
1221
|
title: open.label ?? open.id,
|
|
913
1222
|
description: `${typeLabel(open.type)}. O que o assistente lembra nas pr\xF3ximas conversas. Esque\xE7a o que estiver errado ou n\xE3o deveria ser guardado.`,
|
|
914
|
-
actions: /* @__PURE__ */ (0,
|
|
1223
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
915
1224
|
Button,
|
|
916
1225
|
{
|
|
917
1226
|
variant: "ghost",
|
|
@@ -922,40 +1231,40 @@ function MemoryBrowser() {
|
|
|
922
1231
|
children: "Voltar para a lista"
|
|
923
1232
|
}
|
|
924
1233
|
),
|
|
925
|
-
children: /* @__PURE__ */ (0,
|
|
1234
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FactList, { subject: open, emptyText: "Tudo foi esquecido." })
|
|
926
1235
|
}
|
|
927
1236
|
);
|
|
928
1237
|
}
|
|
929
|
-
return /* @__PURE__ */ (0,
|
|
930
|
-
subjects.error && /* @__PURE__ */ (0,
|
|
931
|
-
subjects.loading && !subjects.data && /* @__PURE__ */ (0,
|
|
932
|
-
subjects.data && !subjects.data.length && /* @__PURE__ */ (0,
|
|
933
|
-
!!subjects.data?.length && /* @__PURE__ */ (0,
|
|
934
|
-
/* @__PURE__ */ (0,
|
|
935
|
-
/* @__PURE__ */ (0,
|
|
936
|
-
/* @__PURE__ */ (0,
|
|
937
|
-
/* @__PURE__ */ (0,
|
|
938
|
-
/* @__PURE__ */ (0,
|
|
1238
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Section, { title: "Mem\xF3ria", description: "O que o assistente e o bot guardaram sobre clientes e pessoas da equipe, de conversas anteriores.", children: [
|
|
1239
|
+
subjects.error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Notice, { tone: "error", children: subjects.error }),
|
|
1240
|
+
subjects.loading && !subjects.data && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Loading, {}),
|
|
1241
|
+
subjects.data && !subjects.data.length && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Empty, { title: "Nada guardado ainda", children: "O bot guarda o que o cliente conta (prefer\xEAncias, contexto) e o assistente guarda como cada pessoa gosta de trabalhar." }),
|
|
1242
|
+
!!subjects.data?.length && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "dlf-table-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("table", { className: "dlf-table", children: [
|
|
1243
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("tr", { children: [
|
|
1244
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { scope: "col", children: "Sobre" }),
|
|
1245
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { scope: "col", children: "Tipo" }),
|
|
1246
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { scope: "col", className: "dlf-num", children: "Fatos" }),
|
|
1247
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { scope: "col", children: "\xDAltimo" })
|
|
939
1248
|
] }) }),
|
|
940
|
-
/* @__PURE__ */ (0,
|
|
941
|
-
/* @__PURE__ */ (0,
|
|
942
|
-
/* @__PURE__ */ (0,
|
|
943
|
-
/* @__PURE__ */ (0,
|
|
944
|
-
/* @__PURE__ */ (0,
|
|
1249
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("tbody", { children: subjects.data.map((s) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("tr", { children: [
|
|
1250
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "dlf-link-button", onClick: () => setOpen(s), children: s.label ?? s.id }) }),
|
|
1251
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { children: typeLabel(s.type) }),
|
|
1252
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { className: "dlf-num", children: s.count }),
|
|
1253
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: s.lastAt, children: formatDateTime(s.lastAt, locale) }) })
|
|
945
1254
|
] }, `${s.type}:${s.id}`)) })
|
|
946
1255
|
] }) })
|
|
947
1256
|
] });
|
|
948
1257
|
}
|
|
949
1258
|
function MyMemory({ subject }) {
|
|
950
|
-
return /* @__PURE__ */ (0,
|
|
1259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Section, { title: "O que o assistente lembra de voc\xEA", description: "Prefer\xEAncias que voc\xEA pediu para ele guardar. Esque\xE7a o que n\xE3o valer mais.", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FactList, { subject, emptyText: 'Pe\xE7a ao assistente, por exemplo: "lembre que prefiro respostas curtas".' }) });
|
|
951
1260
|
}
|
|
952
1261
|
|
|
953
1262
|
// src/Studio.tsx
|
|
954
|
-
var
|
|
1263
|
+
var import_react12 = require("react");
|
|
955
1264
|
|
|
956
1265
|
// src/Usage.tsx
|
|
957
|
-
var
|
|
958
|
-
var
|
|
1266
|
+
var import_react11 = require("react");
|
|
1267
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
959
1268
|
var periodRange = (period) => {
|
|
960
1269
|
const now = /* @__PURE__ */ new Date();
|
|
961
1270
|
const monthStart = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
|
|
@@ -965,8 +1274,8 @@ var periodRange = (period) => {
|
|
|
965
1274
|
};
|
|
966
1275
|
function UsageReport() {
|
|
967
1276
|
const { client, labels, locale } = useStudio();
|
|
968
|
-
const ids = (0,
|
|
969
|
-
const [period, setPeriod] = (0,
|
|
1277
|
+
const ids = (0, import_react11.useId)();
|
|
1278
|
+
const [period, setPeriod] = (0, import_react11.useState)("month");
|
|
970
1279
|
const usage = useResource(() => client.usage(periodRange(period)), [client, period]);
|
|
971
1280
|
const data = usage.data;
|
|
972
1281
|
const money = (n) => formatMoney(n, data?.currency ?? null, locale);
|
|
@@ -974,41 +1283,41 @@ function UsageReport() {
|
|
|
974
1283
|
const channelLabel = (c) => labels.channels?.[c] ?? c;
|
|
975
1284
|
const maxDay = Math.max(...data?.byDay.map((d) => data.currency ? d.cost : d.inputTokens + d.outputTokens) ?? [0], 0);
|
|
976
1285
|
const used = data?.budget && period === "month" ? data.total.cost / data.budget.monthly : null;
|
|
977
|
-
return /* @__PURE__ */ (0,
|
|
1286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
978
1287
|
Section,
|
|
979
1288
|
{
|
|
980
1289
|
title: "Uso e custos",
|
|
981
1290
|
description: "Quanto o assistente, o bot e as automa\xE7\xF5es gastaram com IA.",
|
|
982
|
-
actions: /* @__PURE__ */ (0,
|
|
983
|
-
/* @__PURE__ */ (0,
|
|
984
|
-
/* @__PURE__ */ (0,
|
|
985
|
-
/* @__PURE__ */ (0,
|
|
1291
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "Per\xEDodo", htmlFor: `${ids}-periodo`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("select", { id: `${ids}-periodo`, className: "dlf-select", value: period, onChange: (e) => setPeriod(e.target.value), children: [
|
|
1292
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "month", children: "Este m\xEAs" }),
|
|
1293
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "last-month", children: "M\xEAs passado" }),
|
|
1294
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "7d", children: "\xDAltimos 7 dias" })
|
|
986
1295
|
] }) }),
|
|
987
1296
|
children: [
|
|
988
|
-
usage.error && /* @__PURE__ */ (0,
|
|
989
|
-
usage.loading && !data && /* @__PURE__ */ (0,
|
|
990
|
-
data && /* @__PURE__ */ (0,
|
|
991
|
-
/* @__PURE__ */ (0,
|
|
992
|
-
/* @__PURE__ */ (0,
|
|
993
|
-
/* @__PURE__ */ (0,
|
|
994
|
-
/* @__PURE__ */ (0,
|
|
1297
|
+
usage.error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Notice, { tone: "error", children: usage.error }),
|
|
1298
|
+
usage.loading && !data && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Loading, {}),
|
|
1299
|
+
data && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1300
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dl", { className: "dlf-stats", children: [
|
|
1301
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dlf-stat", children: [
|
|
1302
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: "Custo" }),
|
|
1303
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: data.currency ? money(data.total.cost) : "\u2014" })
|
|
995
1304
|
] }),
|
|
996
|
-
/* @__PURE__ */ (0,
|
|
997
|
-
/* @__PURE__ */ (0,
|
|
998
|
-
/* @__PURE__ */ (0,
|
|
1305
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dlf-stat", children: [
|
|
1306
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: "Conversas e tarefas" }),
|
|
1307
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: formatNumber(data.total.runs, locale) })
|
|
999
1308
|
] }),
|
|
1000
|
-
/* @__PURE__ */ (0,
|
|
1001
|
-
/* @__PURE__ */ (0,
|
|
1002
|
-
/* @__PURE__ */ (0,
|
|
1309
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dlf-stat", children: [
|
|
1310
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: "Tokens" }),
|
|
1311
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: tokens(data.total) })
|
|
1003
1312
|
] })
|
|
1004
1313
|
] }),
|
|
1005
|
-
!data.currency && /* @__PURE__ */ (0,
|
|
1006
|
-
data.total.unpricedCalls > 0 && data.currency && /* @__PURE__ */ (0,
|
|
1314
|
+
!data.currency && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dlf-muted", children: "Sem tabela de pre\xE7os configurada na aplica\xE7\xE3o: s\xF3 os tokens aparecem." }),
|
|
1315
|
+
data.total.unpricedCalls > 0 && data.currency && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { className: "dlf-muted", children: [
|
|
1007
1316
|
formatNumber(data.total.unpricedCalls, locale),
|
|
1008
1317
|
" chamadas usaram modelos sem pre\xE7o configurado e n\xE3o entram no custo."
|
|
1009
1318
|
] }),
|
|
1010
|
-
used !== null && data.budget && /* @__PURE__ */ (0,
|
|
1011
|
-
/* @__PURE__ */ (0,
|
|
1319
|
+
used !== null && data.budget && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dlf-field", children: [
|
|
1320
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { className: "dlf-muted", id: `${ids}-limite`, children: [
|
|
1012
1321
|
money(data.total.cost),
|
|
1013
1322
|
" de ",
|
|
1014
1323
|
money(data.budget.monthly),
|
|
@@ -1017,7 +1326,7 @@ function UsageReport() {
|
|
|
1017
1326
|
"%)",
|
|
1018
1327
|
used >= 1 ? ". Limite atingido: o assistente est\xE1 parado at\xE9 o m\xEAs virar ou o limite subir." : ""
|
|
1019
1328
|
] }),
|
|
1020
|
-
/* @__PURE__ */ (0,
|
|
1329
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1021
1330
|
"div",
|
|
1022
1331
|
{
|
|
1023
1332
|
className: used >= 1 ? "dlf-meter dlf-meter--over" : "dlf-meter",
|
|
@@ -1026,38 +1335,38 @@ function UsageReport() {
|
|
|
1026
1335
|
"aria-valuemin": 0,
|
|
1027
1336
|
"aria-valuemax": 100,
|
|
1028
1337
|
"aria-valuenow": Math.min(100, Math.round(used * 100)),
|
|
1029
|
-
children: /* @__PURE__ */ (0,
|
|
1338
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { style: { width: `${Math.min(100, used * 100)}%` } })
|
|
1030
1339
|
}
|
|
1031
1340
|
)
|
|
1032
1341
|
] }),
|
|
1033
|
-
!data.byDay.length ? /* @__PURE__ */ (0,
|
|
1034
|
-
/* @__PURE__ */ (0,
|
|
1035
|
-
/* @__PURE__ */ (0,
|
|
1036
|
-
/* @__PURE__ */ (0,
|
|
1342
|
+
!data.byDay.length ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Empty, { title: "Nenhum uso no per\xEDodo" }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1343
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
|
|
1344
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: "dlf-h3", style: { marginBottom: "0.5rem" }, children: "Por dia" }),
|
|
1345
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "dlf-bars", children: data.byDay.map((d) => {
|
|
1037
1346
|
const value = data.currency ? d.cost : d.inputTokens + d.outputTokens;
|
|
1038
|
-
return /* @__PURE__ */ (0,
|
|
1039
|
-
/* @__PURE__ */ (0,
|
|
1040
|
-
/* @__PURE__ */ (0,
|
|
1041
|
-
/* @__PURE__ */ (0,
|
|
1347
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { display: "contents" }, children: [
|
|
1348
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "dlf-muted", children: new Intl.DateTimeFormat(locale, { day: "2-digit", month: "2-digit", timeZone: "UTC" }).format(/* @__PURE__ */ new Date(`${d.day}T00:00:00Z`)) }),
|
|
1349
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "dlf-bar", style: { width: `${maxDay ? value / maxDay * 100 : 0}%` }, "aria-hidden": true }),
|
|
1350
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "dlf-num", children: data.currency ? money(d.cost) : tokens(d) })
|
|
1042
1351
|
] }, d.day);
|
|
1043
1352
|
}) })
|
|
1044
1353
|
] }),
|
|
1045
1354
|
[
|
|
1046
1355
|
["Por canal", data.byChannel.map((c) => ({ key: c.channel, label: channelLabel(c.channel), t: c }))],
|
|
1047
1356
|
["Por modelo", data.byModel.map((m) => ({ key: m.model, label: m.model.slice(m.model.indexOf(":") + 1), t: m }))]
|
|
1048
|
-
].map(([title, rows]) => /* @__PURE__ */ (0,
|
|
1049
|
-
/* @__PURE__ */ (0,
|
|
1050
|
-
/* @__PURE__ */ (0,
|
|
1051
|
-
/* @__PURE__ */ (0,
|
|
1052
|
-
/* @__PURE__ */ (0,
|
|
1053
|
-
/* @__PURE__ */ (0,
|
|
1054
|
-
data.currency && /* @__PURE__ */ (0,
|
|
1357
|
+
].map(([title, rows]) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "dlf-table-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("table", { className: "dlf-table", children: [
|
|
1358
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("caption", { className: "dlf-sr-only", children: title }),
|
|
1359
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("tr", { children: [
|
|
1360
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("th", { scope: "col", children: title }),
|
|
1361
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("th", { scope: "col", className: "dlf-num", children: "Execu\xE7\xF5es" }),
|
|
1362
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("th", { scope: "col", className: "dlf-num", children: "Tokens" }),
|
|
1363
|
+
data.currency && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("th", { scope: "col", className: "dlf-num", children: "Custo" })
|
|
1055
1364
|
] }) }),
|
|
1056
|
-
/* @__PURE__ */ (0,
|
|
1057
|
-
/* @__PURE__ */ (0,
|
|
1058
|
-
/* @__PURE__ */ (0,
|
|
1059
|
-
/* @__PURE__ */ (0,
|
|
1060
|
-
data.currency && /* @__PURE__ */ (0,
|
|
1365
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("tbody", { children: rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("tr", { children: [
|
|
1366
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("td", { children: r.label }),
|
|
1367
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("td", { className: "dlf-num", children: formatNumber(r.t.runs, locale) }),
|
|
1368
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("td", { className: "dlf-num", children: tokens(r.t) }),
|
|
1369
|
+
data.currency && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("td", { className: "dlf-num", children: money(r.t.cost) })
|
|
1061
1370
|
] }, r.key)) })
|
|
1062
1371
|
] }) }, title))
|
|
1063
1372
|
] })
|
|
@@ -1068,7 +1377,7 @@ function UsageReport() {
|
|
|
1068
1377
|
}
|
|
1069
1378
|
|
|
1070
1379
|
// src/Studio.tsx
|
|
1071
|
-
var
|
|
1380
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1072
1381
|
var LABELS = {
|
|
1073
1382
|
approvals: "Aprova\xE7\xF5es",
|
|
1074
1383
|
behavior: "Regras",
|
|
@@ -1076,12 +1385,13 @@ var LABELS = {
|
|
|
1076
1385
|
knowledge: "Conhecimento",
|
|
1077
1386
|
memory: "Mem\xF3ria",
|
|
1078
1387
|
usage: "Custos",
|
|
1388
|
+
keys: "Modelo de IA",
|
|
1079
1389
|
audit: "Auditoria"
|
|
1080
1390
|
};
|
|
1081
1391
|
function DolfinhosStudio({ sections, section, defaultSection, onSectionChange, currency, pendingApprovals, onPendingApprovalsChange }) {
|
|
1082
1392
|
const visible = sections ?? Object.keys(LABELS);
|
|
1083
|
-
const [own, setOwn] = (0,
|
|
1084
|
-
const [pending, setPending] = (0,
|
|
1393
|
+
const [own, setOwn] = (0, import_react12.useState)(defaultSection ?? visible[0]);
|
|
1394
|
+
const [pending, setPending] = (0, import_react12.useState)(pendingApprovals);
|
|
1085
1395
|
const current = section ?? own;
|
|
1086
1396
|
const select = (s) => {
|
|
1087
1397
|
setOwn(s);
|
|
@@ -1092,16 +1402,17 @@ function DolfinhosStudio({ sections, section, defaultSection, onSectionChange, c
|
|
|
1092
1402
|
onPendingApprovalsChange?.(n);
|
|
1093
1403
|
};
|
|
1094
1404
|
const panels = {
|
|
1095
|
-
approvals: () => /* @__PURE__ */ (0,
|
|
1096
|
-
behavior: () => /* @__PURE__ */ (0,
|
|
1097
|
-
automations: () => /* @__PURE__ */ (0,
|
|
1098
|
-
knowledge: () => /* @__PURE__ */ (0,
|
|
1099
|
-
memory: () => /* @__PURE__ */ (0,
|
|
1100
|
-
usage: () => /* @__PURE__ */ (0,
|
|
1101
|
-
|
|
1405
|
+
approvals: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ApprovalsInbox, { onCount }),
|
|
1406
|
+
behavior: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(BehaviorSettings, { currency: currency ?? null }),
|
|
1407
|
+
automations: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AutomationsEditor, {}),
|
|
1408
|
+
knowledge: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(KnowledgeBase, {}),
|
|
1409
|
+
memory: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MemoryBrowser, {}),
|
|
1410
|
+
usage: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(UsageReport, {}),
|
|
1411
|
+
keys: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ModelSettings, {}),
|
|
1412
|
+
audit: () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AuditLog, {})
|
|
1102
1413
|
};
|
|
1103
|
-
return /* @__PURE__ */ (0,
|
|
1104
|
-
/* @__PURE__ */ (0,
|
|
1414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dlf dlf-studio", children: [
|
|
1415
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1105
1416
|
Tabs,
|
|
1106
1417
|
{
|
|
1107
1418
|
label: "\xC1reas do assistente de IA",
|
|
@@ -1110,20 +1421,20 @@ function DolfinhosStudio({ sections, section, defaultSection, onSectionChange, c
|
|
|
1110
1421
|
tabs: visible.map((id) => ({ id, label: LABELS[id], ...id === "approvals" ? { count: pendingApprovals ?? pending ?? 0 } : {} }))
|
|
1111
1422
|
}
|
|
1112
1423
|
),
|
|
1113
|
-
/* @__PURE__ */ (0,
|
|
1424
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { role: "tabpanel", id: `dlf-panel-${current}`, "aria-labelledby": `dlf-tab-${current}`, tabIndex: 0, style: { outlineOffset: 4 }, children: panels[current]() })
|
|
1114
1425
|
] });
|
|
1115
1426
|
}
|
|
1116
1427
|
|
|
1117
1428
|
// src/index.tsx
|
|
1118
|
-
var
|
|
1429
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1119
1430
|
function StudioProvider({ children, endpoint, headers, fetch: fetch2, labels, locale = "pt-BR", navigate }) {
|
|
1120
|
-
const client = (0,
|
|
1431
|
+
const client = (0, import_react13.useMemo)(
|
|
1121
1432
|
() => createStudioClient({ ...endpoint ? { endpoint } : {}, ...headers ? { headers } : {}, ...fetch2 ? { fetch: fetch2 } : {} }),
|
|
1122
1433
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1123
1434
|
[endpoint]
|
|
1124
1435
|
);
|
|
1125
|
-
const value = (0,
|
|
1126
|
-
return /* @__PURE__ */ (0,
|
|
1436
|
+
const value = (0, import_react13.useMemo)(() => ({ client, labels: labels ?? {}, locale, ...navigate ? { navigate } : {} }), [client, labels, locale, navigate]);
|
|
1437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(StudioContextProvider, { value, children });
|
|
1127
1438
|
}
|
|
1128
1439
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1129
1440
|
0 && (module.exports = {
|
|
@@ -1134,7 +1445,9 @@ function StudioProvider({ children, endpoint, headers, fetch: fetch2, labels, lo
|
|
|
1134
1445
|
DolfinhosStudio,
|
|
1135
1446
|
KnowledgeBase,
|
|
1136
1447
|
MemoryBrowser,
|
|
1448
|
+
ModelSettings,
|
|
1137
1449
|
MyMemory,
|
|
1450
|
+
ProviderKeys,
|
|
1138
1451
|
StudioError,
|
|
1139
1452
|
StudioProvider,
|
|
1140
1453
|
UsageReport,
|