@alan-ai/alan-sdk-web 1.8.127 → 1.8.128
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/alan_lib.js +63 -9
- package/dist/alan_lib.min.js +1 -1
- package/package.json +1 -1
package/dist/alan_lib.js
CHANGED
|
@@ -96992,6 +96992,7 @@
|
|
|
96992
96992
|
docked: false,
|
|
96993
96993
|
options: null,
|
|
96994
96994
|
maxCharactersCount: 2e4,
|
|
96995
|
+
maxQuestionsCount: 5,
|
|
96995
96996
|
loaderTimeoutMs: 18e5,
|
|
96996
96997
|
defaults: {
|
|
96997
96998
|
minChatWidth: 250,
|
|
@@ -97254,7 +97255,6 @@
|
|
|
97254
97255
|
// alan_btn/src/textChat/helpers/getMsgReqId.ts
|
|
97255
97256
|
function getMsgReqId(msg) {
|
|
97256
97257
|
return msg.reqId || msg?.ctx?.reqId;
|
|
97257
|
-
;
|
|
97258
97258
|
}
|
|
97259
97259
|
function getMsgResponseId(msg) {
|
|
97260
97260
|
return msg.responseId || msg?.ctx?.responseId || msg?.ctx?.resId;
|
|
@@ -97263,12 +97263,13 @@
|
|
|
97263
97263
|
// alan_btn/src/textChat/helpers/getMsgLoader.ts
|
|
97264
97264
|
var DEFAULT_INTERIM_MESSAGE = "Thinking...";
|
|
97265
97265
|
var STOP_RESPONSE_ICON_CLASS = "alan-btn__chat-incomming-msg-loader-icon";
|
|
97266
|
+
var INCOMMING_MSG_LOADER_ICON_HOLDER_CLASS = "alan-btn__chat-incomming-msg-loader-icon-holder";
|
|
97266
97267
|
function getMsgLoaderWrapper(content) {
|
|
97267
97268
|
return `<div class="alan-btn__chat-incomming-msg-wrapper">${content}</div>`;
|
|
97268
97269
|
}
|
|
97269
97270
|
function getMsgLoader(textChatOptions, inTop = false) {
|
|
97270
97271
|
const icon = textChatOptions?.bubbles?.waitingResponse?.icon?.svg || chatIcons.msgLoader;
|
|
97271
|
-
return `<span class="
|
|
97272
|
+
return `<span class="${INCOMMING_MSG_LOADER_ICON_HOLDER_CLASS} ${inTop ? "" : "alan-btn__bottom-loader"}">
|
|
97272
97273
|
<span class="${STOP_RESPONSE_ICON_CLASS}">${icon}</span>
|
|
97273
97274
|
</span>`;
|
|
97274
97275
|
}
|
|
@@ -99795,6 +99796,9 @@
|
|
|
99795
99796
|
user-select: text;
|
|
99796
99797
|
overflow: hidden;
|
|
99797
99798
|
}`;
|
|
99799
|
+
keyFrames += getStyleSheetMarker() + `.alan-btn__chat-response.without-content {
|
|
99800
|
+
display: none!important;
|
|
99801
|
+
}`;
|
|
99798
99802
|
keyFrames += getStyleSheetMarker() + `.alan-btn__chat-response.alan-incoming-msg {
|
|
99799
99803
|
max-width: 100%;
|
|
99800
99804
|
${waitingResponseBubbleLayout === "loader-and-label-wo-bubble" ? `padding: ${getPaddingProp(responseBubbleTopPadding, 0, responseBubbleBottomPadding, 0)};
|
|
@@ -100587,6 +100591,7 @@
|
|
|
100587
100591
|
white-space: nowrap;
|
|
100588
100592
|
overflow: hidden;
|
|
100589
100593
|
text-overflow: ellipsis;
|
|
100594
|
+
pointer-events: none;
|
|
100590
100595
|
}`;
|
|
100591
100596
|
keyFrames += styleSheetMarker + `.alan-btn__chat-incomming-msg-loader-label-default {
|
|
100592
100597
|
position: relative;
|
|
@@ -110961,7 +110966,7 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
110961
110966
|
// alan_btn/alan_btn.ts
|
|
110962
110967
|
(function(ns) {
|
|
110963
110968
|
const uiState10 = getUIState();
|
|
110964
|
-
const version2 = "alan-version.1.8.
|
|
110969
|
+
const version2 = "alan-version.1.8.128".replace("alan-version.", "");
|
|
110965
110970
|
uiState10.lib.version = version2;
|
|
110966
110971
|
window.alanLib = { version: version2 };
|
|
110967
110972
|
if (window.alanBtn) {
|
|
@@ -111004,6 +111009,7 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
111004
111009
|
var textChatMessages = [];
|
|
111005
111010
|
var canceledRequests = [];
|
|
111006
111011
|
var textChatScrollPosition = null;
|
|
111012
|
+
var questionInProgress = false;
|
|
111007
111013
|
var sentMessageInd = null;
|
|
111008
111014
|
var sentMessages = [];
|
|
111009
111015
|
const LOCAL_STORAGE_KEYS = {
|
|
@@ -112046,7 +112052,6 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
112046
112052
|
userAgent: navigator.userAgent,
|
|
112047
112053
|
appName: window.location.hostname
|
|
112048
112054
|
});
|
|
112049
|
-
console.time("Alan: receiving options time");
|
|
112050
112055
|
window.tutorProject.on("connectStatus", onConnectStatusChange);
|
|
112051
112056
|
window.tutorProject.on("options", onOptionsReceived);
|
|
112052
112057
|
window.tutorProject.on("scripts", onScriptsCb);
|
|
@@ -112743,7 +112748,7 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
112743
112748
|
}
|
|
112744
112749
|
}
|
|
112745
112750
|
function updateMsgLoaderIcons(textChatOptions) {
|
|
112746
|
-
document.querySelectorAll(
|
|
112751
|
+
document.querySelectorAll(`.${INCOMMING_MSG_LOADER_ICON_HOLDER_CLASS}`).forEach((el) => {
|
|
112747
112752
|
el.outerHTML = getMsgLoader(textChatOptions);
|
|
112748
112753
|
});
|
|
112749
112754
|
}
|
|
@@ -112755,7 +112760,6 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
112755
112760
|
}
|
|
112756
112761
|
function onOptionsReceived(data4) {
|
|
112757
112762
|
console.log("Alan: options received");
|
|
112758
|
-
console.timeEnd("Alan: receiving options time");
|
|
112759
112763
|
saveOptions(data4);
|
|
112760
112764
|
uiState10.textChat.notifications.enabled = data4?.web?.chatOptions?.textChat?.notifications?.enabled;
|
|
112761
112765
|
uiState10.textChat.chatExport.includeGraphInfo.enabled = data4?.web?.chatOptions?.textChat?.popup?.saveChatState?.includeGraphInfo?.enabled;
|
|
@@ -112764,6 +112768,7 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
112764
112768
|
uiState10.pageState.autoSync = data4?.web?.pageState?.autoSync;
|
|
112765
112769
|
uiState10.textChat.autocomplete.enabled = data4?.web?.chatOptions?.textChat?.textarea?.autocomplete?.enabled;
|
|
112766
112770
|
uiState10.textChat.maxCharactersCount = data4?.web?.chatOptions?.textChat?.textarea?.maxCharactersCount ? +data4?.web?.chatOptions?.textChat?.textarea?.maxCharactersCount : 2e4;
|
|
112771
|
+
uiState10.textChat.maxQuestionsCount = data4?.web?.chatOptions?.textChat?.textarea?.maxQuestionsCount ? +data4?.web?.chatOptions?.textChat?.textarea?.maxQuestionsCount : 5;
|
|
112767
112772
|
changeOptions(getOptionsByTheme(data4?.web, uiState10.currentTheme || options.theme));
|
|
112768
112773
|
saveResourcesUrl(data4);
|
|
112769
112774
|
insertResources(data4);
|
|
@@ -112821,6 +112826,9 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
112821
112826
|
console.info(`Alan: connected to ${dialogId !== getSavedDialogId() ? "new" : ""} dialog:
|
|
112822
112827
|
${dialogId}
|
|
112823
112828
|
${getSavedDialogId() || "-"} (prev. dialog)`);
|
|
112829
|
+
if (dialogId !== getSavedDialogId()) {
|
|
112830
|
+
questionInProgress = false;
|
|
112831
|
+
}
|
|
112824
112832
|
curDialogId = dialogId;
|
|
112825
112833
|
sentMessages = restoreSentMessages();
|
|
112826
112834
|
const prevUserId = getPrevUserId();
|
|
@@ -113636,7 +113644,7 @@ ${curDialogId}`);
|
|
|
113636
113644
|
if (msg?.suggestions?.length > 0) {
|
|
113637
113645
|
suggestionsHtml += renderSuggestions(msg.suggestions);
|
|
113638
113646
|
}
|
|
113639
|
-
msgHtml = `<div class="alan-btn__chat-inner-msg ${msg.type === "request" ? "alan-btn__chat-request" : "alan-btn__chat-response"} ${msg.images?.length > 0 ? "with-images" : ""} ${isMsgContainsTable(innerMsgPart) ? "with-table" : ""} ${isMsgContainsIFrame(innerMsgPart) ? "with-iframe" : ""}">${innerMsgPart}</div>${suggestionsHtml}`;
|
|
113647
|
+
msgHtml = `<div class="alan-btn__chat-inner-msg ${msg.text || msg.images?.length > 0 || msg?.links?.length > 0 ? "" : "without-content"} ${msg.type === "request" ? "alan-btn__chat-request" : "alan-btn__chat-response"} ${msg.images?.length > 0 ? "with-images" : ""} ${isMsgContainsTable(innerMsgPart) ? "with-table" : ""} ${isMsgContainsIFrame(innerMsgPart) ? "with-iframe" : ""}">${innerMsgPart}</div>${suggestionsHtml}`;
|
|
113640
113648
|
}
|
|
113641
113649
|
if (msg.name === "loading") {
|
|
113642
113650
|
const loaderId = `loading-msg-${guid()}`;
|
|
@@ -113711,6 +113719,9 @@ ${curDialogId}`);
|
|
|
113711
113719
|
if (innerEl.classList.contains("alan-hidden-loader")) {
|
|
113712
113720
|
innerEl.classList.remove("alan-hidden-loader");
|
|
113713
113721
|
}
|
|
113722
|
+
if (msg.text || msg.images?.length > 0 || msg.links?.length > 0) {
|
|
113723
|
+
innerEl.classList.remove("without-content");
|
|
113724
|
+
}
|
|
113714
113725
|
const updatedMsg = textChatMessages[msgInd];
|
|
113715
113726
|
innerEl.innerHTML = innerMsgPart;
|
|
113716
113727
|
if (withDetailedStatuses) {
|
|
@@ -113746,6 +113757,9 @@ ${curDialogId}`);
|
|
|
113746
113757
|
if (innerEl.classList.contains("alan-hidden-loader")) {
|
|
113747
113758
|
innerEl.classList.remove("alan-hidden-loader");
|
|
113748
113759
|
}
|
|
113760
|
+
if (msg.text || msg.images?.length > 0 || msg.links?.length > 0) {
|
|
113761
|
+
innerEl.classList.remove("without-content");
|
|
113762
|
+
}
|
|
113749
113763
|
const updatedMsg = textChatMessages[msgInd];
|
|
113750
113764
|
const imagesWrapper = innerEl.querySelector(".alan-btn__chat-response-imgs-wrapper");
|
|
113751
113765
|
if (updatedMsg.images?.length > 0 && imagesWrapper) {
|
|
@@ -113848,6 +113862,11 @@ ${curDialogId}`);
|
|
|
113848
113862
|
enableTextareaInTheChat();
|
|
113849
113863
|
}
|
|
113850
113864
|
}
|
|
113865
|
+
if (msg.ctx?.final === true && msg.type === "response") {
|
|
113866
|
+
if (msg.type === "response") {
|
|
113867
|
+
enableTextareaInTheChat();
|
|
113868
|
+
}
|
|
113869
|
+
}
|
|
113851
113870
|
manageSaveChatHistoryBtn();
|
|
113852
113871
|
}
|
|
113853
113872
|
function updateTextParts(textWrapperEl, updatedMsg) {
|
|
@@ -113953,6 +113972,7 @@ ${curDialogId}`);
|
|
|
113953
113972
|
if (options.onEvent) {
|
|
113954
113973
|
options.onEvent({ name: "textChatCleared" });
|
|
113955
113974
|
}
|
|
113975
|
+
questionInProgress = false;
|
|
113956
113976
|
window.alanIframes = {};
|
|
113957
113977
|
clearChatHistoryStorage();
|
|
113958
113978
|
clearDOMChat();
|
|
@@ -114050,22 +114070,37 @@ ${curDialogId}`);
|
|
|
114050
114070
|
}
|
|
114051
114071
|
}
|
|
114052
114072
|
}
|
|
114073
|
+
function getActiveQuestionsCount() {
|
|
114074
|
+
return document.querySelectorAll(
|
|
114075
|
+
`.alan-btn__chat-msg-holder:not(.alan-hide-msg-immidiatelly) .${INCOMMING_MSG_LOADER_ICON_HOLDER_CLASS}`
|
|
114076
|
+
).length + (questionInProgress ? 1 : 0);
|
|
114077
|
+
}
|
|
114053
114078
|
async function _sendText(text5) {
|
|
114054
114079
|
manageAutocompeteInChat();
|
|
114055
114080
|
var maxChars = uiState10.textChat.maxCharactersCount || 2e4;
|
|
114081
|
+
var maxQuestions = uiState10.textChat.maxQuestionsCount || 5;
|
|
114056
114082
|
if (text5?.length > maxChars) {
|
|
114057
114083
|
console.warn("Alan: message cannot be sent: maximum message limit exceeded.");
|
|
114058
114084
|
return;
|
|
114059
114085
|
}
|
|
114086
|
+
if (getActiveQuestionsCount() >= maxQuestions) {
|
|
114087
|
+
console.warn("Alan: message cannot be sent: maximum concurrent questions limit exceeded.");
|
|
114088
|
+
return;
|
|
114089
|
+
}
|
|
114060
114090
|
if (!canMsgBeSent()) {
|
|
114061
114091
|
console.warn("Alan: message cannot be sent. Model is not ready or connection is not established.");
|
|
114062
114092
|
return;
|
|
114063
114093
|
}
|
|
114094
|
+
if (getActiveQuestionsCount() >= maxQuestions) {
|
|
114095
|
+
disableTextareaInTheChat();
|
|
114096
|
+
}
|
|
114064
114097
|
var msg = { text: text5, type: "request", name: "text", tsInit: Date.now() };
|
|
114065
114098
|
sentMessageInd = null;
|
|
114066
114099
|
clearMessageProgressStatusInterval();
|
|
114100
|
+
questionInProgress = true;
|
|
114067
114101
|
var res = await sendText(text5);
|
|
114068
114102
|
msg = { ...msg, reqId: res.reqId };
|
|
114103
|
+
questionInProgress = false;
|
|
114069
114104
|
renderMessageInTextChat(msg);
|
|
114070
114105
|
renderMessageInTextChat({
|
|
114071
114106
|
type: "response",
|
|
@@ -114093,10 +114128,19 @@ ${curDialogId}`);
|
|
|
114093
114128
|
}
|
|
114094
114129
|
function enableTextareaInTheChat() {
|
|
114095
114130
|
var textareaHolderEl = document.getElementById("textarea-holder");
|
|
114096
|
-
|
|
114131
|
+
var maxQuestions = uiState10.textChat.maxQuestionsCount || 5;
|
|
114132
|
+
if (getActiveQuestionsCount() < maxQuestions) {
|
|
114133
|
+
textareaHolderEl.classList.remove("alan-btn__inactive");
|
|
114134
|
+
}
|
|
114097
114135
|
clearTimeout(lastSendMsgTs);
|
|
114098
114136
|
lastSendMsgTs = null;
|
|
114099
114137
|
}
|
|
114138
|
+
function disableTextareaInTheChat() {
|
|
114139
|
+
var textareaHolderEl = document.getElementById("textarea-holder");
|
|
114140
|
+
if (textareaHolderEl) {
|
|
114141
|
+
textareaHolderEl.classList.add("alan-btn__inactive");
|
|
114142
|
+
}
|
|
114143
|
+
}
|
|
114100
114144
|
function canMsgBeSent() {
|
|
114101
114145
|
if (!isModelReady || state === DISCONNECTED || state === OFFLINE) {
|
|
114102
114146
|
return false;
|
|
@@ -114108,6 +114152,7 @@ ${curDialogId}`);
|
|
|
114108
114152
|
var textareaHolderEl = document.getElementById("textarea-holder");
|
|
114109
114153
|
var text5 = textareaEl.value;
|
|
114110
114154
|
var maxChars = uiState10.textChat.maxCharactersCount || 2e4;
|
|
114155
|
+
var maxQuestions = uiState10.textChat.maxQuestionsCount || 5;
|
|
114111
114156
|
if (lastSendMsgTs) {
|
|
114112
114157
|
console.warn("Alan: message cannot be sent: you are sending messages too fast. Please wait a moment before sending another message.");
|
|
114113
114158
|
return;
|
|
@@ -114116,6 +114161,10 @@ ${curDialogId}`);
|
|
|
114116
114161
|
console.warn("Alan: message cannot be sent: maximum message limit exceeded.");
|
|
114117
114162
|
return;
|
|
114118
114163
|
}
|
|
114164
|
+
if (getActiveQuestionsCount() >= maxQuestions) {
|
|
114165
|
+
console.warn("Alan: message cannot be sent: maximum concurrent questions limit exceeded.");
|
|
114166
|
+
return;
|
|
114167
|
+
}
|
|
114119
114168
|
if (!canMsgBeSent()) {
|
|
114120
114169
|
return;
|
|
114121
114170
|
}
|
|
@@ -114127,7 +114176,7 @@ ${curDialogId}`);
|
|
|
114127
114176
|
textareaEl.value = "";
|
|
114128
114177
|
previousTextValue = "";
|
|
114129
114178
|
_sendText(text5);
|
|
114130
|
-
|
|
114179
|
+
disableTextareaInTheChat();
|
|
114131
114180
|
textChatScrollPosition = null;
|
|
114132
114181
|
}, 1e3);
|
|
114133
114182
|
function getMsgElForMathJax(msgInd) {
|
|
@@ -114279,6 +114328,11 @@ ${curDialogId}`);
|
|
|
114279
114328
|
} else {
|
|
114280
114329
|
errEl.style.display = "block";
|
|
114281
114330
|
}
|
|
114331
|
+
if (getActiveQuestionsCount() >= uiState10.textChat.maxQuestionsCount) {
|
|
114332
|
+
disableTextareaInTheChat();
|
|
114333
|
+
} else {
|
|
114334
|
+
enableTextareaInTheChat();
|
|
114335
|
+
}
|
|
114282
114336
|
}
|
|
114283
114337
|
}
|
|
114284
114338
|
const resizeTextAreaDebounced = throttle(function() {
|