bibot 1.0.40 → 1.0.42
Sign up to get free protection for your applications and to get access to all the features.
- 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 +2 -13
- package/dist/hooks/usePluginFactory.d.ts +1 -1
- package/dist/index.d.ts +2 -7
- package/dist/index.js +61 -47
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +61 -47
- package/dist/index.modern.js.map +1 -1
- package/dist/services/plugin-api.d.ts +6 -28
- package/dist/types/coreInterfaces.d.ts +57 -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: '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,7 +3630,7 @@ 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,
|
@@ -3659,7 +3663,7 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3659
3663
|
try {
|
3660
3664
|
setIsLoading(true);
|
3661
3665
|
var input = question.question.trim();
|
3662
|
-
recordPredefinedQ({
|
3666
|
+
recordPredefinedQ(pluginAxiosInstance, {
|
3663
3667
|
"client_id": clientId,
|
3664
3668
|
"question": question.question,
|
3665
3669
|
"q_n_a_id": question.q_n_a_id
|
@@ -3689,7 +3693,10 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3689
3693
|
}
|
3690
3694
|
};
|
3691
3695
|
var clientId = _ref.clientId,
|
3692
|
-
client_session_id = _ref.client_session_id
|
3696
|
+
client_session_id = _ref.client_session_id,
|
3697
|
+
test = _ref.test;
|
3698
|
+
var baseURL = test ? endpoints.getInferenceURL(true) : endpoints.getInferenceURL(false);
|
3699
|
+
var pluginAxiosInstance = createPluginAxiosInstance(baseURL);
|
3693
3700
|
var _useState = useState([]),
|
3694
3701
|
predefinedQuestions = _useState[0],
|
3695
3702
|
setPredefinedQuestions = _useState[1];
|
@@ -3722,13 +3729,13 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3722
3729
|
};
|
3723
3730
|
var getChatBubbleConfig = useCallback(function () {
|
3724
3731
|
try {
|
3725
|
-
return Promise.resolve(getRemoteClientChatPredefinedQuestions({
|
3732
|
+
return Promise.resolve(getRemoteClientChatPredefinedQuestions(pluginAxiosInstance, {
|
3726
3733
|
client_id: clientId
|
3727
3734
|
})).then(function (remotePredefinedQuestions) {
|
3728
3735
|
if (remotePredefinedQuestions) {
|
3729
3736
|
setPredefinedQuestions(remotePredefinedQuestions);
|
3730
3737
|
}
|
3731
|
-
return Promise.resolve(getRemoteClientChatBubbleConfig({
|
3738
|
+
return Promise.resolve(getRemoteClientChatBubbleConfig(pluginAxiosInstance, {
|
3732
3739
|
client_id: clientId
|
3733
3740
|
})).then(function (remoteChatBubbleConfig) {
|
3734
3741
|
if (remoteChatBubbleConfig) {
|
@@ -4077,9 +4084,11 @@ var Loader = function Loader() {
|
|
4077
4084
|
var PredefinedQuestions = function PredefinedQuestions(_ref) {
|
4078
4085
|
var questions = _ref.questions,
|
4079
4086
|
onSelect = _ref.onSelect,
|
4080
|
-
clientId = _ref.clientId
|
4087
|
+
clientId = _ref.clientId,
|
4088
|
+
test = _ref.test;
|
4081
4089
|
var _useBiBotChatBot = useBiBotChatBot({
|
4082
|
-
clientId: clientId
|
4090
|
+
clientId: clientId,
|
4091
|
+
test: test
|
4083
4092
|
}),
|
4084
4093
|
chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig;
|
4085
4094
|
return createElement("div", {
|
@@ -4136,11 +4145,13 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4136
4145
|
var _chatBubbleConfig$col2, _chatBubbleConfig$col3;
|
4137
4146
|
var clientId = _ref2.clientId,
|
4138
4147
|
client_session_id = _ref2.client_session_id,
|
4139
|
-
redirect_notice = _ref2.redirect_notice
|
4148
|
+
redirect_notice = _ref2.redirect_notice,
|
4149
|
+
test = _ref2.test;
|
4140
4150
|
var _useBiBotChatBot2 = useBiBotChatBot({
|
4141
4151
|
clientId: clientId,
|
4142
4152
|
client_session_id: client_session_id,
|
4143
|
-
redirect_notice: redirect_notice
|
4153
|
+
redirect_notice: redirect_notice,
|
4154
|
+
test: test
|
4144
4155
|
}),
|
4145
4156
|
chatIsOpen = _useBiBotChatBot2.chatIsOpen,
|
4146
4157
|
messages = _useBiBotChatBot2.messages,
|
@@ -4349,11 +4360,14 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4349
4360
|
|
4350
4361
|
var BiBot = function BiBot(_ref) {
|
4351
4362
|
var clientId = _ref.clientId,
|
4352
|
-
client_session_id = _ref.client_session_id
|
4363
|
+
client_session_id = _ref.client_session_id,
|
4364
|
+
redirect_notice = _ref.redirect_notice,
|
4365
|
+
test = _ref.test;
|
4353
4366
|
return createElement(AppProvider, null, createElement(ChatBubbleBiBot, {
|
4354
4367
|
clientId: clientId,
|
4355
4368
|
client_session_id: client_session_id,
|
4356
|
-
redirect_notice:
|
4369
|
+
redirect_notice: redirect_notice,
|
4370
|
+
test: test
|
4357
4371
|
}));
|
4358
4372
|
};
|
4359
4373
|
|