impact-chatbot 2.3.2 → 2.3.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/components/message-template/components/message-content/ImageContent.d.ts +4 -0
- package/dist/index.cjs.js +78 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +79 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/services/chatbot-services.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -26,7 +26,6 @@ var RefreshIcon = require('@mui/icons-material/Refresh');
|
|
|
26
26
|
var styled = require('styled-components');
|
|
27
27
|
var material = require('@mui/material');
|
|
28
28
|
var utils = require('core/Utils/functions/utils');
|
|
29
|
-
var impactUiChatbot = require('impact-ui-chatbot');
|
|
30
29
|
var impactUiV3 = require('impact-ui-v3');
|
|
31
30
|
var AgGridComponent = require('core/Utils/agGrid');
|
|
32
31
|
var agGridColumnFormatter = require('core/Utils/agGrid/column-formatter');
|
|
@@ -34,6 +33,7 @@ var CoreChart = require('core/Utils/core-charts');
|
|
|
34
33
|
var makeStyles = require('@mui/styles/makeStyles');
|
|
35
34
|
var FormatListBulletedOutlinedIcon = require('@mui/icons-material/FormatListBulletedOutlined');
|
|
36
35
|
var PsychologyOutlinedIcon = require('@mui/icons-material/PsychologyOutlined');
|
|
36
|
+
var chatbotServices = require('core/commonComponents/smartBot/services/chatbot-services');
|
|
37
37
|
var RangePicker = require('core/commonComponents/dateRangePicker');
|
|
38
38
|
|
|
39
39
|
function _interopNamespaceDefault(e) {
|
|
@@ -518,6 +518,16 @@ const parseResponse = (data, type, agentId = "", currentMode = "", disableTimeAn
|
|
|
518
518
|
paramName: data?.data?.param_name
|
|
519
519
|
}
|
|
520
520
|
};
|
|
521
|
+
case "image":
|
|
522
|
+
return {
|
|
523
|
+
...data,
|
|
524
|
+
timeStamp: timeString,
|
|
525
|
+
userType: "bot",
|
|
526
|
+
userName: userName,
|
|
527
|
+
headerTitle: data?.response_heading || "",
|
|
528
|
+
bodyType: "image",
|
|
529
|
+
bodyText: data?.image || data,
|
|
530
|
+
};
|
|
521
531
|
case "combined":
|
|
522
532
|
return {
|
|
523
533
|
...data,
|
|
@@ -1227,6 +1237,7 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
|
|
|
1227
1237
|
setUniqueChatId: utilityObjectData?.setUniqueChatId,
|
|
1228
1238
|
fieldNumber: utilityObjectData?.fieldNumber,
|
|
1229
1239
|
setFieldNumber: utilityObjectData?.setFieldNumber,
|
|
1240
|
+
baseUrl: baseUrlTemp,
|
|
1230
1241
|
};
|
|
1231
1242
|
response = await parseResponse(null, "stream", "", currentModeValue, false, "", {}, payload, utilityObject);
|
|
1232
1243
|
let chatDataMessages = chatDataInfoRef.current[currentModeValue].conversations[1].messages;
|
|
@@ -4360,6 +4371,13 @@ const useRectangleStyles = styles.makeStyles((theme) => ({
|
|
|
4360
4371
|
transition: "all 0.2s ease-in-out",
|
|
4361
4372
|
position: "relative",
|
|
4362
4373
|
overflow: "hidden",
|
|
4374
|
+
},
|
|
4375
|
+
rectangleHoverable: {
|
|
4376
|
+
cursor: "pointer",
|
|
4377
|
+
"&:hover": {
|
|
4378
|
+
transform: "translateY(-2px)",
|
|
4379
|
+
boxShadow: "0px 4px 12px rgba(0, 0, 0, 0.1)",
|
|
4380
|
+
},
|
|
4363
4381
|
"&::before": {
|
|
4364
4382
|
content: '""',
|
|
4365
4383
|
position: "absolute",
|
|
@@ -4434,9 +4452,9 @@ const useRectangleStyles = styles.makeStyles((theme) => ({
|
|
|
4434
4452
|
color: "#60697D",
|
|
4435
4453
|
},
|
|
4436
4454
|
}));
|
|
4437
|
-
const Rectangle = ({ type, icon, title, description, onClick }) => {
|
|
4455
|
+
const Rectangle = ({ type, icon, title, description, onClick, hoverable }) => {
|
|
4438
4456
|
const classes = useRectangleStyles();
|
|
4439
|
-
return (jsxRuntime.jsx("div", { className: `${classes.rectangle} ${classes[type]}`, onClick: onClick, children: jsxRuntime.jsxs("div", { className: classes.textContainer, children: [jsxRuntime.jsx(material.Typography, { className: classes.title, children: title }), jsxRuntime.jsx(material.Typography, { className: classes.description, children: description })] }) }));
|
|
4457
|
+
return (jsxRuntime.jsx("div", { className: `${classes.rectangle} ${classes[type]} ${hoverable ? classes.rectangleHoverable : ''}`, onClick: onClick, children: jsxRuntime.jsxs("div", { className: classes.textContainer, children: [jsxRuntime.jsx(material.Typography, { className: classes.title, children: title }), jsxRuntime.jsx(material.Typography, { className: classes.description, children: description })] }) }));
|
|
4440
4458
|
};
|
|
4441
4459
|
const ChatPlaceholder = (props) => {
|
|
4442
4460
|
const { dateFormat, chatDataRef, currentMode, setShowChatPlaceholder, setLoader, setCurrentAgentId, baseUrl, setBaseUrl, setCurrentSessionId, customChatConfig, chatDataInfoRef, setChatDataState, userInput, legacyAgentScreen, activeConversationId, chatBodyRef, chatbotContext, setInitValue, setSessionId, thinkingContent, setThinkingContent, isThinking, setIsThinking, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, uniqueChatId, setUniqueChatId, } = props;
|
|
@@ -4501,15 +4519,15 @@ const ChatPlaceholder = (props) => {
|
|
|
4501
4519
|
React.useEffect(() => {
|
|
4502
4520
|
getBaseUrl();
|
|
4503
4521
|
}, []);
|
|
4504
|
-
const handleRectangleClick = (agentId) => {
|
|
4522
|
+
const handleRectangleClick = (agentId, title) => {
|
|
4505
4523
|
if (legacyAgentScreen) {
|
|
4506
4524
|
setCurrentAgentId(agentId);
|
|
4507
4525
|
const initiateAgentPayload = {
|
|
4508
4526
|
agent_id: agentId,
|
|
4509
4527
|
session_id: null,
|
|
4510
|
-
user_input:
|
|
4528
|
+
user_input: title,
|
|
4511
4529
|
init: true,
|
|
4512
|
-
delay: 0,
|
|
4530
|
+
delay: 0.3,
|
|
4513
4531
|
};
|
|
4514
4532
|
setAgentFlow(initiateAgentPayload, "", baseUrl);
|
|
4515
4533
|
}
|
|
@@ -4551,7 +4569,7 @@ const ChatPlaceholder = (props) => {
|
|
|
4551
4569
|
agentId: card.agentId || card.id
|
|
4552
4570
|
}));
|
|
4553
4571
|
const dataToMap = legacyAgentScreen ? transformedCardList : rectangleData;
|
|
4554
|
-
return (jsxRuntime.jsxs("div", { className: classes.placeholderContainer, children: [jsxRuntime.jsx("div", { className: classes.centerIconContainer, children: jsxRuntime.jsx(SvgCenter3D, { className: classes.centerIcon }) }), jsxRuntime.jsx(material.Typography, { variant: "h1", className: classes.heading, children: "Alan's Capabilities" }), jsxRuntime.jsx(material.Typography, { variant: "body1", className: classes.headingHelperText, children: "Discover potential issues & opportunities Alan can help you with!" }), jsxRuntime.jsx("div", { className: classes.rectanglesContainer, children: dataToMap.map((item, index) => (jsxRuntime.jsx(Rectangle, { type: item.type, icon: item.icon, title: item.title, description: item.description, onClick: () => handleRectangleClick(item
|
|
4572
|
+
return (jsxRuntime.jsxs("div", { className: classes.placeholderContainer, children: [jsxRuntime.jsx("div", { className: classes.centerIconContainer, children: jsxRuntime.jsx(SvgCenter3D, { className: classes.centerIcon }) }), jsxRuntime.jsx(material.Typography, { variant: "h1", className: classes.heading, children: "Alan's Capabilities" }), jsxRuntime.jsx(material.Typography, { variant: "body1", className: classes.headingHelperText, children: "Discover potential issues & opportunities Alan can help you with!" }), jsxRuntime.jsx("div", { className: classes.rectanglesContainer, children: dataToMap.map((item, index) => (jsxRuntime.jsx(Rectangle, { type: item.type, icon: item.icon, title: item.title, description: item.description, onClick: () => handleRectangleClick(item?.agentId, item?.title), hoverable: legacyAgentScreen }, index))) })] }));
|
|
4555
4573
|
};
|
|
4556
4574
|
|
|
4557
4575
|
const dateFormat = "DD-MM-YYYY HH:mm:ss";
|
|
@@ -5034,6 +5052,13 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5034
5052
|
};
|
|
5035
5053
|
}
|
|
5036
5054
|
}
|
|
5055
|
+
if (messageToStoreRef.current.currentMode === "agent" &&
|
|
5056
|
+
(parsedData?.chat_id || parsedData?.session_id)) {
|
|
5057
|
+
messageToStoreRef.current.uniqueChatId = parsedData?.chat_id
|
|
5058
|
+
? parsedData.chat_id
|
|
5059
|
+
: "";
|
|
5060
|
+
messageToStoreRef.current.sessionId = parsedData?.session_id;
|
|
5061
|
+
}
|
|
5037
5062
|
if (parsedData?.is_error) {
|
|
5038
5063
|
messageToStoreRef.current.chatData.response =
|
|
5039
5064
|
messageToStoreRef.current.chatData.response +
|
|
@@ -5101,6 +5126,21 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5101
5126
|
: "";
|
|
5102
5127
|
messageToStoreRef.current.status = parsedData?.status;
|
|
5103
5128
|
}
|
|
5129
|
+
// Handle image chunks for navigation mode
|
|
5130
|
+
if (parsedData?.response_type === "image" &&
|
|
5131
|
+
messageToStoreRef.current.currentMode === "navigation") {
|
|
5132
|
+
let imageData = {
|
|
5133
|
+
type: "image",
|
|
5134
|
+
image: parsedData.image,
|
|
5135
|
+
response_heading: parsedData.response_heading,
|
|
5136
|
+
};
|
|
5137
|
+
let previousData = lodash.isArray(messageToStoreRef.current.appendedData)
|
|
5138
|
+
? messageToStoreRef.current.appendedData
|
|
5139
|
+
: lodash.isEmpty(messageToStoreRef.current.appendedData)
|
|
5140
|
+
? []
|
|
5141
|
+
: [messageToStoreRef.current.appendedData];
|
|
5142
|
+
messageToStoreRef.current.appendedData = [...previousData, imageData];
|
|
5143
|
+
}
|
|
5104
5144
|
return new MessageEvent(type, { data: data });
|
|
5105
5145
|
}
|
|
5106
5146
|
catch (error) {
|
|
@@ -5573,7 +5613,7 @@ const formatThinkingTime = (seconds) => {
|
|
|
5573
5613
|
* @param {Function} botData.utilityObject.setChatDataState - Function to update chat data state
|
|
5574
5614
|
*/
|
|
5575
5615
|
const StreamedContent = ({ botData }) => {
|
|
5576
|
-
const { activeConversationId, currentMode, chatDataRef, chatBodyRef, setChatDataState, chatDataInfoRef, setLoader = (params) => { }, processResponse = (params) => { }, setThinkingContent, thinkingContent, isThinking: isThinkingFromParent, setIsThinking: setIsThinkingFromParent, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, } = botData.utilityObject;
|
|
5616
|
+
const { activeConversationId, currentMode, chatDataRef, chatBodyRef, setChatDataState, chatDataInfoRef, setLoader = (params) => { }, processResponse = (params) => { }, setThinkingContent, thinkingContent, isThinking: isThinkingFromParent, setIsThinking: setIsThinkingFromParent, chatId, setChatId, isStop, setIsStop, functionsRef, functionsState, setFunctionsState, thinkingHeaderMessage, setThinkingHeaderMessage, baseUrl } = botData.utilityObject;
|
|
5577
5617
|
const classes = useStyles$3();
|
|
5578
5618
|
useStyles$6();
|
|
5579
5619
|
const dispatch = reactRedux.useDispatch();
|
|
@@ -5633,6 +5673,7 @@ const StreamedContent = ({ botData }) => {
|
|
|
5633
5673
|
thinkingHeading: botData?.utilityObject?.thinkingResponse?.thinkingHeading
|
|
5634
5674
|
},
|
|
5635
5675
|
},
|
|
5676
|
+
currentMode: currentMode,
|
|
5636
5677
|
appendedData: {},
|
|
5637
5678
|
appendedDataFromLastChunk: {},
|
|
5638
5679
|
initValue: false,
|
|
@@ -6045,6 +6086,11 @@ const StreamedContent = ({ botData }) => {
|
|
|
6045
6086
|
// // enableLikes: true
|
|
6046
6087
|
// },
|
|
6047
6088
|
];
|
|
6089
|
+
let finalData = isArray(messageToStoreRef?.current?.appendedData)
|
|
6090
|
+
? messageToStoreRef?.current?.appendedData
|
|
6091
|
+
: isEmpty(messageToStoreRef?.current?.appendedData)
|
|
6092
|
+
? []
|
|
6093
|
+
: [messageToStoreRef?.current?.appendedData];
|
|
6048
6094
|
let textResponseTobeParsed = {
|
|
6049
6095
|
...messageToStoreRef.current.chatData,
|
|
6050
6096
|
type: "text",
|
|
@@ -6052,7 +6098,7 @@ const StreamedContent = ({ botData }) => {
|
|
|
6052
6098
|
let response = {
|
|
6053
6099
|
data: {
|
|
6054
6100
|
data: {
|
|
6055
|
-
data: [textResponseTobeParsed],
|
|
6101
|
+
data: [textResponseTobeParsed, ...finalData],
|
|
6056
6102
|
},
|
|
6057
6103
|
},
|
|
6058
6104
|
};
|
|
@@ -6094,6 +6140,10 @@ const StreamedContent = ({ botData }) => {
|
|
|
6094
6140
|
sourceRef.current.close();
|
|
6095
6141
|
setIsStreaming(false);
|
|
6096
6142
|
setIsStreamingDone(true);
|
|
6143
|
+
// Stop the agent flow on the backend
|
|
6144
|
+
if (messageToStoreRef.current.sessionId) {
|
|
6145
|
+
chatbotServices.stopAgentFlow({ session_id: messageToStoreRef.current.sessionId }, baseUrl);
|
|
6146
|
+
}
|
|
6097
6147
|
// Clear timeout if exists
|
|
6098
6148
|
if (streamTimeoutRef.current) {
|
|
6099
6149
|
clearTimeout(streamTimeoutRef.current);
|
|
@@ -6394,6 +6444,20 @@ const InputContent = ({ bodyText }) => {
|
|
|
6394
6444
|
return (jsxRuntime.jsx("div", { style: { width: '100%', marginTop: '10px' }, children: jsxRuntime.jsx(impactUiV3.Input, { label: label, placeholder: placeholder, value: value, onChange: handleChange, required: isRequired, disabled: isDisabled, type: inputType || "text", labelOrientation: labelOrientation, maxLength: maxLength, minLength: minLength }) }));
|
|
6395
6445
|
};
|
|
6396
6446
|
|
|
6447
|
+
const ImageContent = ({ bodyText }) => {
|
|
6448
|
+
const { gcs_uri, caption } = bodyText || {};
|
|
6449
|
+
return (jsxRuntime.jsxs("div", { style: {
|
|
6450
|
+
display: "flex",
|
|
6451
|
+
flexDirection: "column",
|
|
6452
|
+
gap: "8px",
|
|
6453
|
+
width: "100%",
|
|
6454
|
+
}, children: [gcs_uri && (jsxRuntime.jsx("img", { src: gcs_uri, alt: caption || "Image", style: {
|
|
6455
|
+
maxWidth: "100%",
|
|
6456
|
+
borderRadius: "8px",
|
|
6457
|
+
objectFit: "contain",
|
|
6458
|
+
} })), caption && (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(TextRenderer, { text: caption }) }))] }));
|
|
6459
|
+
};
|
|
6460
|
+
|
|
6397
6461
|
const useStyles$1 = makeStyles((theme) => ({
|
|
6398
6462
|
stepsContainer: {
|
|
6399
6463
|
display: "flex",
|
|
@@ -6585,6 +6649,8 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
6585
6649
|
return jsxRuntime.jsx(ButtonContent, { bodyText: parsedData.bodyText }, key);
|
|
6586
6650
|
case "input":
|
|
6587
6651
|
return jsxRuntime.jsx(InputContent, { bodyText: parsedData.bodyText }, key);
|
|
6652
|
+
case "image":
|
|
6653
|
+
return jsxRuntime.jsx(ImageContent, { bodyText: parsedData.bodyText }, key);
|
|
6588
6654
|
default:
|
|
6589
6655
|
return null;
|
|
6590
6656
|
}
|
|
@@ -6677,6 +6743,8 @@ const BotMessage = ({ botData, state, handleLikeDislike, props }) => {
|
|
|
6677
6743
|
return jsxRuntime.jsx(ButtonContent, { bodyText: botData.bodyText });
|
|
6678
6744
|
case "input":
|
|
6679
6745
|
return jsxRuntime.jsx(InputContent, { bodyText: botData.bodyText });
|
|
6746
|
+
case "image":
|
|
6747
|
+
return jsxRuntime.jsx(ImageContent, { bodyText: botData.bodyText });
|
|
6680
6748
|
case "combined":
|
|
6681
6749
|
return jsxRuntime.jsx(CombinedContent, { botData: botData, props: props });
|
|
6682
6750
|
case "dynamic":
|
|
@@ -9868,7 +9936,7 @@ const SmartBot = (props) => {
|
|
|
9868
9936
|
setBaseUrl(customBaseUrl);
|
|
9869
9937
|
}
|
|
9870
9938
|
}, [forceOpen]);
|
|
9871
|
-
return (jsxRuntime.jsxs("div", { className: `${classes.agentStyleOverride} ${partialClose ? classes.hideBotStyle : ""}`, children: [jsxRuntime.jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsxRuntime.jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsxRuntime.jsx(
|
|
9939
|
+
return (jsxRuntime.jsxs("div", { className: `${classes.agentStyleOverride} ${partialClose ? classes.hideBotStyle : ""}`, children: [jsxRuntime.jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsxRuntime.jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsxRuntime.jsx(impactUiV3.ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: false, customInputComponent: currentMode === "agent" ? (jsxRuntime.jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions })) : null, isChatBotOpen: showModal || forceOpen,
|
|
9872
9940
|
// landingScreen={true}
|
|
9873
9941
|
handleNewChatClick: () => {
|
|
9874
9942
|
localStorage.setItem("isStreaming", "false");
|