impact-chatbot 2.3.3 → 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/index.esm.js CHANGED
@@ -23,14 +23,14 @@ import RefreshIcon from '@mui/icons-material/Refresh';
23
23
  import styled from 'styled-components';
24
24
  import { CircularProgress, Typography, Grid } from '@mui/material';
25
25
  import { fetchBaseUrl, replaceSpecialCharacter as replaceSpecialCharacter$1 } from 'core/Utils/functions/utils';
26
- import { ChatBotComponent } from 'impact-ui-chatbot';
27
- import { Button, Modal, Tabs, Slider, Select, DatePicker, Checkbox, RadioButtonGroup, Input, Loader } from 'impact-ui-v3';
26
+ import { Button, Modal, Tabs, Slider, Select, DatePicker, Checkbox, RadioButtonGroup, Input, Loader, ChatBotComponent } from 'impact-ui-v3';
28
27
  import AgGridComponent from 'core/Utils/agGrid';
29
28
  import agGridColumnFormatter from 'core/Utils/agGrid/column-formatter';
30
29
  import CoreChart from 'core/Utils/core-charts';
31
30
  import makeStyles$1 from '@mui/styles/makeStyles';
32
31
  import FormatListBulletedOutlinedIcon from '@mui/icons-material/FormatListBulletedOutlined';
33
32
  import PsychologyOutlinedIcon from '@mui/icons-material/PsychologyOutlined';
33
+ import { stopAgentFlow } from 'core/commonComponents/smartBot/services/chatbot-services';
34
34
  import RangePicker from 'core/commonComponents/dateRangePicker';
35
35
 
36
36
  /**
@@ -1215,6 +1215,7 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
1215
1215
  setUniqueChatId: utilityObjectData?.setUniqueChatId,
1216
1216
  fieldNumber: utilityObjectData?.fieldNumber,
1217
1217
  setFieldNumber: utilityObjectData?.setFieldNumber,
1218
+ baseUrl: baseUrlTemp,
1218
1219
  };
1219
1220
  response = await parseResponse(null, "stream", "", currentModeValue, false, "", {}, payload, utilityObject);
1220
1221
  let chatDataMessages = chatDataInfoRef.current[currentModeValue].conversations[1].messages;
@@ -4348,6 +4349,13 @@ const useRectangleStyles = makeStyles((theme) => ({
4348
4349
  transition: "all 0.2s ease-in-out",
4349
4350
  position: "relative",
4350
4351
  overflow: "hidden",
4352
+ },
4353
+ rectangleHoverable: {
4354
+ cursor: "pointer",
4355
+ "&:hover": {
4356
+ transform: "translateY(-2px)",
4357
+ boxShadow: "0px 4px 12px rgba(0, 0, 0, 0.1)",
4358
+ },
4351
4359
  "&::before": {
4352
4360
  content: '""',
4353
4361
  position: "absolute",
@@ -4422,9 +4430,9 @@ const useRectangleStyles = makeStyles((theme) => ({
4422
4430
  color: "#60697D",
4423
4431
  },
4424
4432
  }));
4425
- const Rectangle = ({ type, icon, title, description, onClick }) => {
4433
+ const Rectangle = ({ type, icon, title, description, onClick, hoverable }) => {
4426
4434
  const classes = useRectangleStyles();
4427
- return (jsx("div", { className: `${classes.rectangle} ${classes[type]}`, onClick: onClick, children: jsxs("div", { className: classes.textContainer, children: [jsx(Typography, { className: classes.title, children: title }), jsx(Typography, { className: classes.description, children: description })] }) }));
4435
+ return (jsx("div", { className: `${classes.rectangle} ${classes[type]} ${hoverable ? classes.rectangleHoverable : ''}`, onClick: onClick, children: jsxs("div", { className: classes.textContainer, children: [jsx(Typography, { className: classes.title, children: title }), jsx(Typography, { className: classes.description, children: description })] }) }));
4428
4436
  };
4429
4437
  const ChatPlaceholder = (props) => {
4430
4438
  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;
@@ -4489,15 +4497,15 @@ const ChatPlaceholder = (props) => {
4489
4497
  useEffect(() => {
4490
4498
  getBaseUrl();
4491
4499
  }, []);
4492
- const handleRectangleClick = (agentId) => {
4500
+ const handleRectangleClick = (agentId, title) => {
4493
4501
  if (legacyAgentScreen) {
4494
4502
  setCurrentAgentId(agentId);
4495
4503
  const initiateAgentPayload = {
4496
4504
  agent_id: agentId,
4497
4505
  session_id: null,
4498
- user_input: userInput,
4506
+ user_input: title,
4499
4507
  init: true,
4500
- delay: 0,
4508
+ delay: 0.3,
4501
4509
  };
4502
4510
  setAgentFlow(initiateAgentPayload, "", baseUrl);
4503
4511
  }
@@ -4539,7 +4547,7 @@ const ChatPlaceholder = (props) => {
4539
4547
  agentId: card.agentId || card.id
4540
4548
  }));
4541
4549
  const dataToMap = legacyAgentScreen ? transformedCardList : rectangleData;
4542
- return (jsxs("div", { className: classes.placeholderContainer, children: [jsx("div", { className: classes.centerIconContainer, children: jsx(SvgCenter3D, { className: classes.centerIcon }) }), jsx(Typography, { variant: "h1", className: classes.heading, children: "Alan's Capabilities" }), jsx(Typography, { variant: "body1", className: classes.headingHelperText, children: "Discover potential issues & opportunities Alan can help you with!" }), jsx("div", { className: classes.rectanglesContainer, children: dataToMap.map((item, index) => (jsx(Rectangle, { type: item.type, icon: item.icon, title: item.title, description: item.description, onClick: () => handleRectangleClick(item.agentId) }, index))) })] }));
4550
+ return (jsxs("div", { className: classes.placeholderContainer, children: [jsx("div", { className: classes.centerIconContainer, children: jsx(SvgCenter3D, { className: classes.centerIcon }) }), jsx(Typography, { variant: "h1", className: classes.heading, children: "Alan's Capabilities" }), jsx(Typography, { variant: "body1", className: classes.headingHelperText, children: "Discover potential issues & opportunities Alan can help you with!" }), jsx("div", { className: classes.rectanglesContainer, children: dataToMap.map((item, index) => (jsx(Rectangle, { type: item.type, icon: item.icon, title: item.title, description: item.description, onClick: () => handleRectangleClick(item?.agentId, item?.title), hoverable: legacyAgentScreen }, index))) })] }));
4543
4551
  };
4544
4552
 
4545
4553
  const dateFormat = "DD-MM-YYYY HH:mm:ss";
@@ -5022,6 +5030,13 @@ const sseevent = (message, messageToStoreRef) => {
5022
5030
  };
5023
5031
  }
5024
5032
  }
5033
+ if (messageToStoreRef.current.currentMode === "agent" &&
5034
+ (parsedData?.chat_id || parsedData?.session_id)) {
5035
+ messageToStoreRef.current.uniqueChatId = parsedData?.chat_id
5036
+ ? parsedData.chat_id
5037
+ : "";
5038
+ messageToStoreRef.current.sessionId = parsedData?.session_id;
5039
+ }
5025
5040
  if (parsedData?.is_error) {
5026
5041
  messageToStoreRef.current.chatData.response =
5027
5042
  messageToStoreRef.current.chatData.response +
@@ -5576,7 +5591,7 @@ const formatThinkingTime = (seconds) => {
5576
5591
  * @param {Function} botData.utilityObject.setChatDataState - Function to update chat data state
5577
5592
  */
5578
5593
  const StreamedContent = ({ botData }) => {
5579
- 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;
5594
+ 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;
5580
5595
  const classes = useStyles$3();
5581
5596
  useStyles$6();
5582
5597
  const dispatch = useDispatch();
@@ -6103,6 +6118,10 @@ const StreamedContent = ({ botData }) => {
6103
6118
  sourceRef.current.close();
6104
6119
  setIsStreaming(false);
6105
6120
  setIsStreamingDone(true);
6121
+ // Stop the agent flow on the backend
6122
+ if (messageToStoreRef.current.sessionId) {
6123
+ stopAgentFlow({ session_id: messageToStoreRef.current.sessionId }, baseUrl);
6124
+ }
6106
6125
  // Clear timeout if exists
6107
6126
  if (streamTimeoutRef.current) {
6108
6127
  clearTimeout(streamTimeoutRef.current);
@@ -9895,7 +9914,7 @@ const SmartBot = (props) => {
9895
9914
  setBaseUrl(customBaseUrl);
9896
9915
  }
9897
9916
  }, [forceOpen]);
9898
- return (jsxs("div", { className: `${classes.agentStyleOverride} ${partialClose ? classes.hideBotStyle : ""}`, children: [jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsx(ChatBotComponent, { isFullWidth: true, userName: userName, showHistoryPanel: false, customInputComponent: currentMode === "agent" ? (jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions })) : null, isChatBotOpen: showModal || forceOpen,
9917
+ return (jsxs("div", { className: `${classes.agentStyleOverride} ${partialClose ? classes.hideBotStyle : ""}`, children: [jsx(MemoryModal, { isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, displaySnackMessages: displaySnackMessages }), jsx(UploadModal, { isUploadModalOpen: isUploadModalOpen, setIsUploadModalOpen: setIsUploadModalOpen, displaySnackMessages: displaySnackMessages }), jsx(ChatBotComponent, { isFullWidth: forceOpen, userName: userName, showHistoryPanel: false, customInputComponent: currentMode === "agent" ? (jsx(ChatbotInput, { newChatScreen: newChatScreen, inputValue: userInput, setInputValue: setUserInput, isStopIcon: isStop, onSendIconClick: onSendIconClick, onStopIconClick: onStopIconClick, currentMode: currentMode, filterOptions: filterOptions })) : null, isChatBotOpen: showModal || forceOpen,
9899
9918
  // landingScreen={true}
9900
9919
  handleNewChatClick: () => {
9901
9920
  localStorage.setItem("isStreaming", "false");