@smarter.sh/ui-chat 0.36.1 → 0.36.2-alpha.1
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/embed.js +4 -4
- package/dist/embed.js.map +1 -1
- package/dist/smarter-chat-library.es.js +87 -73
- package/dist/smarter-chat-library.es.js.map +1 -1
- package/dist/smarter-chat-library.umd.js +3 -3
- package/dist/smarter-chat-library.umd.js.map +1 -1
- package/dist/types/src/lib/messages.d.ts +10 -0
- package/package.json +1 -1
|
@@ -6775,7 +6775,7 @@ Af.displayName = "StatusList", Af.propTypes = {
|
|
|
6775
6775
|
}, process.env.NODE_ENV !== "production" && (kf.propTypes = Af.propTypes);
|
|
6776
6776
|
var jf = {
|
|
6777
6777
|
name: "@smarter.sh/ui-chat",
|
|
6778
|
-
version: "0.36.1",
|
|
6778
|
+
version: "0.36.2-alpha.1",
|
|
6779
6779
|
description: "chatbot React.js component for the https://smarter.sh declarative, plugin-based AI resource management platform.",
|
|
6780
6780
|
homepage: "https://smarter.sh",
|
|
6781
6781
|
type: "module",
|
|
@@ -6998,6 +6998,7 @@ var Bf = {
|
|
|
6998
6998
|
"buttonDiagram": "Diagrama",
|
|
6999
6999
|
"Show the diagram": "Mostrar el diagrama",
|
|
7000
7000
|
Diagram: "Diagrama",
|
|
7001
|
+
Image: "Imagen",
|
|
7001
7002
|
"Some example prompts to get you started:": "Algunos prompts de ejemplo para empezar:"
|
|
7002
7003
|
}
|
|
7003
7004
|
},
|
|
@@ -7047,6 +7048,7 @@ var Bf = {
|
|
|
7047
7048
|
"buttonDiagram": "Diagramme",
|
|
7048
7049
|
"Show the diagram": "Afficher le diagramme",
|
|
7049
7050
|
Diagram: "Diagramme",
|
|
7051
|
+
Image: "Image",
|
|
7050
7052
|
"Some example prompts to get you started:": "Quelques exemples de prompts pour commencer :"
|
|
7051
7053
|
}
|
|
7052
7054
|
},
|
|
@@ -7096,6 +7098,7 @@ var Bf = {
|
|
|
7096
7098
|
"buttonDiagram": "Diagrama",
|
|
7097
7099
|
"Show the diagram": "Mostrar o diagrama",
|
|
7098
7100
|
Diagram: "Diagrama",
|
|
7101
|
+
Image: "Imagem",
|
|
7099
7102
|
"Some example prompts to get you started:": "Alguns prompts de exemplo para você começar:"
|
|
7100
7103
|
}
|
|
7101
7104
|
}
|
|
@@ -38841,21 +38844,27 @@ var Sw = String.raw`(?:https?:\/\/|\/)[^\s)"]+`, Cw = String.raw`(?:${Sw}|data:i
|
|
|
38841
38844
|
function Aw(e, t) {
|
|
38842
38845
|
return `<a href="${e}" target="_blank" rel="noopener noreferrer">${t}</a>`;
|
|
38843
38846
|
}
|
|
38844
|
-
|
|
38845
|
-
|
|
38847
|
+
var jw = "smarter-chat-image";
|
|
38848
|
+
function Mw(e, t) {
|
|
38849
|
+
return `<img class="${jw}" src="${e}" alt="${t}" loading="lazy" referrerpolicy="no-referrer">`;
|
|
38846
38850
|
}
|
|
38847
|
-
function
|
|
38848
|
-
|
|
38851
|
+
function Nw(e) {
|
|
38852
|
+
if (!(e instanceof HTMLImageElement) || !e.classList.contains(jw)) return !1;
|
|
38853
|
+
let t = document.createElement("span");
|
|
38854
|
+
return t.className = "smarter-chat-image-unavailable", t.textContent = e.alt.trim() || ip("Image"), e.replaceWith(t), !0;
|
|
38849
38855
|
}
|
|
38850
|
-
function
|
|
38851
|
-
return e.
|
|
38856
|
+
function Pw(e) {
|
|
38857
|
+
return xw(e).replace(Dw, (e, t, n, r) => Aw(r, Mw(n, t))).replace(Ow, (e, t, n) => Fw(n, t)).replace(kw, (e, t, n) => Aw(n, t));
|
|
38852
38858
|
}
|
|
38853
|
-
|
|
38859
|
+
function Fw(e, t) {
|
|
38860
|
+
return e.startsWith("data:") ? Mw(e, t) : Aw(e, Mw(e, t));
|
|
38861
|
+
}
|
|
38862
|
+
var Iw = new nv({
|
|
38854
38863
|
gfm: !0,
|
|
38855
38864
|
breaks: !0,
|
|
38856
38865
|
async: !1
|
|
38857
38866
|
});
|
|
38858
|
-
|
|
38867
|
+
Iw.use(yw), Iw.use({ renderer: {
|
|
38859
38868
|
html({ text: e }) {
|
|
38860
38869
|
return xw(e);
|
|
38861
38870
|
},
|
|
@@ -38863,38 +38872,42 @@ Pw.use(yw), Pw.use({ renderer: {
|
|
|
38863
38872
|
let [n] = t;
|
|
38864
38873
|
if (t.length === 1 && n.type === "image") {
|
|
38865
38874
|
let { href: t, text: r } = n;
|
|
38866
|
-
if (Tw.test(e) && Ew.test(t)) return Aw(xw(e),
|
|
38875
|
+
if (Tw.test(e) && Ew.test(t)) return Aw(xw(e), Mw(xw(t), r));
|
|
38867
38876
|
}
|
|
38868
38877
|
let r = this.parser.parseInline(t);
|
|
38869
38878
|
return Tw.test(e) ? Aw(xw(e), r) : r;
|
|
38870
38879
|
},
|
|
38871
38880
|
image({ href: e, text: t }) {
|
|
38872
|
-
return Ew.test(e) ?
|
|
38881
|
+
return Ew.test(e) ? Fw(xw(e), t) : t;
|
|
38873
38882
|
},
|
|
38874
38883
|
code({ text: e, lang: t }) {
|
|
38875
38884
|
return km(e, t);
|
|
38876
38885
|
}
|
|
38877
38886
|
} });
|
|
38878
|
-
function
|
|
38887
|
+
function Lw(e) {
|
|
38879
38888
|
return ug.sanitize(e, {
|
|
38880
38889
|
ADD_TAGS: ["semantics", "annotation"],
|
|
38881
|
-
ADD_ATTR: [
|
|
38890
|
+
ADD_ATTR: [
|
|
38891
|
+
"target",
|
|
38892
|
+
"encoding",
|
|
38893
|
+
"referrerpolicy"
|
|
38894
|
+
]
|
|
38882
38895
|
});
|
|
38883
38896
|
}
|
|
38884
|
-
function
|
|
38885
|
-
let t =
|
|
38886
|
-
return
|
|
38897
|
+
function Rw(e) {
|
|
38898
|
+
let t = Iw.parse(e).trim(), n = /^<p>([\s\S]*)<\/p>$/.exec(t);
|
|
38899
|
+
return Lw(n && !n[1].includes("<p>") ? n[1] : t);
|
|
38887
38900
|
}
|
|
38888
|
-
function
|
|
38901
|
+
function zw(e) {
|
|
38889
38902
|
return e === Vf.USER ? Bf.OUTGOING : Bf.INCOMING;
|
|
38890
38903
|
}
|
|
38891
|
-
function
|
|
38892
|
-
return t === Vf.USER ?
|
|
38904
|
+
function Bw(e, t) {
|
|
38905
|
+
return t === Vf.USER ? Pw(e) : Rw(e);
|
|
38893
38906
|
}
|
|
38894
|
-
function
|
|
38907
|
+
function Vw(e, t, n, r = zw(t)) {
|
|
38895
38908
|
let i = typeof e == "string" && e !== "";
|
|
38896
38909
|
return {
|
|
38897
|
-
message: i ?
|
|
38910
|
+
message: i ? Bw(e, t) : "",
|
|
38898
38911
|
content: e ?? null,
|
|
38899
38912
|
direction: r,
|
|
38900
38913
|
sender: t,
|
|
@@ -38903,28 +38916,28 @@ function zw(e, t, n, r = Lw(t)) {
|
|
|
38903
38916
|
originalMessage: n
|
|
38904
38917
|
};
|
|
38905
38918
|
}
|
|
38906
|
-
function
|
|
38907
|
-
return (e ?? []).filter((e) => e && typeof e == "object" && typeof e.role == "string").map((e) =>
|
|
38919
|
+
function Hw(e) {
|
|
38920
|
+
return (e ?? []).filter((e) => e && typeof e == "object" && typeof e.role == "string").map((e) => Vw(e.content, e.role, e));
|
|
38908
38921
|
}
|
|
38909
|
-
function
|
|
38922
|
+
function Uw(e) {
|
|
38910
38923
|
return !e || e.length === 0 ? "" : ip("Some example prompts to get you started:") + "\n\n" + e.map((e) => `- ${e}\n`).join("");
|
|
38911
38924
|
}
|
|
38912
|
-
function
|
|
38913
|
-
let r = [
|
|
38914
|
-
return i && r.push(
|
|
38925
|
+
function Ww(e, t, n) {
|
|
38926
|
+
let r = [Vw(t, Vf.SYSTEM), Vw(e, Vf.ASSISTANT)], i = Uw(n);
|
|
38927
|
+
return i && r.push(Vw(i, Vf.ASSISTANT)), r;
|
|
38915
38928
|
}
|
|
38916
|
-
function
|
|
38917
|
-
let i =
|
|
38918
|
-
return i.length > 0 ? i :
|
|
38929
|
+
function Gw(e, t, n, r) {
|
|
38930
|
+
let i = Hw(r);
|
|
38931
|
+
return i.length > 0 ? i : Ww(e, t, n);
|
|
38919
38932
|
}
|
|
38920
|
-
function
|
|
38933
|
+
function Kw(e) {
|
|
38921
38934
|
return e.filter((e) => Hf.includes(e.sender)).map((e) => ({
|
|
38922
38935
|
...e.originalMessage,
|
|
38923
38936
|
role: e.sender,
|
|
38924
38937
|
content: e.content
|
|
38925
38938
|
}));
|
|
38926
38939
|
}
|
|
38927
|
-
function
|
|
38940
|
+
function qw(e, t, n) {
|
|
38928
38941
|
return e.map((e) => e.message ? {
|
|
38929
38942
|
...e,
|
|
38930
38943
|
display: !n.includes(e.sender) || t
|
|
@@ -38933,12 +38946,12 @@ function Gw(e, t, n) {
|
|
|
38933
38946
|
display: !1
|
|
38934
38947
|
});
|
|
38935
38948
|
}
|
|
38936
|
-
function
|
|
38949
|
+
function Jw(e) {
|
|
38937
38950
|
return e.replace(/<[^>]+>/g, "");
|
|
38938
38951
|
}
|
|
38939
38952
|
//#endregion
|
|
38940
38953
|
//#region src/components/AppTitle/Component.tsx
|
|
38941
|
-
function
|
|
38954
|
+
function Yw({ label: e, color: t, path: n }) {
|
|
38942
38955
|
return /* @__PURE__ */ d("svg", {
|
|
38943
38956
|
className: "smarter-chat-title-icon",
|
|
38944
38957
|
viewBox: "0 0 16 16",
|
|
@@ -38948,25 +38961,25 @@ function qw({ label: e, color: t, path: n }) {
|
|
|
38948
38961
|
children: [/* @__PURE__ */ u("title", { children: e }), /* @__PURE__ */ u("path", { d: n })]
|
|
38949
38962
|
});
|
|
38950
38963
|
}
|
|
38951
|
-
var
|
|
38952
|
-
function
|
|
38964
|
+
var Xw = "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z", Zw = "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293z", Qw = "M9.752 6.193c.599.6 1.73.437 2.528-.362s.96-1.932.362-2.531c-.599-.6-1.73-.438-2.528.361-.798.8-.96 1.933-.362 2.532M15.811 3.312c-.363 1.534-1.334 3.626-3.64 6.218l-.24 2.408a2.56 2.56 0 0 1-.732 1.526L8.817 15.85a.51.51 0 0 1-.867-.434l.27-1.899c.04-.28-.013-.593-.131-.956a9 9 0 0 0-.249-.657l-.082-.202c-.468-.07-.844-.393-1.162-.71-.319-.318-.64-.695-.71-1.163l-.202-.082a9 9 0 0 0-.657-.249c-.363-.118-.676-.172-.956-.131l-1.899.27a.51.51 0 0 1-.434-.867l2.391-2.391a2.56 2.56 0 0 1 1.526-.732l2.408-.24c2.592-2.306 4.684-3.277 6.218-3.64a.5.5 0 0 1 .6.6";
|
|
38965
|
+
function $w({ title: e, isReady: t, isValid: n, isDeployed: r }) {
|
|
38953
38966
|
return t ? /* @__PURE__ */ d("span", {
|
|
38954
38967
|
className: "smarter-chat-title",
|
|
38955
38968
|
children: [
|
|
38956
38969
|
e,
|
|
38957
|
-
n ? /* @__PURE__ */ u(
|
|
38970
|
+
n ? /* @__PURE__ */ u(Yw, {
|
|
38958
38971
|
label: ip("valid"),
|
|
38959
38972
|
color: "green",
|
|
38960
|
-
path:
|
|
38961
|
-
}) : /* @__PURE__ */ u(
|
|
38973
|
+
path: Xw
|
|
38974
|
+
}) : /* @__PURE__ */ u(Yw, {
|
|
38962
38975
|
label: ip("not valid"),
|
|
38963
38976
|
color: "red",
|
|
38964
|
-
path:
|
|
38977
|
+
path: Zw
|
|
38965
38978
|
}),
|
|
38966
|
-
r ? /* @__PURE__ */ u(
|
|
38979
|
+
r ? /* @__PURE__ */ u(Yw, {
|
|
38967
38980
|
label: ip("deployed"),
|
|
38968
38981
|
color: "orange",
|
|
38969
|
-
path:
|
|
38982
|
+
path: Qw
|
|
38970
38983
|
}) : /* @__PURE__ */ u("span", {
|
|
38971
38984
|
className: "smarter-chat-title-sandbox",
|
|
38972
38985
|
children: ip("(sandbox)")
|
|
@@ -38976,7 +38989,7 @@ function Zw({ title: e, isReady: t, isValid: n, isDeployed: r }) {
|
|
|
38976
38989
|
}
|
|
38977
38990
|
//#endregion
|
|
38978
38991
|
//#region src/components/AppTitle/index.tsx
|
|
38979
|
-
var
|
|
38992
|
+
var eT = $w, tT = class extends t {
|
|
38980
38993
|
state = { error: null };
|
|
38981
38994
|
static getDerivedStateFromError(e) {
|
|
38982
38995
|
return { error: e };
|
|
@@ -38994,7 +39007,7 @@ var Qw = Zw, $w = class extends t {
|
|
|
38994
39007
|
};
|
|
38995
39008
|
//#endregion
|
|
38996
39009
|
//#region src/components/SmarterChat/icons.tsx
|
|
38997
|
-
function
|
|
39010
|
+
function nT({ paths: e }) {
|
|
38998
39011
|
return /* @__PURE__ */ u("svg", {
|
|
38999
39012
|
viewBox: "0 0 16 16",
|
|
39000
39013
|
width: "1em",
|
|
@@ -39005,24 +39018,24 @@ function eT({ paths: e }) {
|
|
|
39005
39018
|
children: e.map((e) => /* @__PURE__ */ u("path", { d: e }, e))
|
|
39006
39019
|
});
|
|
39007
39020
|
}
|
|
39008
|
-
function
|
|
39009
|
-
return /* @__PURE__ */ u(
|
|
39021
|
+
function rT() {
|
|
39022
|
+
return /* @__PURE__ */ u(nT, { paths: ["M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z"] });
|
|
39010
39023
|
}
|
|
39011
|
-
function
|
|
39012
|
-
return /* @__PURE__ */ u(
|
|
39024
|
+
function iT() {
|
|
39025
|
+
return /* @__PURE__ */ u(nT, { paths: ["M1 0 0 1l2.2 3.081a1 1 0 0 0 .815.419h.07a1 1 0 0 1 .708.293l2.675 2.675-2.617 2.654A3.003 3.003 0 0 0 0 13a3 3 0 1 0 5.878-.851l2.654-2.617.968.968-.305.914a1 1 0 0 0 .242 1.023l3.27 3.27a.997.997 0 0 0 1.414 0l1.586-1.586a.997.997 0 0 0 0-1.414l-3.27-3.27a1 1 0 0 0-1.023-.242L10.5 9.5l-.96-.96 2.68-2.643A3.005 3.005 0 0 0 16 3q0-.405-.102-.777l-2.14 2.141L12 4l-.364-1.757L13.777.102a3 3 0 0 0-3.675 3.68L7.462 6.46 4.793 3.793a1 1 0 0 1-.293-.707v-.071a1 1 0 0 0-.419-.814zm9.646 10.646a.5.5 0 0 1 .708 0l2.914 2.915a.5.5 0 0 1-.707.707l-2.915-2.914a.5.5 0 0 1 0-.708M3 11l.471.242.529.026.287.445.445.287.026.529L5 13l-.242.471-.026.529-.445.287-.287.445-.529.026L3 15l-.471-.242L2 14.732l-.287-.445L1.268 14l-.026-.529L1 13l.242-.471.026-.529.445-.287.287-.445.529-.026z"] });
|
|
39013
39026
|
}
|
|
39014
|
-
function
|
|
39015
|
-
return /* @__PURE__ */ u(
|
|
39027
|
+
function aT() {
|
|
39028
|
+
return /* @__PURE__ */ u(nT, { paths: ["M5.338 1.59a61 61 0 0 0-2.837.856.48.48 0 0 0-.328.39c-.554 4.157.726 7.19 2.253 9.188a10.7 10.7 0 0 0 2.287 2.233c.346.244.652.42.893.533q.18.085.293.118a1 1 0 0 0 .101.025 1 1 0 0 0 .1-.025q.114-.034.294-.118c.24-.113.547-.29.893-.533a10.7 10.7 0 0 0 2.287-2.233c1.527-1.997 2.807-5.031 2.253-9.188a.48.48 0 0 0-.328-.39c-.651-.213-1.75-.56-2.837-.855C9.552 1.29 8.531 1.067 8 1.067c-.53 0-1.552.223-2.662.524zM5.072.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.596 4.477-.787 7.795-2.465 9.99a11.8 11.8 0 0 1-2.517 2.453 7 7 0 0 1-1.048.625c-.28.132-.581.24-.829.24s-.548-.108-.829-.24a7 7 0 0 1-1.048-.625 11.8 11.8 0 0 1-2.517-2.453C1.928 10.487.545 7.169 1.141 2.692A1.54 1.54 0 0 1 2.185 1.43 63 63 0 0 1 5.072.56", "M10.854 5.146a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7.5 7.793l2.646-2.647a.5.5 0 0 1 .708 0"] });
|
|
39016
39029
|
}
|
|
39017
39030
|
//#endregion
|
|
39018
39031
|
//#region src/components/SmarterChat/Component.tsx
|
|
39019
|
-
function
|
|
39032
|
+
function oT(e) {
|
|
39020
39033
|
return e === Vf.SMARTER ? "smarter-message" : e === Vf.SMARTER_ERROR ? "smarter-error-message" : e === Vf.TOOL || e === Vf.SYSTEM ? "system-message" : "";
|
|
39021
39034
|
}
|
|
39022
|
-
function
|
|
39023
|
-
return
|
|
39035
|
+
function sT(e) {
|
|
39036
|
+
return Vw(e.message, Vf.SMARTER).message;
|
|
39024
39037
|
}
|
|
39025
|
-
function
|
|
39038
|
+
function cT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieName: a = "csrftoken", csrftoken: f = null, debugCookieName: p = "debug", debugCookieExpiration: m = Ff, debugMode: h = !1, sessionCookieName: g = "session_key", sessionCookieExpiration: _ = Ff, cookiePath: v = null, cookieDomain: y = "", smarterRequestId: b = "", streamProgress: x = !0, language: S = null, verbose: C = !1, reloadKey: w, headerActions: T = null, onConfig: E, onNewChat: D, onModeChange: O }) {
|
|
39026
39039
|
let k = $f(S), [A, ee] = l(null), [j, te] = l(null), [M, N] = l([]), [P, ne] = l(n), [re, ie] = l(!1), [ae, oe] = l([]), [se, ce] = l(/* @__PURE__ */ new Set()), le = c(null), ue = c(null), [de, fe] = l(!1), pe = c(0), me = s(() => ({
|
|
39027
39040
|
csrfCookie: zf(a, null, y, f),
|
|
39028
39041
|
sessionCookie: zf(g, _, y, null, v),
|
|
@@ -39071,8 +39084,8 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39071
39084
|
let ye = r(async () => {
|
|
39072
39085
|
try {
|
|
39073
39086
|
te(null);
|
|
39074
|
-
let e = await _e(), t = e.llmclient, r =
|
|
39075
|
-
N(
|
|
39087
|
+
let e = await _e(), t = e.llmclient, r = Gw(t.app_welcome_message ?? "", t.default_system_role ?? "", t.app_example_prompts, e.history?.chat_history);
|
|
39088
|
+
N(qw(r, n, Uf)), ne(n), ie(!1), ge("chat started", e);
|
|
39076
39089
|
} catch (e) {
|
|
39077
39090
|
console.error(`${Pf} Failed to fetch the configuration:`, e), te(e instanceof Error ? e.message : String(e));
|
|
39078
39091
|
}
|
|
@@ -39091,6 +39104,7 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39091
39104
|
return e?.addEventListener("click", t), () => e?.removeEventListener("click", t);
|
|
39092
39105
|
}, []), i(() => {
|
|
39093
39106
|
let e = ue.current, t = (e) => {
|
|
39107
|
+
if (Nw(e.target)) return;
|
|
39094
39108
|
let t = e.target;
|
|
39095
39109
|
if (!(t instanceof HTMLImageElement) || !t.closest(".cs-avatar")) return;
|
|
39096
39110
|
let n = t.getAttribute("src") ?? "";
|
|
@@ -39103,18 +39117,18 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39103
39117
|
let be = () => {
|
|
39104
39118
|
Rf(me.sessionCookie, ""), ee(null), D?.(), ye();
|
|
39105
39119
|
}, xe = (e) => {
|
|
39106
|
-
e !== P && (ne(e), N((t) =>
|
|
39120
|
+
e !== P && (ne(e), N((t) => qw(t, e, Uf)));
|
|
39107
39121
|
};
|
|
39108
39122
|
async function Se(e) {
|
|
39109
39123
|
if (!A) return;
|
|
39110
|
-
let t = [...M,
|
|
39124
|
+
let t = [...M, Vw(e, Vf.USER)];
|
|
39111
39125
|
N(t), ie(!0), oe([]);
|
|
39112
39126
|
let n = x ? (e) => {
|
|
39113
39127
|
ge("prompt progress", e), oe((t) => [...t, e]);
|
|
39114
39128
|
} : void 0;
|
|
39115
39129
|
try {
|
|
39116
|
-
let e = await jp(A,
|
|
39117
|
-
let t =
|
|
39130
|
+
let e = await jp(A, Kw(t), me, he, n), r = e.messages.map((e) => {
|
|
39131
|
+
let t = Vw(e.content, e.role, e);
|
|
39118
39132
|
return Uf.includes(t.sender) && !P ? {
|
|
39119
39133
|
...t,
|
|
39120
39134
|
display: !1
|
|
@@ -39124,13 +39138,13 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39124
39138
|
} catch (e) {
|
|
39125
39139
|
console.error(`${Pf} Prompt failed:`, e);
|
|
39126
39140
|
let t = e instanceof Error ? e.message : String(e);
|
|
39127
|
-
N((e) => [...e,
|
|
39141
|
+
N((e) => [...e, Vw(t, Vf.SMARTER_ERROR)]);
|
|
39128
39142
|
} finally {
|
|
39129
39143
|
ie(!1), oe([]);
|
|
39130
39144
|
}
|
|
39131
39145
|
}
|
|
39132
39146
|
let we = (e, t, n) => {
|
|
39133
|
-
let r = n ?? t ??
|
|
39147
|
+
let r = n ?? t ?? Jw(e);
|
|
39134
39148
|
r.trim() && Se(r);
|
|
39135
39149
|
}, Te = (e) => {
|
|
39136
39150
|
let t = e.target.files?.[0];
|
|
@@ -39160,7 +39174,7 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39160
39174
|
assistant: ze,
|
|
39161
39175
|
step: Ve
|
|
39162
39176
|
}) : sp(ip("%(assistant)s is typing"), { assistant: ze }), Ue;
|
|
39163
|
-
return Ue = j ? ip("Smarter Chat is not available") : De ? /* @__PURE__ */ u(
|
|
39177
|
+
return Ue = j ? ip("Smarter Chat is not available") : De ? /* @__PURE__ */ u(eT, {
|
|
39164
39178
|
title: Pe,
|
|
39165
39179
|
isReady: De,
|
|
39166
39180
|
isValid: Le,
|
|
@@ -39178,7 +39192,7 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39178
39192
|
children: /* @__PURE__ */ d("div", {
|
|
39179
39193
|
className: "chat-app",
|
|
39180
39194
|
ref: ue,
|
|
39181
|
-
children: [/* @__PURE__ */ u(
|
|
39195
|
+
children: [/* @__PURE__ */ u(tT, { children: /* @__PURE__ */ u(qd, {
|
|
39182
39196
|
style: {
|
|
39183
39197
|
width: "100%",
|
|
39184
39198
|
height: "100%"
|
|
@@ -39203,7 +39217,7 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39203
39217
|
className: "smarter-chat-mode-toggle",
|
|
39204
39218
|
children: [/* @__PURE__ */ u(Ge, {
|
|
39205
39219
|
className: "smarter-chat-toolbar-button smarter-chat-mode-option",
|
|
39206
|
-
icon: /* @__PURE__ */ u(
|
|
39220
|
+
icon: /* @__PURE__ */ u(iT, {}),
|
|
39207
39221
|
"aria-pressed": P,
|
|
39208
39222
|
onClick: () => xe(!0),
|
|
39209
39223
|
title: ip("Sandbox mode: Smarter's system, tool and meta data messages are displayed."),
|
|
@@ -39213,7 +39227,7 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39213
39227
|
})
|
|
39214
39228
|
}), /* @__PURE__ */ u(Ge, {
|
|
39215
39229
|
className: "smarter-chat-toolbar-button smarter-chat-mode-option",
|
|
39216
|
-
icon: /* @__PURE__ */ u(
|
|
39230
|
+
icon: /* @__PURE__ */ u(aT, {}),
|
|
39217
39231
|
"aria-pressed": !P,
|
|
39218
39232
|
onClick: () => xe(!1),
|
|
39219
39233
|
title: ip("Production mode: the conversation is displayed as its users see it."),
|
|
@@ -39225,7 +39239,7 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39225
39239
|
}),
|
|
39226
39240
|
/* @__PURE__ */ u(Ge, {
|
|
39227
39241
|
className: "smarter-chat-toolbar-button",
|
|
39228
|
-
icon: /* @__PURE__ */ u(
|
|
39242
|
+
icon: /* @__PURE__ */ u(rT, {}),
|
|
39229
39243
|
onClick: be,
|
|
39230
39244
|
title: ip("Start a new chat"),
|
|
39231
39245
|
"aria-label": ip("Start a new chat")
|
|
@@ -39241,14 +39255,14 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39241
39255
|
j && /* @__PURE__ */ u(sl, {
|
|
39242
39256
|
className: "smarter-error-message",
|
|
39243
39257
|
model: {
|
|
39244
|
-
message:
|
|
39258
|
+
message: Vw(j, Vf.SMARTER_ERROR).message,
|
|
39245
39259
|
direction: "incoming",
|
|
39246
39260
|
position: "single",
|
|
39247
39261
|
sender: Vf.SMARTER_ERROR
|
|
39248
39262
|
}
|
|
39249
39263
|
}),
|
|
39250
39264
|
M.map((e, t) => e.display ? /* @__PURE__ */ u(sl, {
|
|
39251
|
-
className:
|
|
39265
|
+
className: oT(e.sender),
|
|
39252
39266
|
model: {
|
|
39253
39267
|
message: e.message,
|
|
39254
39268
|
sentTime: e.sentTime,
|
|
@@ -39261,7 +39275,7 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39261
39275
|
P && ae.map((e, t) => /* @__PURE__ */ u(sl, {
|
|
39262
39276
|
className: `smarter-progress-message ${t === ae.length - 1 ? "smarter-progress-message-active" : "smarter-progress-message-done"}`,
|
|
39263
39277
|
model: {
|
|
39264
|
-
message:
|
|
39278
|
+
message: sT(e),
|
|
39265
39279
|
sender: Vf.SMARTER,
|
|
39266
39280
|
direction: "incoming",
|
|
39267
39281
|
position: "single"
|
|
@@ -39295,7 +39309,7 @@ function oT({ apiUrl: e, apiKey: t = null, toggleMetadata: n = !1, csrfCookieNam
|
|
|
39295
39309
|
}
|
|
39296
39310
|
//#endregion
|
|
39297
39311
|
//#region src/components/SmarterChat/HeaderButton.tsx
|
|
39298
|
-
function
|
|
39312
|
+
function lT({ className: e = "", icon: t, children: n, ...r }) {
|
|
39299
39313
|
return /* @__PURE__ */ u(Ge, {
|
|
39300
39314
|
className: [
|
|
39301
39315
|
"smarter-chat-toolbar-button",
|
|
@@ -39312,8 +39326,8 @@ function sT({ className: e = "", icon: t, children: n, ...r }) {
|
|
|
39312
39326
|
}
|
|
39313
39327
|
//#endregion
|
|
39314
39328
|
//#region src/components/SmarterChat/index.tsx
|
|
39315
|
-
var
|
|
39329
|
+
var uT = cT;
|
|
39316
39330
|
//#endregion
|
|
39317
|
-
export { up as CHAT_CONTRACT_V2_CAPABILITY,
|
|
39331
|
+
export { up as CHAT_CONTRACT_V2_CAPABILITY, lT as HeaderButton, Bf as MessageDirectionEnum, Vf as SenderRoleEnum, uT as SmarterChat, Hf as ValidMessageRolesEnum, _p as normalizeConfig, Nf as version };
|
|
39318
39332
|
|
|
39319
39333
|
//# sourceMappingURL=smarter-chat-library.es.js.map
|