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
@@ -1,10 +1,3 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
|
3
|
-
source: string | undefined;
|
4
|
-
height: string;
|
5
|
-
width: string;
|
6
|
-
indicator?: string;
|
7
|
-
borderColor: string | undefined;
|
8
|
-
}
|
2
|
+
import { AvatarProps } from '../types/coreInterfaces';
|
9
3
|
export declare const Avatar: React.FC<AvatarProps>;
|
10
|
-
export {};
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
|
3
|
-
color: string | undefined;
|
4
|
-
}
|
2
|
+
import { iconColor } from '../types/coreInterfaces';
|
5
3
|
declare function SendMessageIcon({ color }: iconColor): React.JSX.Element;
|
6
4
|
declare function DefaultBotProfile(): React.JSX.Element;
|
7
5
|
declare function ChatIcon(): React.JSX.Element;
|
@@ -1,8 +1,4 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
|
3
|
-
|
4
|
-
client_session_id?: string;
|
5
|
-
redirect_notice?: boolean;
|
6
|
-
}
|
7
|
-
declare const ChatBubbleBiBot: ({ clientId, client_session_id, redirect_notice }: bubbleProps) => React.JSX.Element;
|
2
|
+
import { BiBotProps } from '../types/coreInterfaces';
|
3
|
+
declare const ChatBubbleBiBot: ({ clientId, client_session_id, redirect_notice, test }: BiBotProps) => React.JSX.Element;
|
8
4
|
export default ChatBubbleBiBot;
|
@@ -1,9 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
3
|
-
import type { AppContextProps } from '../types/coreInterfaces';
|
4
|
-
interface AppProps {
|
5
|
-
children: ReactNode;
|
6
|
-
}
|
2
|
+
import type { AppContextProps, AppProps } from '../types/coreInterfaces';
|
7
3
|
declare const AppContext: React.Context<AppContextProps>;
|
8
4
|
declare const AppProvider: React.FC<AppProps>;
|
9
5
|
export { AppContext, AppProvider };
|
@@ -1,17 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { predefinedQuestionsType } from '../
|
3
|
-
|
4
|
-
clientId: string;
|
5
|
-
client_session_id?: string;
|
6
|
-
redirect_notice?: boolean;
|
7
|
-
}
|
8
|
-
interface ChatBubbleConfigProps {
|
9
|
-
bgColor?: string;
|
10
|
-
color?: string;
|
11
|
-
title?: string;
|
12
|
-
logo_url?: string;
|
13
|
-
}
|
14
|
-
declare const useBiBotChatBot: ({ clientId, client_session_id }: UseBiBotChatBotProps) => {
|
2
|
+
import { BiBotProps, ChatBubbleConfigProps, predefinedQuestionsType } from '../types/coreInterfaces';
|
3
|
+
declare const useBiBotChatBot: ({ clientId, client_session_id, test }: BiBotProps) => {
|
15
4
|
chatIsOpen: boolean;
|
16
5
|
messages: {
|
17
6
|
sender: 'user' | 'bot';
|
@@ -1 +1 @@
|
|
1
|
-
export declare const createPluginAxiosInstance: (params?: {}, headers?: {}) => import("axios").AxiosInstance;
|
1
|
+
export declare const createPluginAxiosInstance: (baseURL: string, params?: {}, headers?: {}) => import("axios").AxiosInstance;
|
package/dist/index.d.ts
CHANGED
@@ -1,9 +1,4 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import './styles.css';
|
3
|
-
|
4
|
-
|
5
|
-
client_session_id?: string;
|
6
|
-
redirect_notice?: boolean;
|
7
|
-
}
|
8
|
-
export declare const BiBot: ({ clientId, client_session_id }: Props) => React.JSX.Element;
|
9
|
-
export {};
|
3
|
+
import { BiBotProps } from './types/coreInterfaces';
|
4
|
+
export declare const BiBot: ({ clientId, client_session_id, redirect_notice, test }: BiBotProps) => React.JSX.Element;
|
package/dist/index.js
CHANGED
@@ -3266,31 +3266,7 @@ axios.HttpStatusCode = HttpStatusCode;
|
|
3266
3266
|
|
3267
3267
|
axios.default = axios;
|
3268
3268
|
|
3269
|
-
var
|
3270
|
-
inference: 'https://inference.bibot.app/v0'
|
3271
|
-
};
|
3272
|
-
var endpoints = {
|
3273
|
-
get inference() {
|
3274
|
-
return baseUrls.inference;
|
3275
|
-
}
|
3276
|
-
};
|
3277
|
-
var domain;
|
3278
|
-
(function (domain) {
|
3279
|
-
domain["app"] = "/app";
|
3280
|
-
domain["bibot"] = "/bibot";
|
3281
|
-
domain["inference"] = "/inference";
|
3282
|
-
})(domain || (domain = {}));
|
3283
|
-
var resources;
|
3284
|
-
(function (resources) {
|
3285
|
-
resources["chatBubble"] = "/chat-bubble-config";
|
3286
|
-
resources["predefinedQ"] = "/predefined-q";
|
3287
|
-
resources["timeoutQ"] = "/timeout-q";
|
3288
|
-
resources["q"] = "/q";
|
3289
|
-
resources["predefinedQstatistics"] = "/predefined-questions-statistics";
|
3290
|
-
})(resources || (resources = {}));
|
3291
|
-
|
3292
|
-
var inferenceBaseURL = endpoints.inference;
|
3293
|
-
var createPluginAxiosInstance = function createPluginAxiosInstance(params, headers) {
|
3269
|
+
var createPluginAxiosInstance = function createPluginAxiosInstance(baseURL, params, headers) {
|
3294
3270
|
if (params === void 0) {
|
3295
3271
|
params = {};
|
3296
3272
|
}
|
@@ -3298,7 +3274,7 @@ var createPluginAxiosInstance = function createPluginAxiosInstance(params, heade
|
|
3298
3274
|
headers = {};
|
3299
3275
|
}
|
3300
3276
|
var instance = axios.create(_extends({
|
3301
|
-
baseURL:
|
3277
|
+
baseURL: baseURL,
|
3302
3278
|
timeout: 60000,
|
3303
3279
|
headers: _extends({
|
3304
3280
|
'Content-Type': 'application/json'
|
@@ -3495,7 +3471,36 @@ var AppProvider = function AppProvider(_ref) {
|
|
3495
3471
|
}, children);
|
3496
3472
|
};
|
3497
3473
|
|
3498
|
-
var
|
3474
|
+
var baseUrls = {
|
3475
|
+
inference: {
|
3476
|
+
production: 'https://inference.bibot.app/v0',
|
3477
|
+
test: 'https://inference.dev.bibot.thespuka.com/v0'
|
3478
|
+
}
|
3479
|
+
};
|
3480
|
+
var endpoints = {
|
3481
|
+
getInferenceURL: function getInferenceURL(isTest) {
|
3482
|
+
if (isTest === void 0) {
|
3483
|
+
isTest = false;
|
3484
|
+
}
|
3485
|
+
return isTest ? baseUrls.inference.test : baseUrls.inference.production;
|
3486
|
+
}
|
3487
|
+
};
|
3488
|
+
var domain;
|
3489
|
+
(function (domain) {
|
3490
|
+
domain["app"] = "/app";
|
3491
|
+
domain["bibot"] = "/bibot";
|
3492
|
+
domain["inference"] = "/inference";
|
3493
|
+
})(domain || (domain = {}));
|
3494
|
+
var resources;
|
3495
|
+
(function (resources) {
|
3496
|
+
resources["chatBubble"] = "/chat-bubble-config";
|
3497
|
+
resources["predefinedQ"] = "/predefined-q";
|
3498
|
+
resources["timeoutQ"] = "/timeout-q";
|
3499
|
+
resources["q"] = "/q";
|
3500
|
+
resources["predefinedQstatistics"] = "/predefined-questions-statistics";
|
3501
|
+
})(resources || (resources = {}));
|
3502
|
+
|
3503
|
+
var getRemoteClientChatPredefinedQuestions = function getRemoteClientChatPredefinedQuestions(pluginAxiosInstance, params) {
|
3499
3504
|
return Promise.resolve(_catch(function () {
|
3500
3505
|
var path = "" + domain.inference + resources.predefinedQ;
|
3501
3506
|
return Promise.resolve(pluginAxiosInstance.get(path, {
|
@@ -3508,7 +3513,7 @@ var getRemoteClientChatPredefinedQuestions = function getRemoteClientChatPredefi
|
|
3508
3513
|
return [];
|
3509
3514
|
}));
|
3510
3515
|
};
|
3511
|
-
var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(params) {
|
3516
|
+
var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(pluginAxiosInstance, params) {
|
3512
3517
|
try {
|
3513
3518
|
return Promise.resolve(_catch(function () {
|
3514
3519
|
var path = "" + domain.inference + resources.chatBubble;
|
@@ -3529,7 +3534,7 @@ var getRemoteClientChatBubbleConfig = function getRemoteClientChatBubbleConfig(p
|
|
3529
3534
|
return Promise.reject(e);
|
3530
3535
|
}
|
3531
3536
|
};
|
3532
|
-
var handleRetries = function handleRetries(data, attempt) {
|
3537
|
+
var handleRetries = function handleRetries(pluginAxiosInstance, data, attempt) {
|
3533
3538
|
try {
|
3534
3539
|
var maxAttempts = 30;
|
3535
3540
|
var delay = 10000;
|
@@ -3540,11 +3545,11 @@ var handleRetries = function handleRetries(data, attempt) {
|
|
3540
3545
|
return setTimeout(resolve, delay);
|
3541
3546
|
})).then(function () {
|
3542
3547
|
return _catch(function () {
|
3543
|
-
return Promise.resolve(askTimedOutBiBot(_extends({}, data, {
|
3548
|
+
return Promise.resolve(askTimedOutBiBot(pluginAxiosInstance, _extends({}, data, {
|
3544
3549
|
tries: attempt + 1
|
3545
3550
|
}))).then(function (message) {
|
3546
3551
|
if (message === defaultSlacker) {
|
3547
|
-
return Promise.resolve(handleRetries(data, attempt + 1));
|
3552
|
+
return Promise.resolve(handleRetries(pluginAxiosInstance, data, attempt + 1));
|
3548
3553
|
} else {
|
3549
3554
|
return message;
|
3550
3555
|
}
|
@@ -3557,13 +3562,13 @@ var handleRetries = function handleRetries(data, attempt) {
|
|
3557
3562
|
return Promise.reject(e);
|
3558
3563
|
}
|
3559
3564
|
};
|
3560
|
-
var askBiBot = function askBiBot(data) {
|
3565
|
+
var askBiBot = function askBiBot(pluginAxiosInstance, data) {
|
3561
3566
|
try {
|
3562
3567
|
return Promise.resolve(_catch(function () {
|
3563
3568
|
var path = "" + domain.inference + resources.q;
|
3564
3569
|
return Promise.resolve(pluginAxiosInstance.post(path, data)).then(function (response) {
|
3565
3570
|
if (response.data.message === defaultSlacker) {
|
3566
|
-
return Promise.resolve(handleRetries(data, 1));
|
3571
|
+
return Promise.resolve(handleRetries(pluginAxiosInstance, data, 1));
|
3567
3572
|
} else {
|
3568
3573
|
return response.data.message;
|
3569
3574
|
}
|
@@ -3577,7 +3582,7 @@ var askBiBot = function askBiBot(data) {
|
|
3577
3582
|
return Promise.reject(e);
|
3578
3583
|
}
|
3579
3584
|
};
|
3580
|
-
var recordPredefinedQ = function recordPredefinedQ(data) {
|
3585
|
+
var recordPredefinedQ = function recordPredefinedQ(pluginAxiosInstance, data) {
|
3581
3586
|
try {
|
3582
3587
|
return Promise.resolve(_catch(function () {
|
3583
3588
|
var path = "" + domain.inference + resources.predefinedQstatistics;
|
@@ -3594,7 +3599,7 @@ var recordPredefinedQ = function recordPredefinedQ(data) {
|
|
3594
3599
|
return Promise.reject(e);
|
3595
3600
|
}
|
3596
3601
|
};
|
3597
|
-
var askTimedOutBiBot = function askTimedOutBiBot(data) {
|
3602
|
+
var askTimedOutBiBot = function askTimedOutBiBot(pluginAxiosInstance, data) {
|
3598
3603
|
try {
|
3599
3604
|
return Promise.resolve(_catch(function () {
|
3600
3605
|
var path = "" + domain.inference + resources.timeoutQ;
|
@@ -3611,7 +3616,6 @@ var askTimedOutBiBot = function askTimedOutBiBot(data) {
|
|
3611
3616
|
}
|
3612
3617
|
};
|
3613
3618
|
var defaultSlacker = "BiBot_Retry_Later";
|
3614
|
-
var pluginAxiosInstance = createPluginAxiosInstance();
|
3615
3619
|
|
3616
3620
|
var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
3617
3621
|
var sendInputInquiry = function sendInputInquiry() {
|
@@ -3629,7 +3633,7 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3629
3633
|
text: input
|
3630
3634
|
}]);
|
3631
3635
|
});
|
3632
|
-
return Promise.resolve(askBiBot({
|
3636
|
+
return Promise.resolve(askBiBot(pluginAxiosInstance, {
|
3633
3637
|
client_id: clientId,
|
3634
3638
|
q: input,
|
3635
3639
|
session_id: client_session_id ? client_session_id : state.sessionId,
|
@@ -3662,7 +3666,7 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3662
3666
|
try {
|
3663
3667
|
setIsLoading(true);
|
3664
3668
|
var input = question.question.trim();
|
3665
|
-
recordPredefinedQ({
|
3669
|
+
recordPredefinedQ(pluginAxiosInstance, {
|
3666
3670
|
"client_id": clientId,
|
3667
3671
|
"question": question.question,
|
3668
3672
|
"q_n_a_id": question.q_n_a_id
|
@@ -3692,7 +3696,10 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3692
3696
|
}
|
3693
3697
|
};
|
3694
3698
|
var clientId = _ref.clientId,
|
3695
|
-
client_session_id = _ref.client_session_id
|
3699
|
+
client_session_id = _ref.client_session_id,
|
3700
|
+
test = _ref.test;
|
3701
|
+
var baseURL = test ? endpoints.getInferenceURL(true) : endpoints.getInferenceURL(false);
|
3702
|
+
var pluginAxiosInstance = createPluginAxiosInstance(baseURL);
|
3696
3703
|
var _useState = React.useState([]),
|
3697
3704
|
predefinedQuestions = _useState[0],
|
3698
3705
|
setPredefinedQuestions = _useState[1];
|
@@ -3725,13 +3732,13 @@ var useBiBotChatBot = function useBiBotChatBot(_ref) {
|
|
3725
3732
|
};
|
3726
3733
|
var getChatBubbleConfig = React.useCallback(function () {
|
3727
3734
|
try {
|
3728
|
-
return Promise.resolve(getRemoteClientChatPredefinedQuestions({
|
3735
|
+
return Promise.resolve(getRemoteClientChatPredefinedQuestions(pluginAxiosInstance, {
|
3729
3736
|
client_id: clientId
|
3730
3737
|
})).then(function (remotePredefinedQuestions) {
|
3731
3738
|
if (remotePredefinedQuestions) {
|
3732
3739
|
setPredefinedQuestions(remotePredefinedQuestions);
|
3733
3740
|
}
|
3734
|
-
return Promise.resolve(getRemoteClientChatBubbleConfig({
|
3741
|
+
return Promise.resolve(getRemoteClientChatBubbleConfig(pluginAxiosInstance, {
|
3735
3742
|
client_id: clientId
|
3736
3743
|
})).then(function (remoteChatBubbleConfig) {
|
3737
3744
|
if (remoteChatBubbleConfig) {
|
@@ -4080,9 +4087,11 @@ var Loader = function Loader() {
|
|
4080
4087
|
var PredefinedQuestions = function PredefinedQuestions(_ref) {
|
4081
4088
|
var questions = _ref.questions,
|
4082
4089
|
onSelect = _ref.onSelect,
|
4083
|
-
clientId = _ref.clientId
|
4090
|
+
clientId = _ref.clientId,
|
4091
|
+
test = _ref.test;
|
4084
4092
|
var _useBiBotChatBot = useBiBotChatBot({
|
4085
|
-
clientId: clientId
|
4093
|
+
clientId: clientId,
|
4094
|
+
test: test
|
4086
4095
|
}),
|
4087
4096
|
chatBubbleConfig = _useBiBotChatBot.chatBubbleConfig;
|
4088
4097
|
return React.createElement("div", {
|
@@ -4139,11 +4148,13 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4139
4148
|
var _chatBubbleConfig$col2, _chatBubbleConfig$col3;
|
4140
4149
|
var clientId = _ref2.clientId,
|
4141
4150
|
client_session_id = _ref2.client_session_id,
|
4142
|
-
redirect_notice = _ref2.redirect_notice
|
4151
|
+
redirect_notice = _ref2.redirect_notice,
|
4152
|
+
test = _ref2.test;
|
4143
4153
|
var _useBiBotChatBot2 = useBiBotChatBot({
|
4144
4154
|
clientId: clientId,
|
4145
4155
|
client_session_id: client_session_id,
|
4146
|
-
redirect_notice: redirect_notice
|
4156
|
+
redirect_notice: redirect_notice,
|
4157
|
+
test: test
|
4147
4158
|
}),
|
4148
4159
|
chatIsOpen = _useBiBotChatBot2.chatIsOpen,
|
4149
4160
|
messages = _useBiBotChatBot2.messages,
|
@@ -4352,11 +4363,14 @@ var ChatBubbleBiBot = function ChatBubbleBiBot(_ref2) {
|
|
4352
4363
|
|
4353
4364
|
var BiBot = function BiBot(_ref) {
|
4354
4365
|
var clientId = _ref.clientId,
|
4355
|
-
client_session_id = _ref.client_session_id
|
4366
|
+
client_session_id = _ref.client_session_id,
|
4367
|
+
redirect_notice = _ref.redirect_notice,
|
4368
|
+
test = _ref.test;
|
4356
4369
|
return React.createElement(AppProvider, null, React.createElement(ChatBubbleBiBot, {
|
4357
4370
|
clientId: clientId,
|
4358
4371
|
client_session_id: client_session_id,
|
4359
|
-
redirect_notice:
|
4372
|
+
redirect_notice: redirect_notice,
|
4373
|
+
test: test
|
4360
4374
|
}));
|
4361
4375
|
};
|
4362
4376
|
|