@chatsystem/client 1.1.34 → 1.1.35
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 +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +30 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3927,6 +3927,9 @@ const hf = "languageSettings", mf = (e, t) => {
|
|
|
3927
3927
|
}), Hs = Pe.createContext({
|
|
3928
3928
|
conversation: [],
|
|
3929
3929
|
setConversation: () => {
|
|
3930
|
+
},
|
|
3931
|
+
discussionId: null,
|
|
3932
|
+
setDiscussionId: () => {
|
|
3930
3933
|
}
|
|
3931
3934
|
});
|
|
3932
3935
|
var Mt = {}, Fi;
|
|
@@ -4036,25 +4039,27 @@ const _f = ({
|
|
|
4036
4039
|
), i = {
|
|
4037
4040
|
companySettings: r,
|
|
4038
4041
|
setCompanySettings: a
|
|
4039
|
-
}, [u, o] = Ae([]), l = {
|
|
4042
|
+
}, [u, o] = Ae([]), [l, c] = Ae(null), f = {
|
|
4040
4043
|
conversation: u,
|
|
4041
|
-
setConversation: o
|
|
4044
|
+
setConversation: o,
|
|
4045
|
+
discussionId: l,
|
|
4046
|
+
setDiscussionId: c
|
|
4042
4047
|
};
|
|
4043
4048
|
return ve(() => {
|
|
4044
|
-
const
|
|
4049
|
+
const d = wn.getApiUrl(), h = wn.getFetchConfig({
|
|
4045
4050
|
httpVerb: "GET",
|
|
4046
4051
|
contentType: "application/json"
|
|
4047
4052
|
});
|
|
4048
|
-
fetch(`${
|
|
4049
|
-
const
|
|
4050
|
-
a(
|
|
4053
|
+
fetch(`${d}/company/settings/${t}/${e}`, h).then(async (m) => {
|
|
4054
|
+
const _ = await m.json();
|
|
4055
|
+
a(_), o([
|
|
4051
4056
|
{
|
|
4052
4057
|
userType: "assistant",
|
|
4053
|
-
content:
|
|
4058
|
+
content: _.agent.text.initialText
|
|
4054
4059
|
}
|
|
4055
4060
|
]), n?.();
|
|
4056
|
-
}).catch((
|
|
4057
|
-
}, [t, e]), { contextCompanySettings: i, contextInitialChatbotStartingText:
|
|
4061
|
+
}).catch((m) => console.log("error in settings fetch", m));
|
|
4062
|
+
}, [t, e]), { contextCompanySettings: i, contextInitialChatbotStartingText: f };
|
|
4058
4063
|
};
|
|
4059
4064
|
function yf(e, t = {}, n, r) {
|
|
4060
4065
|
const { id: a, nonce: i, target: u, disableConstructable: o } = t, l = u ?? document.head, c = Oe(null), f = Oe(null);
|
|
@@ -19436,16 +19441,14 @@ const Ol = ({
|
|
|
19436
19441
|
genericErrorTranslation: a,
|
|
19437
19442
|
tooManyRequestsTranslation: i,
|
|
19438
19443
|
conflictErrorTranslation: u
|
|
19439
|
-
} = Ka(), { conversation: o, setConversation: l } = rt(
|
|
19440
|
-
Hs
|
|
19441
|
-
), [c, f] = Ae("notLoading"), [d, h] = Ae(null), { defaultStartingStep: m } = Nl(), [_, A] = Ae(
|
|
19444
|
+
} = Ka(), { conversation: o, setConversation: l, discussionId: c, setDiscussionId: f } = rt(Hs), [d, h] = Ae("notLoading"), { defaultStartingStep: m } = Nl(), [_, A] = Ae(
|
|
19442
19445
|
null
|
|
19443
19446
|
), [L, S] = Ae(
|
|
19444
19447
|
m
|
|
19445
19448
|
), [R, O] = Ae(
|
|
19446
19449
|
null
|
|
19447
19450
|
), { companySettings: M } = rt(Yn), { appCurrentLang: x } = rt(Fs), X = {
|
|
19448
|
-
...
|
|
19451
|
+
...d !== "notLoading" || (o?.length ?? 0) > 0 ? {
|
|
19449
19452
|
maxHeight: "100vh"
|
|
19450
19453
|
//TODO overridable with custom css
|
|
19451
19454
|
} : {
|
|
@@ -19463,7 +19466,7 @@ const Ol = ({
|
|
|
19463
19466
|
{ content: ue, userType: pe, metaData: De }
|
|
19464
19467
|
]);
|
|
19465
19468
|
}, Y = () => {
|
|
19466
|
-
ir.abort("cancelling"), console.log("Stream request aborted"),
|
|
19469
|
+
ir.abort("cancelling"), console.log("Stream request aborted"), h("notLoading"), l(
|
|
19467
19470
|
(ue) => ue.filter(
|
|
19468
19471
|
(pe) => !(pe.content?.length === 0 && pe.userType === "assistant")
|
|
19469
19472
|
)
|
|
@@ -19471,11 +19474,11 @@ const Ol = ({
|
|
|
19471
19474
|
}, { resetDiscussion: K } = jf({
|
|
19472
19475
|
companySettings: M,
|
|
19473
19476
|
setConversation: l,
|
|
19474
|
-
setDiscussionId:
|
|
19477
|
+
setDiscussionId: f
|
|
19475
19478
|
});
|
|
19476
19479
|
console.log("conversation", o);
|
|
19477
19480
|
const de = async (ue) => {
|
|
19478
|
-
|
|
19481
|
+
h("loadingIntermediaryStates");
|
|
19479
19482
|
const pe = wn.getApiUrl(), De = {
|
|
19480
19483
|
query: ue,
|
|
19481
19484
|
language: x.locale
|
|
@@ -19488,7 +19491,7 @@ const Ol = ({
|
|
|
19488
19491
|
}
|
|
19489
19492
|
]), requestAnimationFrame(
|
|
19490
19493
|
() => ne({ smooth: !1, sticky: !1 })
|
|
19491
|
-
),
|
|
19494
|
+
), c && (De.discussionId = c);
|
|
19492
19495
|
const p = ir.signal, F = wn.getFetchConfig({
|
|
19493
19496
|
httpVerb: "POST",
|
|
19494
19497
|
body: De,
|
|
@@ -19501,12 +19504,12 @@ const Ol = ({
|
|
|
19501
19504
|
const g = G?.body?.getReader(), q = new TextDecoder();
|
|
19502
19505
|
let Q = "", j = "", Z = !1, J = !1, ee = null;
|
|
19503
19506
|
const re = G.headers.get("discussionId");
|
|
19504
|
-
|
|
19507
|
+
f(parseInt(re, 10)), await new ReadableStream({
|
|
19505
19508
|
start(H) {
|
|
19506
19509
|
return ke();
|
|
19507
19510
|
async function ke() {
|
|
19508
19511
|
if (!G.ok) {
|
|
19509
|
-
|
|
19512
|
+
h("notLoading");
|
|
19510
19513
|
let Fe = a;
|
|
19511
19514
|
G.status === 409 ? Fe = u : G.status === 429 ? Fe = i : (G.status, Fe = a), l((Xe) => (Xe.pop(), Xe)), $(Fe, "assistant", {
|
|
19512
19515
|
isErrorMessage: !0
|
|
@@ -19517,7 +19520,7 @@ const Ol = ({
|
|
|
19517
19520
|
const { done: Xe, value: vt } = Fe, Ge = q.decode(vt), Pt = Zt.transformStringifiedObjectIntoArrayOfObjects(
|
|
19518
19521
|
Ge
|
|
19519
19522
|
);
|
|
19520
|
-
Zt.containsObjectWithLastAnswerToTrue(Pt) &&
|
|
19523
|
+
Zt.containsObjectWithLastAnswerToTrue(Pt) && h("loadingFinalAnswer");
|
|
19521
19524
|
for (const ie of Pt)
|
|
19522
19525
|
if (Zt.isObjectOutputstreamTextDTO(ie)) {
|
|
19523
19526
|
const {
|
|
@@ -19554,7 +19557,7 @@ const Ol = ({
|
|
|
19554
19557
|
} else
|
|
19555
19558
|
console.warn(`Object not handled - ${ie}`);
|
|
19556
19559
|
if (Xe && J) {
|
|
19557
|
-
H.close(),
|
|
19560
|
+
H.close(), h("notLoading"), S(m), O(null);
|
|
19558
19561
|
return;
|
|
19559
19562
|
}
|
|
19560
19563
|
return ke();
|
|
@@ -19563,7 +19566,7 @@ const Ol = ({
|
|
|
19563
19566
|
}
|
|
19564
19567
|
}).pipeTo(new WritableStream());
|
|
19565
19568
|
}).catch((G) => {
|
|
19566
|
-
console.error(G), console.log("Cancelling stream"),
|
|
19569
|
+
console.error(G), console.log("Cancelling stream"), h("notLoading"), ir = new AbortController();
|
|
19567
19570
|
});
|
|
19568
19571
|
};
|
|
19569
19572
|
return /* @__PURE__ */ Ie(
|
|
@@ -19593,7 +19596,7 @@ const Ol = ({
|
|
|
19593
19596
|
userType: ue.userType,
|
|
19594
19597
|
metaData: ue.metaData,
|
|
19595
19598
|
context: {
|
|
19596
|
-
discussionId:
|
|
19599
|
+
discussionId: c,
|
|
19597
19600
|
messageIndex: pe,
|
|
19598
19601
|
appToken: e
|
|
19599
19602
|
},
|
|
@@ -19606,7 +19609,7 @@ const Ol = ({
|
|
|
19606
19609
|
{
|
|
19607
19610
|
currentStepName: L,
|
|
19608
19611
|
currentStepNumber: R,
|
|
19609
|
-
loadingStatus:
|
|
19612
|
+
loadingStatus: d,
|
|
19610
19613
|
numberOfSteps: _
|
|
19611
19614
|
}
|
|
19612
19615
|
)
|
|
@@ -19648,14 +19651,14 @@ const Ol = ({
|
|
|
19648
19651
|
classNameTextarea: "",
|
|
19649
19652
|
classNameContainer: "relative mt-6 mt-3 border-slate-400 border-[1px] rounded-lg p-1",
|
|
19650
19653
|
SubmitComponent: Rg,
|
|
19651
|
-
isDisabled:
|
|
19654
|
+
isDisabled: d !== "notLoading" || fe,
|
|
19652
19655
|
shouldDisableIfInputIsEmpty: !0,
|
|
19653
19656
|
"aria-label": "TextArea For Bot Conversation",
|
|
19654
19657
|
onSubmit: (ue) => {
|
|
19655
19658
|
if (kg(ue)) {
|
|
19656
19659
|
const pe = wg(
|
|
19657
19660
|
ue,
|
|
19658
|
-
|
|
19661
|
+
c
|
|
19659
19662
|
);
|
|
19660
19663
|
$(pe, "user"), B(), ne({
|
|
19661
19664
|
smooth: !0,
|
|
@@ -19669,7 +19672,7 @@ const Ol = ({
|
|
|
19669
19672
|
},
|
|
19670
19673
|
placeholder: r,
|
|
19671
19674
|
autoFocus: !0,
|
|
19672
|
-
isLoadingStream:
|
|
19675
|
+
isLoadingStream: d === "loadingFinalAnswer" || d === "loadingIntermediaryStates",
|
|
19673
19676
|
LoadingComponent: Fg,
|
|
19674
19677
|
onPressLoadingButton: Y
|
|
19675
19678
|
}
|