@enegelai/bot-widget 1.12.2 → 1.12.4
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/enegelaibot.umd.js +3 -3
- package/dist/index.es.js +12 -11
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -806,7 +806,7 @@ A.setLevel("info");
|
|
|
806
806
|
const ee = "cb_";
|
|
807
807
|
class L extends kt {
|
|
808
808
|
constructor() {
|
|
809
|
-
super(...arguments), this.actionIdCounter = 0, this.prefilledFormValues = {}, this.wsClient = null, this.replyMessage = null, this.streamingResponseInProgress = !1, this.streamingResponseLastText = null, this.streamingResponseBuffer = null, this.streamingResponseTagStartPos = 0, this.streamingResponseCurrentTag = null;
|
|
809
|
+
super(...arguments), this.actionIdCounter = 0, this.currentLoadContext = {}, this.prefilledFormValues = {}, this.wsClient = null, this.replyMessage = null, this.streamingResponseInProgress = !1, this.streamingResponseLastText = null, this.streamingResponseBuffer = null, this.streamingResponseTagStartPos = 0, this.streamingResponseCurrentTag = null;
|
|
810
810
|
}
|
|
811
811
|
// this is called at startup
|
|
812
812
|
setSetting(e) {
|
|
@@ -872,7 +872,8 @@ class L extends kt {
|
|
|
872
872
|
}
|
|
873
873
|
initConversation() {
|
|
874
874
|
const e = Date.now(), a = this.setting.newConversationTimeoutInSec * 1e3;
|
|
875
|
-
|
|
875
|
+
let n = this.lastConversationUpdate;
|
|
876
|
+
if (typeof n == "string" && (n = isNaN(n) ? 0 : parseInt(n, 10)), e - n > a) {
|
|
876
877
|
this.clearConversation();
|
|
877
878
|
return;
|
|
878
879
|
}
|
|
@@ -880,7 +881,7 @@ class L extends kt {
|
|
|
880
881
|
}
|
|
881
882
|
clearConversation() {
|
|
882
883
|
this.wsClient && (this.wsClient.stop().then(() => {
|
|
883
|
-
}), this.wsClient = null), this.conversationId = xe(), this.lastConversationUpdate = Date.now(), this.connectWs = "false", this.shouldEngage = "true", this.messages = [], this.unreadMessages = 0, this.actions = [], this.context =
|
|
884
|
+
}), this.wsClient = null), this.conversationId = xe(), this.lastConversationUpdate = Date.now(), this.connectWs = "false", this.shouldEngage = "true", this.messages = [], this.unreadMessages = 0, this.actions = [], this.context = this.currentLoadContext, this.form = null, this.addMessage({
|
|
884
885
|
author: "assistant",
|
|
885
886
|
type: "text",
|
|
886
887
|
data: {
|
|
@@ -896,12 +897,12 @@ class L extends kt {
|
|
|
896
897
|
}
|
|
897
898
|
// Set data in the context of the conversation
|
|
898
899
|
async setContext(e) {
|
|
899
|
-
if (!
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
900
|
+
if (!e || typeof e != "object")
|
|
901
|
+
return;
|
|
902
|
+
const a = this.context ? this.context : {};
|
|
903
|
+
for (const [n, s] of Object.entries(e))
|
|
904
|
+
a[n] = s, this.currentLoadContext[n] = s;
|
|
905
|
+
this.context = a, this.wsClient && await this.sendContext();
|
|
905
906
|
}
|
|
906
907
|
async sendContext() {
|
|
907
908
|
if (!this.context)
|
|
@@ -922,7 +923,7 @@ class L extends kt {
|
|
|
922
923
|
return this.context;
|
|
923
924
|
}
|
|
924
925
|
clearContext() {
|
|
925
|
-
this.context = {};
|
|
926
|
+
this.context = {}, this.currentLoadContext = {};
|
|
926
927
|
}
|
|
927
928
|
initStartupForm() {
|
|
928
929
|
const e = wt(null, ["startupForm"], this.botSettings);
|
|
@@ -1477,7 +1478,7 @@ O([
|
|
|
1477
1478
|
], L.prototype, "setting");
|
|
1478
1479
|
O([
|
|
1479
1480
|
oe({ prefix: ee }),
|
|
1480
|
-
q({ type: Object, value:
|
|
1481
|
+
q({ type: Object, value: {} })
|
|
1481
1482
|
], L.prototype, "context");
|
|
1482
1483
|
O([
|
|
1483
1484
|
q({ type: String, value: "top-end" })
|