bibot 1.0.41 → 1.0.45
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/component/Avatar.d.ts +1 -8
- package/dist/component/Icons.d.ts +1 -3
- package/dist/component/bibot.d.ts +2 -6
- package/dist/config/endpointEnums.d.ts +1 -1
- package/dist/context/AppContext.d.ts +1 -5
- package/dist/hooks/useBiBotChatBot.d.ts +3 -17
- package/dist/hooks/usePluginFactory.d.ts +1 -1
- package/dist/index.d.ts +2 -7
- package/dist/index.js +63 -48
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +63 -48
- package/dist/index.modern.js.map +1 -1
- package/dist/services/plugin-api.d.ts +6 -28
- package/dist/types/coreInterfaces.d.ts +63 -6
- package/package.json +1 -1
- package/dist/component/SendMessageIcon.d.ts +0 -2
package/dist/index.modern.js
CHANGED
@@ -3263,31 +3263,7 @@ axios.HttpStatusCode = HttpStatusCode;
|
|
3263
3263
|
|
3264
3264
|
axios.default = axios;
|
3265
3265
|
|
3266
|
-
var
|
3267
|
-
inference: process.env.NODE_ENV !== 'production' ? 'https://inference.dev.bibot.thespuka.com/v0' : 'https://inference.bibot.app/v0'
|
3268
|
-
};
|
3269
|
-
var endpoints = {
|
3270
|
-
get inference() {
|
3271
|
-
return baseUrls.inference;
|
3272
|
-
}
|
3273
|
-
};
|
3274
|
-
var domain;
|
3275
|
-
(function (domain) {
|
3276
|
-
domain["app"] = "/app";
|
3277
|
-
domain["bibot"] = "/bibot";
|
3278
|
-
domain["inference"] = "/inference";
|
3279
|
-
})(domain || (domain = {}));
|
3280
|
-
var resources;
|
3281
|
-
(function (resources) {
|
3282
|
-
resources["chatBubble"] = "/chat-bubble-config";
|
3283
|
-
resources["predefinedQ"] = "/predefined-q";
|
3284
|
-
resources["timeoutQ"] = "/timeout-q";
|
3285
|
-
resources["q"] = "/q";
|
3286
|
-
resources["predefinedQstatistics"] = "/predefined-questions-statistics";
|
3287
|
-
})(resources || (resources = {}));
|
3288
|
-
|
3289
|
-
var inferenceBaseURL = endpoints.inference;
|
3290
|
-
var createPluginAxiosInstance = function createPluginAxiosInstance(params, headers) {
|
3266
|
+
var createPluginAxiosInstance = function createPluginAxiosInstance(baseURL, params, headers) {
|
3291
3267
|
if (params === void 0) {
|
3292
3268
|
params = {};
|
3293
3269
|
}
|
@@ -3295,7 +3271,7 @@ var createPluginAxiosInstance = function createPluginAxiosInstance(params, heade
|
|
3295
3271
|
headers = {};
|
3296
3272
|
}
|
3297
3273
|
var instance = axios.create(_extends({
|
3298
|
-
baseURL:
|
3274
|
+
baseURL: baseURL,
|
3299
3275
|
timeout: 60000,
|
3300
3276
|
headers: _extends({
|
3301
3277
|
'Content-Type': 'application/json'
|
@@ -3492,7 +3468,36 @@ var AppProvider = function AppProvider(_ref) {
|
|
3492
3468
|
}, children);
|
3493
3469
|
};
|
3494
3470
|
|
3495
|
-
var
|
3471
|
+
var baseUrls = {
|
3472
|
+
inference: {
|
3473
|
+
production: 'https://inference.bibot.app/v0',
|
3474
|
+
test: 'https://inference.dev.bibot.thespuka.com/v0'
|
3475
|
+
}
|
3476
|
+
};
|
3477
|
+
var endpoints = {
|
3478
|
+
getInferenceURL: function getInferenceURL(isTest) {
|
3479
|
+
if (isTest === void 0) {
|
3480
|
+
isTest = false;
|
3481
|
+
}
|
3482
|
+
return isTest ? baseUrls.inference.test : baseUrls.inference.production;
|
3483
|
+
}
|
3484
|
+
};
|
3485
|
+
var domain;
|
3486
|
+
(function (domain) {
|
3487
|
+
domain["app"] = "/app";
|
3488
|
+
domain["bibot"] = "/bibot";
|
3489
|
+
domain["inference"] = "/inference";
|
3490
|
+
})(domain || (domain = {}));
|
3491
|
+
var resources;
|
3492
|
+
(function (resources) {
|
3493
|
+
resources["chatBubble"] = "/chat-bubble-config";
|
3494
|
+
resources["predefinedQ"] = "/predefined-q";
|
3495
|
+
resources["timeoutQ"] = "/timeout-q";
|
3496
|
+
resources["q"] = "/q";
|
3497
|
+
resources["predefinedQstatistics"] = "/predefined-questions-statistics";
|
3498
|
+
})(resources || (resources = {}));
|
3499
|
+
|
3500
|
+
var getRemoteClientChatPredefinedQuestions = function getRemoteClientChatPredefinedQuestions(pluginAxiosInstance, params) {
|
3496
3501
|
return Promise.resolve(_catch(function () {
|
3497
3502
|
var path = "" + domain.inference + resources.predefinedQ;
|
3498
3503
|
return Promise.resolve(pluginAxiosInstance.get(path, {
|
@@ -3505,7 +3510,7 @@ var getRemoteClientChatPredefinedQuestions = function getRemoteClientChatPredefi
|
|
3505
3510
|
return [];
|
3506
3511
|
}));
|
3507
3512
|
};
|
3508
|
-
var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(params) {
|
3513
|
+
var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(pluginAxiosInstance, params) {
|
3509
3514
|
try {
|
3510
3515
|
return Promise.resolve(_catch(function () {
|
3511
3516
|
var path = "" + domain.inference + resources.chatBubble;
|
@@ -3526,7 +3531,7 @@ var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(p
|
|
3526
3531
|
return Promise.reject(e);
|
3527
3532
|
}
|
3528
3533
|
};
|
3529
|
-
var handleRetries = function handleRetries(data, attempt) {
|
3534
|
+
var handleRetries = function handleRetries(pluginAxiosInstance, data, attempt) {
|
3530
3535
|
try {
|
3531
3536
|
var maxAttempts = 30;
|
3532
3537
|
var delay = 10000;
|
@@ -3537,11 +3542,11 @@ var handleRetries = function handleRetries(data, attempt) {
|
|
3537
3542
|
return setTimeout(resolve, delay);
|
3538
3543
|
})).then(function () {
|
3539
3544
|
return _catch(function () {
|
3540
|
-
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3545
|
+
return Promise.resolve(askTimedOutBiBot(pluginAxiosInstance, _extends({}, data, {
|
3541
3546
|
tries: attempt + 1
|
3542
3547
|
}))).then(function (message) {
|
3543
3548
|
if (message === defaultSlacker) {
|
3544
|
-
return Promise.resolve(handleRetries(data, attempt + 1));
|
3549
|
+
return Promise.resolve(handleRetries(pluginAxiosInstance, data, attempt + 1));
|
3545
3550
|
} else {
|
3546
3551
|
return message;
|
3547
3552
|
}
|
@@ -3554,13 +3559,13 @@ var handleRetries = function handleRetries(data, attempt) {
|
|
3554
3559
|
return Promise.reject(e);
|
3555
3560
|
}
|
3556
3561
|
};
|
3557
|
-
var askBiBot = function askBiBot(data) {
|
3562
|
+
var askBiBot = function askBiBot(pluginAxiosInstance, data) {
|
3558
3563
|
try {
|
3559
3564
|
return Promise.resolve(_catch(function () {
|
3560
3565
|
var path = "" + domain.inference + resources.q;
|
3561
3566
|
return Promise.resolve(pluginAxiosInstance.post(path, data)).then(function (response) {
|
3562
3567
|
if (response.data.message === defaultSlacker) {
|
3563
|
-
return Promise.resolve(handleRetries(data, 1));
|
3568
|
+
return Promise.resolve(handleRetries(pluginAxiosInstance, data, 1));
|
3564
3569
|
} else {
|
3565
3570
|
return response.data.message;
|
3566
3571
|
}
|
@@ -3574,7 +3579,7 @@ var askBiBot = function askBiBot(data) {
|
|
3574
3579
|
return Promise.reject(e);
|
3575
3580
|
}
|
3576
3581
|
};
|
3577
|
-
var recordPredefinedQ = function recordPredefinedQ(data) {
|
3582
|
+
var recordPredefinedQ = function recordPredefinedQ(pluginAxiosInstance, data) {
|
3578
3583
|
try {
|
3579
3584
|
return Promise.resolve(_catch(function () {
|
3580
3585
|
var path = "" + domain.inference + resources.predefinedQstatistics;
|
@@ -3591,7 +3596,7 @@ var recordPredefinedQ = function recordPredefinedQ(data) {
|
|
3591
3596
|
return Promise.reject(e);
|
3592
3597
|
}
|
3593
3598
|
};
|
3594
|
-
var askTimedOutBiBot = function askTimedOutBiBot(data) {
|
3599
|
+
var askTimedOutBiBot = function askTimedOutBiBot(pluginAxiosInstance, data) {
|
3595
3600
|
try {
|
3596
3601
|
return Promise.resolve(_catch(function () {
|
3597
3602
|
var path = "" + domain.inference + resources.timeoutQ;
|
@@ -3608,7 +3613,6 @@ var askTimedOutBiBot = function askTimedOutBiBot(data) {
|
|
3608
3613
|
}
|
3609
3614
|
};
|
3610
3615
|
var defaultSlacker = "BiBot_Retry_Later";
|
3611
|
-
var pluginAxiosInstance = createPluginAxiosInstance();
|
3612
3616
|
|
3613
3617
|
var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
3614
3618
|
var sendInputInquiry = function sendInputInquiry() {
|
@@ -3626,11 +3630,12 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3626
3630
|
text: input
|
3627
3631
|
}]);
|
3628
3632
|
});
|
3629
|
-
return Promise.resolve(askBiBot({
|
3633
|
+
return Promise.resolve(askBiBot(pluginAxiosInstance, {
|
3630
3634
|
client_id: clientId,
|
3631
3635
|
q: input,
|
3632
3636
|
session_id: client_session_id ? client_session_id : state.sessionId,
|
3633
|
-
chat_id: v4()
|
3637
|
+
chat_id: v4(),
|
3638
|
+
chat_history: messages
|
3634
3639
|
})).then(function (response) {
|
3635
3640
|
setMessages(function (messages) {
|
3636
3641
|
return [].concat(messages, [{
|
@@ -3659,7 +3664,7 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3659
3664
|
try {
|
3660
3665
|
setIsLoading(true);
|
3661
3666
|
var input = question.question.trim();
|
3662
|
-
recordPredefinedQ({
|
3667
|
+
recordPredefinedQ(pluginAxiosInstance, {
|
3663
3668
|
"client_id": clientId,
|
3664
3669
|
"question": question.question,
|
3665
3670
|
"q_n_a_id": question.q_n_a_id
|
@@ -3689,7 +3694,10 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3689
3694
|
}
|
3690
3695
|
};
|
3691
3696
|
var clientId = _ref.clientId,
|
3692
|
-
client_session_id = _ref.client_session_id
|
3697
|
+
client_session_id = _ref.client_session_id,
|
3698
|
+
test = _ref.test;
|
3699
|
+
var baseURL = test ? endpoints.getInferenceURL(true) : endpoints.getInferenceURL(false);
|
3700
|
+
var pluginAxiosInstance = createPluginAxiosInstance(baseURL);
|
3693
3701
|
var _useState = useState([]),
|
3694
3702
|
predefinedQuestions = _useState[0],
|
3695
3703
|
setPredefinedQuestions = _useState[1];
|
@@ -3722,13 +3730,13 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3722
3730
|
};
|
3723
3731
|
var getChatBubbleConfig = useCallback(function () {
|
3724
3732
|
try {
|
3725
|
-
return Promise.resolve(getRemoteClientChatPredefinedQuestions({
|
3733
|
+
return Promise.resolve(getRemoteClientChatPredefinedQuestions(pluginAxiosInstance, {
|
3726
3734
|
client_id: clientId
|
3727
3735
|
})).then(function (remotePredefinedQuestions) {
|
3728
3736
|
if (remotePredefinedQuestions) {
|
3729
3737
|
setPredefinedQuestions(remotePredefinedQuestions);
|
3730
3738
|
}
|
3731
|
-
return Promise.resolve(getRemoteClientChatBubbleConfig({
|
3739
|
+
return Promise.resolve(getRemoteClientChatBubbleConfig(pluginAxiosInstance, {
|
3732
3740
|
client_id: clientId
|
3733
3741
|
})).then(function (remoteChatBubbleConfig) {
|
3734
3742
|
if (remoteChatBubbleConfig) {
|
@@ -4077,9 +4085,11 @@ var Loader = function Loader() {
|
|
4077
4085
|
var PredefinedQuestions = function PredefinedQuestions(_ref) {
|
4078
4086
|
var questions = _ref.questions,
|
4079
4087
|
onSelect = _ref.onSelect,
|
4080
|
-
clientId = _ref.clientId
|
4088
|
+
clientId = _ref.clientId,
|
4089
|
+
test = _ref.test;
|
4081
4090
|
var _useBiBotChatBot = useBiBotChatBot({
|
4082
|
-
clientId: clientId
|
4091
|
+
clientId: clientId,
|
4092
|
+
test: test
|
4083
4093
|
}),
|
4084
4094
|
chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig;
|
4085
4095
|
return createElement("div", {
|
@@ -4136,11 +4146,13 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4136
4146
|
var _chatBubbleConfig$col2, _chatBubbleConfig$col3;
|
4137
4147
|
var clientId = _ref2.clientId,
|
4138
4148
|
client_session_id = _ref2.client_session_id,
|
4139
|
-
redirect_notice = _ref2.redirect_notice
|
4149
|
+
redirect_notice = _ref2.redirect_notice,
|
4150
|
+
test = _ref2.test;
|
4140
4151
|
var _useBiBotChatBot2 = useBiBotChatBot({
|
4141
4152
|
clientId: clientId,
|
4142
4153
|
client_session_id: client_session_id,
|
4143
|
-
redirect_notice: redirect_notice
|
4154
|
+
redirect_notice: redirect_notice,
|
4155
|
+
test: test
|
4144
4156
|
}),
|
4145
4157
|
chatIsOpen = _useBiBotChatBot2.chatIsOpen,
|
4146
4158
|
messages = _useBiBotChatBot2.messages,
|
@@ -4349,11 +4361,14 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4349
4361
|
|
4350
4362
|
var BiBot = function BiBot(_ref) {
|
4351
4363
|
var clientId = _ref.clientId,
|
4352
|
-
client_session_id = _ref.client_session_id
|
4364
|
+
client_session_id = _ref.client_session_id,
|
4365
|
+
redirect_notice = _ref.redirect_notice,
|
4366
|
+
test = _ref.test;
|
4353
4367
|
return createElement(AppProvider, null, createElement(ChatBubbleBiBot, {
|
4354
4368
|
clientId: clientId,
|
4355
4369
|
client_session_id: client_session_id,
|
4356
|
-
redirect_notice:
|
4370
|
+
redirect_notice: redirect_notice,
|
4371
|
+
test: test
|
4357
4372
|
}));
|
4358
4373
|
};
|
4359
4374
|
|