impact-chatbot 2.3.3 → 2.3.5
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/tabular-content/components/Steps.d.ts +3 -1
- package/dist/components/message-template/components/message-content/tabular-content/index.d.ts +3 -1
- package/dist/components/message-template/components/message-types/streamed-content/steps-response-tab/components/Steps.d.ts +3 -1
- package/dist/core/commonComponents/custom-group-accordion/index.d.ts +5 -0
- package/dist/index.cjs.js +387 -118
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +389 -120
- package/dist/index.esm.js.map +1 -1
- package/dist/services/chatbot-services.d.ts +1 -0
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { cloneDeep, isEmpty as isEmpty$1, isNull, isArray as isArray$1, isObject, throttle } from 'lodash';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { useCallback, useState, useEffect, useRef, useMemo } from 'react';
|
|
4
|
+
import React__default, { useCallback, useState, useEffect, useRef, useMemo } from 'react';
|
|
5
5
|
import { COMBINED_CROSS_DIMENSIONAL_API, BASE_API } from 'config/api';
|
|
6
6
|
import axiosInstance from 'core/Utils/axios';
|
|
7
7
|
import 'core/actions/tenantConfigActions';
|
|
@@ -22,15 +22,17 @@ import { useNavigate, useLocation } from 'react-router-dom-v5-compat';
|
|
|
22
22
|
import RefreshIcon from '@mui/icons-material/Refresh';
|
|
23
23
|
import styled from 'styled-components';
|
|
24
24
|
import { CircularProgress, Typography, Grid } from '@mui/material';
|
|
25
|
-
import { fetchBaseUrl, replaceSpecialCharacter as replaceSpecialCharacter$1 } from 'core/Utils/functions/utils';
|
|
26
|
-
import { ChatBotComponent } from 'impact-ui-
|
|
27
|
-
import { Button, Modal, Tabs, Slider, Select, DatePicker, Checkbox, RadioButtonGroup, Input, Loader } from 'impact-ui-v3';
|
|
25
|
+
import { fetchBaseUrl, replaceSpecialCharacter as replaceSpecialCharacter$1, fetchLegacyAgentScreen } from 'core/Utils/functions/utils';
|
|
26
|
+
import { Button, Modal, AccordionModern, 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';
|
|
31
|
+
import globalStyles$1 from 'core/Styles/globalStyles';
|
|
32
|
+
import CircularProgress$1 from '@mui/material/CircularProgress';
|
|
32
33
|
import FormatListBulletedOutlinedIcon from '@mui/icons-material/FormatListBulletedOutlined';
|
|
33
34
|
import PsychologyOutlinedIcon from '@mui/icons-material/PsychologyOutlined';
|
|
35
|
+
import { stopAgentFlow } from 'core/commonComponents/smartBot/services/chatbot-services';
|
|
34
36
|
import RangePicker from 'core/commonComponents/dateRangePicker';
|
|
35
37
|
|
|
36
38
|
/**
|
|
@@ -918,14 +920,6 @@ const getFormattedApplicationName = (applicationURL) => {
|
|
|
918
920
|
}
|
|
919
921
|
};
|
|
920
922
|
|
|
921
|
-
// Fetch legacy agent screen - stub implementation
|
|
922
|
-
const fetchLegacyAgentScreen = () => {
|
|
923
|
-
// This function is kept as a stub since it's rarely used
|
|
924
|
-
// The actual implementation will be provided by the host app if needed
|
|
925
|
-
console.warn("fetchLegacyAgentScreen called - this is a stub implementation");
|
|
926
|
-
return null;
|
|
927
|
-
};
|
|
928
|
-
|
|
929
923
|
/**
|
|
930
924
|
* Preprocesses markdown content to improve list formatting
|
|
931
925
|
*/
|
|
@@ -1215,6 +1209,7 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
|
|
|
1215
1209
|
setUniqueChatId: utilityObjectData?.setUniqueChatId,
|
|
1216
1210
|
fieldNumber: utilityObjectData?.fieldNumber,
|
|
1217
1211
|
setFieldNumber: utilityObjectData?.setFieldNumber,
|
|
1212
|
+
baseUrl: baseUrlTemp,
|
|
1218
1213
|
};
|
|
1219
1214
|
response = await parseResponse(null, "stream", "", currentModeValue, false, "", {}, payload, utilityObject);
|
|
1220
1215
|
let chatDataMessages = chatDataInfoRef.current[currentModeValue].conversations[1].messages;
|
|
@@ -1845,6 +1840,8 @@ const useAgentFlow = (dateFormat, chatDataRef, currentMode, setShowChatPlacehold
|
|
|
1845
1840
|
isTabEnabled: utilsObject?.isTabEnabled,
|
|
1846
1841
|
steps: utilsObject?.steps,
|
|
1847
1842
|
currentTabValue: utilsObject?.currentTabValue,
|
|
1843
|
+
questions: utilsObject?.questions,
|
|
1844
|
+
questionsStepsMap: utilsObject?.questionsStepsMap,
|
|
1848
1845
|
}, null, { thinkingResponse: thinkingInfo });
|
|
1849
1846
|
}
|
|
1850
1847
|
}
|
|
@@ -4348,6 +4345,13 @@ const useRectangleStyles = makeStyles((theme) => ({
|
|
|
4348
4345
|
transition: "all 0.2s ease-in-out",
|
|
4349
4346
|
position: "relative",
|
|
4350
4347
|
overflow: "hidden",
|
|
4348
|
+
},
|
|
4349
|
+
rectangleHoverable: {
|
|
4350
|
+
cursor: "pointer",
|
|
4351
|
+
"&:hover": {
|
|
4352
|
+
transform: "translateY(-2px)",
|
|
4353
|
+
boxShadow: "0px 4px 12px rgba(0, 0, 0, 0.1)",
|
|
4354
|
+
},
|
|
4351
4355
|
"&::before": {
|
|
4352
4356
|
content: '""',
|
|
4353
4357
|
position: "absolute",
|
|
@@ -4422,12 +4426,12 @@ const useRectangleStyles = makeStyles((theme) => ({
|
|
|
4422
4426
|
color: "#60697D",
|
|
4423
4427
|
},
|
|
4424
4428
|
}));
|
|
4425
|
-
const Rectangle = ({ type, icon, title, description, onClick }) => {
|
|
4429
|
+
const Rectangle = ({ type, icon, title, description, onClick, hoverable }) => {
|
|
4426
4430
|
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 })] }) }));
|
|
4431
|
+
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
4432
|
};
|
|
4429
4433
|
const ChatPlaceholder = (props) => {
|
|
4430
|
-
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;
|
|
4434
|
+
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, fieldNumber, setFieldNumber, } = props;
|
|
4431
4435
|
const classes = useStyles$5();
|
|
4432
4436
|
globalStyles();
|
|
4433
4437
|
const [cardList, setCardList] = useState([]);
|
|
@@ -4455,6 +4459,8 @@ const ChatPlaceholder = (props) => {
|
|
|
4455
4459
|
setThinkingHeaderMessage,
|
|
4456
4460
|
uniqueChatId,
|
|
4457
4461
|
setUniqueChatId,
|
|
4462
|
+
fieldNumber,
|
|
4463
|
+
setFieldNumber,
|
|
4458
4464
|
});
|
|
4459
4465
|
const getBaseUrl = async () => {
|
|
4460
4466
|
try {
|
|
@@ -4489,15 +4495,15 @@ const ChatPlaceholder = (props) => {
|
|
|
4489
4495
|
useEffect(() => {
|
|
4490
4496
|
getBaseUrl();
|
|
4491
4497
|
}, []);
|
|
4492
|
-
const handleRectangleClick = (agentId) => {
|
|
4498
|
+
const handleRectangleClick = (agentId, title) => {
|
|
4493
4499
|
if (legacyAgentScreen) {
|
|
4494
4500
|
setCurrentAgentId(agentId);
|
|
4495
4501
|
const initiateAgentPayload = {
|
|
4496
4502
|
agent_id: agentId,
|
|
4497
4503
|
session_id: null,
|
|
4498
|
-
user_input:
|
|
4504
|
+
user_input: title,
|
|
4499
4505
|
init: true,
|
|
4500
|
-
delay: 0,
|
|
4506
|
+
delay: 0.3,
|
|
4501
4507
|
};
|
|
4502
4508
|
setAgentFlow(initiateAgentPayload, "", baseUrl);
|
|
4503
4509
|
}
|
|
@@ -4535,11 +4541,11 @@ const ChatPlaceholder = (props) => {
|
|
|
4535
4541
|
type: "blue",
|
|
4536
4542
|
icon: jsx(SvgCircular3D, {}),
|
|
4537
4543
|
title: card.name || card.title || "Agent",
|
|
4538
|
-
description: card.description || card.helpText || "
|
|
4544
|
+
description: card.description || card.helpText || "",
|
|
4539
4545
|
agentId: card.agentId || card.id
|
|
4540
4546
|
}));
|
|
4541
4547
|
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
|
|
4548
|
+
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
4549
|
};
|
|
4544
4550
|
|
|
4545
4551
|
const dateFormat = "DD-MM-YYYY HH:mm:ss";
|
|
@@ -5022,6 +5028,13 @@ const sseevent = (message, messageToStoreRef) => {
|
|
|
5022
5028
|
};
|
|
5023
5029
|
}
|
|
5024
5030
|
}
|
|
5031
|
+
if (messageToStoreRef.current.currentMode === "agent" &&
|
|
5032
|
+
(parsedData?.chat_id || parsedData?.session_id)) {
|
|
5033
|
+
messageToStoreRef.current.uniqueChatId = parsedData?.chat_id
|
|
5034
|
+
? parsedData.chat_id
|
|
5035
|
+
: "";
|
|
5036
|
+
messageToStoreRef.current.sessionId = parsedData?.session_id;
|
|
5037
|
+
}
|
|
5025
5038
|
if (parsedData?.is_error) {
|
|
5026
5039
|
messageToStoreRef.current.chatData.response =
|
|
5027
5040
|
messageToStoreRef.current.chatData.response +
|
|
@@ -5383,26 +5396,57 @@ var SvgStepError = function SvgStepError(props) {
|
|
|
5383
5396
|
})));
|
|
5384
5397
|
};
|
|
5385
5398
|
|
|
5399
|
+
const CustomGroupAccordion = ({ children, onExpandChange, }) => {
|
|
5400
|
+
const globalClasses = globalStyles$1();
|
|
5401
|
+
const [accordionData, setAccordionData] = useState([]);
|
|
5402
|
+
const [activeAccordion, setActiveAccordion] = useState("");
|
|
5403
|
+
const prepareAccordionData = () => {
|
|
5404
|
+
const data = [];
|
|
5405
|
+
React__default.Children.toArray(children).forEach((child, index) => {
|
|
5406
|
+
data.push({
|
|
5407
|
+
id: index + 1,
|
|
5408
|
+
header: child.props.accordionName,
|
|
5409
|
+
content: child,
|
|
5410
|
+
value: child.props.accordionValue || child.props.accordionName,
|
|
5411
|
+
childCount: child.props.accordionChildCount,
|
|
5412
|
+
});
|
|
5413
|
+
});
|
|
5414
|
+
setAccordionData(data);
|
|
5415
|
+
};
|
|
5416
|
+
useEffect(() => {
|
|
5417
|
+
prepareAccordionData();
|
|
5418
|
+
}, [children]);
|
|
5419
|
+
return (jsx("div", { className: globalClasses.accordianWrapper, children: jsx(AccordionModern, { data: accordionData, expanded: activeAccordion, setExpanded: (val) => {
|
|
5420
|
+
setActiveAccordion(val);
|
|
5421
|
+
onExpandChange?.(val);
|
|
5422
|
+
} }) }));
|
|
5423
|
+
};
|
|
5424
|
+
|
|
5386
5425
|
const useStyles$2 = makeStyles$1((theme) => ({
|
|
5426
|
+
"@global": {
|
|
5427
|
+
"@keyframes stepsLoaderSpin": {
|
|
5428
|
+
"0%": {
|
|
5429
|
+
transform: "rotate(0deg)",
|
|
5430
|
+
},
|
|
5431
|
+
"100%": {
|
|
5432
|
+
transform: "rotate(360deg)",
|
|
5433
|
+
},
|
|
5434
|
+
},
|
|
5435
|
+
},
|
|
5387
5436
|
stepsContainer: {
|
|
5388
5437
|
display: "flex",
|
|
5389
5438
|
flexDirection: "column",
|
|
5390
|
-
gap:
|
|
5439
|
+
gap: pxToRem(20),
|
|
5391
5440
|
background: colours.white,
|
|
5392
|
-
marginTop:
|
|
5441
|
+
marginTop: pxToRem(20),
|
|
5393
5442
|
},
|
|
5394
5443
|
stepItem: {
|
|
5395
5444
|
display: "flex",
|
|
5396
5445
|
alignItems: "center",
|
|
5397
5446
|
gap: "12px",
|
|
5398
5447
|
},
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
transform: "rotate(0deg)",
|
|
5402
|
-
},
|
|
5403
|
-
"100%": {
|
|
5404
|
-
transform: "rotate(360deg)",
|
|
5405
|
-
}
|
|
5448
|
+
mt12: {
|
|
5449
|
+
marginTop: pxToRem(12),
|
|
5406
5450
|
},
|
|
5407
5451
|
stepStatus: {
|
|
5408
5452
|
display: "flex",
|
|
@@ -5416,7 +5460,7 @@ const useStyles$2 = makeStyles$1((theme) => ({
|
|
|
5416
5460
|
"&.loading": {
|
|
5417
5461
|
background: colours.backgroundChat,
|
|
5418
5462
|
"& svg": {
|
|
5419
|
-
animation: "
|
|
5463
|
+
animation: "stepsLoaderSpin 1s linear infinite",
|
|
5420
5464
|
}
|
|
5421
5465
|
},
|
|
5422
5466
|
"&.error": {
|
|
@@ -5435,10 +5479,10 @@ const useStyles$2 = makeStyles$1((theme) => ({
|
|
|
5435
5479
|
stepHeader: {
|
|
5436
5480
|
color: colours.oceanGreen,
|
|
5437
5481
|
fontFamily: "Manrope",
|
|
5438
|
-
fontSize:
|
|
5482
|
+
fontSize: pxToRem(14),
|
|
5439
5483
|
fontStyle: "normal",
|
|
5440
5484
|
fontWeight: 500,
|
|
5441
|
-
lineHeight:
|
|
5485
|
+
lineHeight: pxToRem(20),
|
|
5442
5486
|
"&.loading": {
|
|
5443
5487
|
color: colours.brightRoyalBlue,
|
|
5444
5488
|
},
|
|
@@ -5449,25 +5493,131 @@ const useStyles$2 = makeStyles$1((theme) => ({
|
|
|
5449
5493
|
stepSubheader: {
|
|
5450
5494
|
color: colours.neutrals,
|
|
5451
5495
|
fontFamily: "Manrope",
|
|
5452
|
-
fontSize:
|
|
5496
|
+
fontSize: pxToRem(12),
|
|
5453
5497
|
fontStyle: "normal",
|
|
5454
5498
|
fontWeight: 500,
|
|
5455
|
-
lineHeight:
|
|
5499
|
+
lineHeight: pxToRem(16),
|
|
5500
|
+
},
|
|
5501
|
+
"@keyframes slideDown": {
|
|
5502
|
+
"0%": {
|
|
5503
|
+
opacity: 0,
|
|
5504
|
+
maxHeight: 0,
|
|
5505
|
+
transform: "translateY(-12px)",
|
|
5506
|
+
},
|
|
5507
|
+
"100%": {
|
|
5508
|
+
opacity: 1,
|
|
5509
|
+
maxHeight: "2000px",
|
|
5510
|
+
transform: "translateY(0)",
|
|
5511
|
+
},
|
|
5512
|
+
},
|
|
5513
|
+
loaderContainer: {
|
|
5514
|
+
display: "flex",
|
|
5515
|
+
flexDirection: "column",
|
|
5516
|
+
justifyContent: "center",
|
|
5517
|
+
alignItems: "center",
|
|
5518
|
+
padding: pxToRem(40),
|
|
5519
|
+
},
|
|
5520
|
+
loader: {
|
|
5521
|
+
color: "#435af0",
|
|
5522
|
+
},
|
|
5523
|
+
loaderCaption: {
|
|
5524
|
+
color: colours.neutrals,
|
|
5525
|
+
fontFamily: "Manrope",
|
|
5526
|
+
fontSize: pxToRem(13),
|
|
5527
|
+
fontWeight: 500,
|
|
5528
|
+
marginTop: pxToRem(12),
|
|
5529
|
+
},
|
|
5530
|
+
accordionAnimated: {
|
|
5531
|
+
animation: "$slideDown 0.4s ease-out forwards",
|
|
5532
|
+
overflow: "hidden",
|
|
5533
|
+
"& .impact-modern-accordion-item .impact-modern-accordion-header": {
|
|
5534
|
+
height: "auto",
|
|
5535
|
+
alignItems: "flex-start",
|
|
5536
|
+
padding: `${pxToRem(16)} ${pxToRem(16)} ${pxToRem(8)} ${pxToRem(16)} !important`
|
|
5537
|
+
},
|
|
5538
|
+
"& .loading svg": {
|
|
5539
|
+
animation: "stepsLoaderSpin 1s linear infinite !important",
|
|
5540
|
+
},
|
|
5541
|
+
"& .impact-modern-accordion-item .impact-modern-accordion-content": {
|
|
5542
|
+
padding: `${pxToRem(0)} ${pxToRem(42)} ${pxToRem(8)} ${pxToRem(32)} !important`
|
|
5543
|
+
},
|
|
5544
|
+
"& .impact-modern-accordion-item .impact-modern-accordion-header .impact-modern-accordion-expand-icon": {
|
|
5545
|
+
width: `${pxToRem(24)} !important`,
|
|
5546
|
+
height: `${pxToRem(24)} !important`,
|
|
5547
|
+
}
|
|
5548
|
+
},
|
|
5549
|
+
accordionStepsWrapper: {
|
|
5550
|
+
display: "flex",
|
|
5551
|
+
flexDirection: "column",
|
|
5552
|
+
gap: pxToRem(12),
|
|
5553
|
+
},
|
|
5554
|
+
accordionHeaderWrapper: {
|
|
5555
|
+
display: "flex",
|
|
5556
|
+
flexDirection: "column",
|
|
5557
|
+
gap: pxToRem(16),
|
|
5558
|
+
width: "100%",
|
|
5559
|
+
},
|
|
5560
|
+
accordionHeaderQuestion: {
|
|
5561
|
+
fontFamily: "Manrope",
|
|
5562
|
+
fontSize: pxToRem(14),
|
|
5563
|
+
fontWeight: 600,
|
|
5564
|
+
},
|
|
5565
|
+
headerStepPreview: {
|
|
5566
|
+
marginLeft: pxToRem(-20),
|
|
5567
|
+
},
|
|
5568
|
+
closedAccordionStep: {
|
|
5569
|
+
display: "flex",
|
|
5570
|
+
alignItems: "center",
|
|
5571
|
+
gap: "8px",
|
|
5572
|
+
marginTop: pxToRem(4),
|
|
5573
|
+
"& svg": {
|
|
5574
|
+
width: "14px",
|
|
5575
|
+
height: "14px",
|
|
5576
|
+
flexShrink: 0,
|
|
5577
|
+
},
|
|
5578
|
+
},
|
|
5579
|
+
closedStepLoading: {
|
|
5580
|
+
"& svg": {
|
|
5581
|
+
animation: "stepsLoaderSpin 1s linear infinite",
|
|
5582
|
+
},
|
|
5583
|
+
},
|
|
5584
|
+
closedStepText: {
|
|
5585
|
+
fontFamily: "Manrope",
|
|
5586
|
+
fontSize: pxToRem(12),
|
|
5587
|
+
fontWeight: 500,
|
|
5588
|
+
color: colours.neutrals,
|
|
5589
|
+
"&.loading": {
|
|
5590
|
+
color: colours.brightRoyalBlue,
|
|
5591
|
+
},
|
|
5592
|
+
"&.completed": {
|
|
5593
|
+
color: colours.oceanGreen,
|
|
5594
|
+
},
|
|
5456
5595
|
},
|
|
5457
5596
|
}));
|
|
5458
|
-
const
|
|
5597
|
+
const StepItemRenderer$1 = ({ step, classes }) => (jsxs("div", { className: classes.stepItem, children: [jsx("div", { className: `${classes.stepStatus} ${step.step_status === "not-completed"
|
|
5598
|
+
? "loading"
|
|
5599
|
+
: step.step_status === "error"
|
|
5600
|
+
? "error"
|
|
5601
|
+
: ""}`, children: step.step_status === "not-completed" ? (jsx(SvgStepsLoader, {})) : step.step_status === "error" ? (jsx(SvgStepError, {})) : (jsx(SvgStepDone, {})) }), jsxs("div", { className: classes.stepContent, children: [jsx("div", { className: `${classes.stepHeader} ${step.step_status === "not-completed"
|
|
5602
|
+
? "loading"
|
|
5603
|
+
: step.step_status === "error"
|
|
5604
|
+
? "error"
|
|
5605
|
+
: ""}`, children: step.header }), jsx("div", { className: classes.stepSubheader, children: step.sub_header })] })] }));
|
|
5606
|
+
const getActiveStep = (stepsForQuestion) => {
|
|
5607
|
+
if (!stepsForQuestion || stepsForQuestion.length === 0)
|
|
5608
|
+
return null;
|
|
5609
|
+
const loadingStep = stepsForQuestion.find((s) => s.step_status === "not-completed");
|
|
5610
|
+
if (loadingStep)
|
|
5611
|
+
return loadingStep;
|
|
5612
|
+
return stepsForQuestion[stepsForQuestion.length - 1];
|
|
5613
|
+
};
|
|
5614
|
+
const AccordionStepsContent$1 = ({ questionSteps, classes, accordionName, accordionChildCount = "", accordionValue }) => {
|
|
5615
|
+
return (jsx("div", { className: classes.accordionStepsWrapper, children: jsx("div", { className: `${classes.stepsContainer} ${classes.mt12}`, children: questionSteps.map((step, index) => (jsx(StepItemRenderer$1, { step: step, classes: classes }, index))) }) }));
|
|
5616
|
+
};
|
|
5617
|
+
const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, setFinalStepDone, stepChange, currentMode, questions = [], questionsStepsMap = {}, }) => {
|
|
5459
5618
|
const classes = useStyles$2();
|
|
5460
5619
|
useState(false);
|
|
5461
|
-
|
|
5462
|
-
// if (steps.length > 0) {
|
|
5463
|
-
// // Mark all previous steps as done and last step as loading
|
|
5464
|
-
// const updatedSteps = steps.map((step, index) => ({
|
|
5465
|
-
// ...step,
|
|
5466
|
-
// status: index === steps.length - 1 ? "loading" : "done"
|
|
5467
|
-
// }));
|
|
5468
|
-
// setSteps(updatedSteps);
|
|
5469
|
-
// }
|
|
5470
|
-
// }, [steps]);
|
|
5620
|
+
const [expandedAccordion, setExpandedAccordion] = useState("");
|
|
5471
5621
|
useEffect(() => {
|
|
5472
5622
|
if (done) {
|
|
5473
5623
|
// Add finished step when done is true
|
|
@@ -5502,15 +5652,38 @@ const Steps$1 = ({ steps, setSteps, done, setTabValue, setDone, finalStepDone, s
|
|
|
5502
5652
|
}
|
|
5503
5653
|
}
|
|
5504
5654
|
}, [done]);
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5655
|
+
const hasQuestions = questions.length > 0;
|
|
5656
|
+
if (!hasQuestions) {
|
|
5657
|
+
if (currentMode === "agent" && steps.length === 1) {
|
|
5658
|
+
return (jsxs("div", { className: classes.loaderContainer, children: [jsx(CircularProgress$1, { className: classes.loader, size: 50, thickness: 4 }), jsx("span", { className: classes.loaderCaption, children: "Analyzing next steps..." })] }));
|
|
5659
|
+
}
|
|
5660
|
+
if (steps.length > 0) {
|
|
5661
|
+
const fallbackQuestion = "Processing Request";
|
|
5662
|
+
const activeStep = getActiveStep(steps);
|
|
5663
|
+
const isExpanded = expandedAccordion === fallbackQuestion;
|
|
5664
|
+
const accordionHeader = (jsxs("div", { className: classes.accordionHeaderWrapper, children: [jsx("div", { className: classes.accordionHeaderQuestion, children: fallbackQuestion }), !isExpanded && activeStep && (jsx("div", { className: classes.headerStepPreview, children: jsx(StepItemRenderer$1, { step: activeStep, classes: classes }) }))] }));
|
|
5665
|
+
return (jsx("div", { className: `${classes.stepsContainer} ${classes.accordionAnimated}`, children: jsx(CustomGroupAccordion, { onExpandChange: (val) => setExpandedAccordion(val), children: jsx(AccordionStepsContent$1, { questionSteps: steps, classes: classes, accordionName: accordionHeader, accordionValue: fallbackQuestion }) }) }));
|
|
5666
|
+
}
|
|
5667
|
+
return null;
|
|
5668
|
+
}
|
|
5669
|
+
return (jsx("div", { className: `${classes.stepsContainer} ${classes.accordionAnimated}`, children: jsx(CustomGroupAccordion, { onExpandChange: (val) => setExpandedAccordion(val), children: questions.map((question, index) => {
|
|
5670
|
+
const questionSteps = questionsStepsMap[question] || [
|
|
5671
|
+
{
|
|
5672
|
+
header: "Processing Request",
|
|
5673
|
+
sub_header: "Analyzing the current request",
|
|
5674
|
+
step_status: "not-completed",
|
|
5675
|
+
},
|
|
5676
|
+
];
|
|
5677
|
+
const activeStep = getActiveStep(questionSteps);
|
|
5678
|
+
const stepCount = questionSteps.length;
|
|
5679
|
+
const completedCount = questionSteps.filter((s) => s.step_status === "completed").length;
|
|
5680
|
+
activeStep
|
|
5681
|
+
? `${activeStep.header} - Step ${completedCount}/${stepCount}`
|
|
5682
|
+
: "";
|
|
5683
|
+
const isExpanded = expandedAccordion === question;
|
|
5684
|
+
const accordionHeader = (jsxs("div", { className: classes.accordionHeaderWrapper, children: [jsx("div", { className: classes.accordionHeaderQuestion, children: question }), !isExpanded && activeStep && (jsx("div", { className: classes.headerStepPreview, children: jsx(StepItemRenderer$1, { step: activeStep, classes: classes }) }))] }));
|
|
5685
|
+
return (jsx(AccordionStepsContent$1, { questionSteps: questionSteps, classes: classes, accordionName: accordionHeader, accordionValue: question }, index));
|
|
5686
|
+
}) }) }));
|
|
5514
5687
|
};
|
|
5515
5688
|
|
|
5516
5689
|
const AgentResponse$1 = (props) => {
|
|
@@ -5523,7 +5696,7 @@ const AgentResponse$1 = (props) => {
|
|
|
5523
5696
|
};
|
|
5524
5697
|
|
|
5525
5698
|
const StepsResponseTab = (props) => {
|
|
5526
|
-
const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, } = props;
|
|
5699
|
+
const { steps, setSteps, stepsDone, setStepsDone, finalStepDone, setFinalStepDone, content, isStreaming, stepChange, currentMode, questions, questionsStepsMap, } = props;
|
|
5527
5700
|
const [tabValue, setTabValue] = useState("steps");
|
|
5528
5701
|
const handleChangeTabValue = (_event, newValue) => {
|
|
5529
5702
|
setTabValue(newValue);
|
|
@@ -5540,7 +5713,7 @@ const StepsResponseTab = (props) => {
|
|
|
5540
5713
|
icon: jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
|
|
5541
5714
|
},
|
|
5542
5715
|
], tabPanels: [
|
|
5543
|
-
jsx(Steps$1, { steps: steps, setSteps: setSteps, done: stepsDone, setDone: setStepsDone, setTabValue: setTabValue, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, stepChange: stepChange, currentMode: currentMode }),
|
|
5716
|
+
jsx(Steps$1, { steps: steps, setSteps: setSteps, done: stepsDone, setDone: setStepsDone, setTabValue: setTabValue, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, stepChange: stepChange, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap }),
|
|
5544
5717
|
jsx(AgentResponse$1, { content: content, isStreaming: isStreaming }),
|
|
5545
5718
|
], value: tabValue }) }));
|
|
5546
5719
|
};
|
|
@@ -5576,7 +5749,7 @@ const formatThinkingTime = (seconds) => {
|
|
|
5576
5749
|
* @param {Function} botData.utilityObject.setChatDataState - Function to update chat data state
|
|
5577
5750
|
*/
|
|
5578
5751
|
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;
|
|
5752
|
+
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
5753
|
const classes = useStyles$3();
|
|
5581
5754
|
useStyles$6();
|
|
5582
5755
|
const dispatch = useDispatch();
|
|
@@ -5598,6 +5771,8 @@ const StreamedContent = ({ botData }) => {
|
|
|
5598
5771
|
step_status: "not-completed"
|
|
5599
5772
|
}
|
|
5600
5773
|
]);
|
|
5774
|
+
const [questions, setQuestions] = useState([]);
|
|
5775
|
+
const [questionsStepsMap, setQuestionsStepsMap] = useState({});
|
|
5601
5776
|
const [stepChange, setStepChange] = useState(false);
|
|
5602
5777
|
const [stepsDone, setStepsDone] = useState(false);
|
|
5603
5778
|
const [finalStepDone, setFinalStepDone] = useState(false);
|
|
@@ -5614,6 +5789,8 @@ const StreamedContent = ({ botData }) => {
|
|
|
5614
5789
|
step_status: "not-completed"
|
|
5615
5790
|
}
|
|
5616
5791
|
]);
|
|
5792
|
+
const questionsRef = useRef([]);
|
|
5793
|
+
const questionsStepsMapRef = useRef({});
|
|
5617
5794
|
// Refs to maintain data across renders
|
|
5618
5795
|
const sourceRef = useRef(null); // Holds the SSE source instance
|
|
5619
5796
|
useRef(""); // Tracks the last received message
|
|
@@ -5703,8 +5880,25 @@ const StreamedContent = ({ botData }) => {
|
|
|
5703
5880
|
thinkingStartTimeRef.current = Date.now();
|
|
5704
5881
|
}
|
|
5705
5882
|
const data = JSON.parse(event.data);
|
|
5706
|
-
if (data?.message || data?.status === "step" || data?.status === "thinking") {
|
|
5707
|
-
if (data.status === "
|
|
5883
|
+
if (data?.message || data?.status === "step" || data?.status === "thinking" || data?.status === "questions") {
|
|
5884
|
+
if (data.status === "questions") {
|
|
5885
|
+
const incomingQuestions = data.widget_data?.[0]?.questions || [];
|
|
5886
|
+
questionsRef.current = incomingQuestions;
|
|
5887
|
+
setQuestions(incomingQuestions);
|
|
5888
|
+
const initialMap = {};
|
|
5889
|
+
incomingQuestions.forEach((q) => {
|
|
5890
|
+
initialMap[q] = [
|
|
5891
|
+
{
|
|
5892
|
+
header: "Processing Request",
|
|
5893
|
+
sub_header: "Analyzing the current request",
|
|
5894
|
+
step_status: "not-completed",
|
|
5895
|
+
},
|
|
5896
|
+
];
|
|
5897
|
+
});
|
|
5898
|
+
questionsStepsMapRef.current = initialMap;
|
|
5899
|
+
setQuestionsStepsMap(cloneDeep(initialMap));
|
|
5900
|
+
}
|
|
5901
|
+
else if (data.status === "thinking") {
|
|
5708
5902
|
messageToStoreRef.current.chatData.thinkingResponse.thinkingHeading = "Planning next moves";
|
|
5709
5903
|
// Start thinking if not already started
|
|
5710
5904
|
if (!isThinking) {
|
|
@@ -5743,6 +5937,7 @@ const StreamedContent = ({ botData }) => {
|
|
|
5743
5937
|
}
|
|
5744
5938
|
else if (data.status === "step") {
|
|
5745
5939
|
let newStep = data.widget_data[0];
|
|
5940
|
+
const currentIntent = data.widget_data[0]?.current_intent;
|
|
5746
5941
|
setSteps([...steps, newStep]);
|
|
5747
5942
|
let newSteps = cloneDeep(stepRef.current);
|
|
5748
5943
|
if (newSteps.length === 1) {
|
|
@@ -5752,15 +5947,28 @@ const StreamedContent = ({ botData }) => {
|
|
|
5752
5947
|
}
|
|
5753
5948
|
const existingStepIndex = newSteps.findIndex((step) => step.header === newStep.header);
|
|
5754
5949
|
if (existingStepIndex !== -1) {
|
|
5755
|
-
// Replace the existing step at the same position
|
|
5756
5950
|
newSteps[existingStepIndex] = newStep;
|
|
5757
5951
|
}
|
|
5758
5952
|
else {
|
|
5759
|
-
// If no matching step found, add it to the end
|
|
5760
5953
|
newSteps.push(newStep);
|
|
5761
5954
|
}
|
|
5762
5955
|
stepRef.current = newSteps;
|
|
5763
5956
|
setSteps(newSteps);
|
|
5957
|
+
if (currentIntent && questionsStepsMapRef.current[currentIntent]) {
|
|
5958
|
+
let intentSteps = cloneDeep(questionsStepsMapRef.current[currentIntent]);
|
|
5959
|
+
if (intentSteps.length === 1 && intentSteps[0].header === "Processing Request") {
|
|
5960
|
+
intentSteps[0].step_status = "completed";
|
|
5961
|
+
}
|
|
5962
|
+
const existingIdx = intentSteps.findIndex((s) => s.header === newStep.header);
|
|
5963
|
+
if (existingIdx !== -1) {
|
|
5964
|
+
intentSteps[existingIdx] = newStep;
|
|
5965
|
+
}
|
|
5966
|
+
else {
|
|
5967
|
+
intentSteps.push(newStep);
|
|
5968
|
+
}
|
|
5969
|
+
questionsStepsMapRef.current[currentIntent] = intentSteps;
|
|
5970
|
+
setQuestionsStepsMap(cloneDeep(questionsStepsMapRef.current));
|
|
5971
|
+
}
|
|
5764
5972
|
setStepChange((prev) => !prev);
|
|
5765
5973
|
}
|
|
5766
5974
|
else if (data.message !== "[DONE]") {
|
|
@@ -5992,6 +6200,8 @@ const StreamedContent = ({ botData }) => {
|
|
|
5992
6200
|
isTabEnabled: true,
|
|
5993
6201
|
steps: cloneDeep(stepRef.current),
|
|
5994
6202
|
currentTabValue: "agent_response",
|
|
6203
|
+
questions: cloneDeep(questionsRef.current),
|
|
6204
|
+
questionsStepsMap: cloneDeep(questionsStepsMapRef.current),
|
|
5995
6205
|
});
|
|
5996
6206
|
// [
|
|
5997
6207
|
// {
|
|
@@ -6070,6 +6280,8 @@ const StreamedContent = ({ botData }) => {
|
|
|
6070
6280
|
isTabEnabled: true,
|
|
6071
6281
|
steps: cloneDeep(stepRef.current),
|
|
6072
6282
|
currentTabValue: "agent_response",
|
|
6283
|
+
questions: cloneDeep(questionsRef.current),
|
|
6284
|
+
questionsStepsMap: cloneDeep(questionsStepsMapRef.current),
|
|
6073
6285
|
});
|
|
6074
6286
|
}
|
|
6075
6287
|
// Trigger re-render by updating chatDataState
|
|
@@ -6103,6 +6315,10 @@ const StreamedContent = ({ botData }) => {
|
|
|
6103
6315
|
sourceRef.current.close();
|
|
6104
6316
|
setIsStreaming(false);
|
|
6105
6317
|
setIsStreamingDone(true);
|
|
6318
|
+
// Stop the agent flow on the backend
|
|
6319
|
+
if (messageToStoreRef.current.sessionId) {
|
|
6320
|
+
stopAgentFlow({ session_id: messageToStoreRef.current.sessionId }, baseUrl);
|
|
6321
|
+
}
|
|
6106
6322
|
// Clear timeout if exists
|
|
6107
6323
|
if (streamTimeoutRef.current) {
|
|
6108
6324
|
clearTimeout(streamTimeoutRef.current);
|
|
@@ -6202,7 +6418,7 @@ const StreamedContent = ({ botData }) => {
|
|
|
6202
6418
|
* @returns {JSX.Element} Rendered content with optional blinking cursor
|
|
6203
6419
|
*/
|
|
6204
6420
|
const renderContent = () => {
|
|
6205
|
-
return (jsx("div", { className: classes.streamContainer, children: jsx(StepsResponseTab, { steps: steps, stepChange: stepChange, setSteps: setSteps, stepsDone: stepsDone, setStepsDone: setStepsDone, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, content: content, isStreaming: isStreaming, currentMode: currentMode }) }));
|
|
6421
|
+
return (jsx("div", { className: classes.streamContainer, children: jsx(StepsResponseTab, { steps: steps, stepChange: stepChange, setSteps: setSteps, stepsDone: stepsDone, setStepsDone: setStepsDone, finalStepDone: finalStepDone, setFinalStepDone: setFinalStepDone, content: content, isStreaming: isStreaming, currentMode: currentMode, questions: questions, questionsStepsMap: questionsStepsMap }) }));
|
|
6206
6422
|
};
|
|
6207
6423
|
if (currentMode === "agent") {
|
|
6208
6424
|
return renderContent();
|
|
@@ -6421,9 +6637,28 @@ const useStyles$1 = makeStyles$1((theme) => ({
|
|
|
6421
6637
|
stepsContainer: {
|
|
6422
6638
|
display: "flex",
|
|
6423
6639
|
flexDirection: "column",
|
|
6424
|
-
gap:
|
|
6640
|
+
gap: pxToRem(20),
|
|
6425
6641
|
background: colours.white,
|
|
6426
|
-
marginTop:
|
|
6642
|
+
marginTop: pxToRem(20),
|
|
6643
|
+
"& .impact-modern-accordion-item .impact-modern-accordion-header": {
|
|
6644
|
+
height: "auto",
|
|
6645
|
+
alignItems: "flex-start"
|
|
6646
|
+
},
|
|
6647
|
+
"& .impact-modern-accordion-item .impact-modern-accordion-content": {
|
|
6648
|
+
padding: `${pxToRem(0)} ${pxToRem(42)} ${pxToRem(8)} ${pxToRem(32)} !important`
|
|
6649
|
+
},
|
|
6650
|
+
"& .impact-modern-accordion-item .impact-modern-accordion-header .impact-modern-accordion-expand-icon": {
|
|
6651
|
+
width: `${pxToRem(24)} !important`,
|
|
6652
|
+
height: `${pxToRem(24)} !important`,
|
|
6653
|
+
}
|
|
6654
|
+
},
|
|
6655
|
+
hideContentDiv: {
|
|
6656
|
+
"& .impact-modern-accordion-item .impact-modern-accordion-content": {
|
|
6657
|
+
display: "none",
|
|
6658
|
+
}
|
|
6659
|
+
},
|
|
6660
|
+
mt12: {
|
|
6661
|
+
marginTop: pxToRem(12),
|
|
6427
6662
|
},
|
|
6428
6663
|
stepItem: {
|
|
6429
6664
|
display: "flex",
|
|
@@ -6469,10 +6704,10 @@ const useStyles$1 = makeStyles$1((theme) => ({
|
|
|
6469
6704
|
stepHeader: {
|
|
6470
6705
|
color: colours.oceanGreen,
|
|
6471
6706
|
fontFamily: "Manrope",
|
|
6472
|
-
fontSize:
|
|
6707
|
+
fontSize: pxToRem(14),
|
|
6473
6708
|
fontStyle: "normal",
|
|
6474
6709
|
fontWeight: 500,
|
|
6475
|
-
lineHeight:
|
|
6710
|
+
lineHeight: pxToRem(20),
|
|
6476
6711
|
"&.loading": {
|
|
6477
6712
|
color: colours.brightRoyalBlue,
|
|
6478
6713
|
},
|
|
@@ -6483,62 +6718,89 @@ const useStyles$1 = makeStyles$1((theme) => ({
|
|
|
6483
6718
|
stepSubheader: {
|
|
6484
6719
|
color: colours.neutrals,
|
|
6485
6720
|
fontFamily: "Manrope",
|
|
6486
|
-
fontSize:
|
|
6721
|
+
fontSize: pxToRem(12),
|
|
6487
6722
|
fontStyle: "normal",
|
|
6488
6723
|
fontWeight: 500,
|
|
6489
|
-
lineHeight:
|
|
6724
|
+
lineHeight: pxToRem(16),
|
|
6725
|
+
},
|
|
6726
|
+
accordionStepsWrapper: {
|
|
6727
|
+
display: "flex",
|
|
6728
|
+
flexDirection: "column",
|
|
6729
|
+
gap: pxToRem(12),
|
|
6730
|
+
},
|
|
6731
|
+
accordionHeaderWrapper: {
|
|
6732
|
+
display: "flex",
|
|
6733
|
+
flexDirection: "column",
|
|
6734
|
+
gap: pxToRem(16),
|
|
6735
|
+
width: "100%",
|
|
6736
|
+
},
|
|
6737
|
+
accordionHeaderQuestion: {
|
|
6738
|
+
fontFamily: "Manrope",
|
|
6739
|
+
fontSize: pxToRem(14),
|
|
6740
|
+
fontWeight: 600,
|
|
6741
|
+
},
|
|
6742
|
+
headerStepPreview: {
|
|
6743
|
+
marginLeft: pxToRem(-20),
|
|
6744
|
+
},
|
|
6745
|
+
closedAccordionStep: {
|
|
6746
|
+
display: "flex",
|
|
6747
|
+
alignItems: "center",
|
|
6748
|
+
gap: "8px",
|
|
6749
|
+
marginTop: pxToRem(4),
|
|
6750
|
+
"& svg": {
|
|
6751
|
+
width: "14px",
|
|
6752
|
+
height: "14px",
|
|
6753
|
+
flexShrink: 0,
|
|
6754
|
+
},
|
|
6755
|
+
},
|
|
6756
|
+
closedStepText: {
|
|
6757
|
+
fontFamily: "Manrope",
|
|
6758
|
+
fontSize: pxToRem(12),
|
|
6759
|
+
fontWeight: 500,
|
|
6760
|
+
color: colours.oceanGreen,
|
|
6490
6761
|
},
|
|
6491
6762
|
}));
|
|
6492
|
-
const
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
// // Mark all previous steps as done and last step as loading
|
|
6498
|
-
// const updatedSteps = steps.map((step, index) => ({
|
|
6499
|
-
// ...step,
|
|
6500
|
-
// status: index === steps.length - 1 ? "loading" : "done"
|
|
6501
|
-
// }));
|
|
6502
|
-
// setSteps(updatedSteps);
|
|
6503
|
-
// }
|
|
6504
|
-
// }, [steps]);
|
|
6505
|
-
// useEffect(() => {
|
|
6506
|
-
// if (done) {
|
|
6507
|
-
// // Add finished step when done is true
|
|
6508
|
-
// if (!finalStepDone) {
|
|
6509
|
-
// let updatedSteps = steps.map((step) => ({
|
|
6510
|
-
// ...step,
|
|
6511
|
-
// step_status: "completed",
|
|
6512
|
-
// }));
|
|
6513
|
-
// updatedSteps = [...updatedSteps, {
|
|
6514
|
-
// header: "Finished",
|
|
6515
|
-
// sub_header: "Analysis complete",
|
|
6516
|
-
// step_status: "not-completed",
|
|
6517
|
-
// }];
|
|
6518
|
-
// setSteps(cloneDeep(updatedSteps));
|
|
6519
|
-
// setTimeout(() => {
|
|
6520
|
-
// updatedSteps = updatedSteps.map((step) => ({
|
|
6521
|
-
// ...step,
|
|
6522
|
-
// step_status: "completed",
|
|
6523
|
-
// }));
|
|
6524
|
-
// setSteps(cloneDeep(updatedSteps));
|
|
6525
|
-
// setFinalStepDone(true);
|
|
6526
|
-
// }, 4000);
|
|
6527
|
-
// setTimeout(() => {
|
|
6528
|
-
// setTabValue("agent_response");
|
|
6529
|
-
// }, 4300);
|
|
6530
|
-
// }
|
|
6531
|
-
// }
|
|
6532
|
-
// }, [done]);
|
|
6533
|
-
return (jsx("div", { className: classes.stepsContainer, children: steps.map((step, index) => (jsxs("div", { className: classes.stepItem, children: [jsx("div", { className: `${classes.stepStatus} ${step.step_status === "not-completed"
|
|
6763
|
+
const StepItemRenderer = ({ step, classes }) => (jsxs("div", { className: classes.stepItem, children: [jsx("div", { className: `${classes.stepStatus} ${step.step_status === "not-completed"
|
|
6764
|
+
? "loading"
|
|
6765
|
+
: step.step_status === "error"
|
|
6766
|
+
? "error"
|
|
6767
|
+
: ""}`, children: step.step_status === "not-completed" ? (jsx(SvgStepsLoader, {})) : step.step_status === "error" ? (jsx(SvgStepError, {})) : (jsx(SvgStepDone, {})) }), jsxs("div", { className: classes.stepContent, children: [jsx("div", { className: `${classes.stepHeader} ${step.step_status === "not-completed"
|
|
6534
6768
|
? "loading"
|
|
6535
6769
|
: step.step_status === "error"
|
|
6536
6770
|
? "error"
|
|
6537
|
-
: ""}`, children: step.
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6771
|
+
: ""}`, children: step.header }), jsx("div", { className: classes.stepSubheader, children: step.sub_header })] })] }));
|
|
6772
|
+
const AccordionStepsContent = ({ questionSteps, classes, accordionName, accordionChildCount = "", accordionValue }) => {
|
|
6773
|
+
return (jsx("div", { className: classes.accordionStepsWrapper, children: jsx("div", { className: `${classes.stepsContainer} ${classes.mt12}`, children: questionSteps.map((step, index) => (jsx(StepItemRenderer, { step: step, classes: classes }, index))) }) }));
|
|
6774
|
+
};
|
|
6775
|
+
const Steps = ({ steps, questions = [], questionsStepsMap = {} }) => {
|
|
6776
|
+
const classes = useStyles$1();
|
|
6777
|
+
useState(false);
|
|
6778
|
+
const [expandedAccordion, setExpandedAccordion] = useState("");
|
|
6779
|
+
const hasQuestions = questions.length > 0;
|
|
6780
|
+
if (!hasQuestions) {
|
|
6781
|
+
if (steps.length > 0) {
|
|
6782
|
+
const fallbackQuestion = "Processing Request";
|
|
6783
|
+
const lastStep = steps[steps.length - 1];
|
|
6784
|
+
const isExpanded = expandedAccordion === fallbackQuestion;
|
|
6785
|
+
const accordionHeader = (jsxs("div", { className: classes.accordionHeaderWrapper, children: [jsx("div", { className: classes.accordionHeaderQuestion, children: fallbackQuestion }), !isExpanded && lastStep && (jsx("div", { className: classes.headerStepPreview, children: jsx(StepItemRenderer, { step: lastStep, classes: classes }) }))] }));
|
|
6786
|
+
return (jsx("div", { className: classes.stepsContainer, children: jsx(CustomGroupAccordion, { onExpandChange: (val) => setExpandedAccordion(val), children: jsx(AccordionStepsContent, { questionSteps: steps, classes: classes, accordionName: accordionHeader, accordionValue: fallbackQuestion }) }) }));
|
|
6787
|
+
}
|
|
6788
|
+
return null;
|
|
6789
|
+
}
|
|
6790
|
+
return (jsx("div", { className: classes.stepsContainer, children: jsx(CustomGroupAccordion, { onExpandChange: (val) => setExpandedAccordion(val), children: questions.map((question, index) => {
|
|
6791
|
+
const questionSteps = questionsStepsMap[question] || [
|
|
6792
|
+
{
|
|
6793
|
+
header: "Processing Request",
|
|
6794
|
+
sub_header: "Analyzing the current request",
|
|
6795
|
+
step_status: "completed",
|
|
6796
|
+
},
|
|
6797
|
+
];
|
|
6798
|
+
questionSteps.length;
|
|
6799
|
+
const lastStep = questionSteps[questionSteps.length - 1];
|
|
6800
|
+
const isExpanded = expandedAccordion === question;
|
|
6801
|
+
const accordionHeader = (jsxs("div", { className: classes.accordionHeaderWrapper, children: [jsx("div", { className: classes.accordionHeaderQuestion, children: question }), !isExpanded && lastStep && (jsx("div", { className: classes.headerStepPreview, children: jsx(StepItemRenderer, { step: lastStep, classes: classes }) }))] }));
|
|
6802
|
+
return (jsx(AccordionStepsContent, { questionSteps: questionSteps, classes: classes, accordionName: accordionHeader, accordionValue: question }, index));
|
|
6803
|
+
}) }) }));
|
|
6542
6804
|
};
|
|
6543
6805
|
|
|
6544
6806
|
const AgentResponse = ({ children }) => {
|
|
@@ -6546,7 +6808,7 @@ const AgentResponse = ({ children }) => {
|
|
|
6546
6808
|
return (jsx("div", { className: classes.agentResponseContainer, children: children }));
|
|
6547
6809
|
};
|
|
6548
6810
|
|
|
6549
|
-
const TabularContent = ({ steps, currentTabValue, children }) => {
|
|
6811
|
+
const TabularContent = ({ steps, currentTabValue, children, questions = [], questionsStepsMap = {} }) => {
|
|
6550
6812
|
const [tabValue, setTabValue] = useState(currentTabValue);
|
|
6551
6813
|
const handleChangeTabValue = (_event, newValue) => {
|
|
6552
6814
|
setTabValue(newValue);
|
|
@@ -6554,6 +6816,13 @@ const TabularContent = ({ steps, currentTabValue, children }) => {
|
|
|
6554
6816
|
steps.forEach((step) => {
|
|
6555
6817
|
step.step_status = "completed";
|
|
6556
6818
|
});
|
|
6819
|
+
if (Object.keys(questionsStepsMap).length > 0) {
|
|
6820
|
+
Object.keys(questionsStepsMap).forEach((key) => {
|
|
6821
|
+
questionsStepsMap[key].forEach((step) => {
|
|
6822
|
+
step.step_status = "completed";
|
|
6823
|
+
});
|
|
6824
|
+
});
|
|
6825
|
+
}
|
|
6557
6826
|
return (jsx("div", { children: jsx(Tabs, { onChange: handleChangeTabValue, orientation: "horizontal", tabNames: [
|
|
6558
6827
|
{
|
|
6559
6828
|
label: "Steps",
|
|
@@ -6566,7 +6835,7 @@ const TabularContent = ({ steps, currentTabValue, children }) => {
|
|
|
6566
6835
|
icon: jsx(PsychologyOutlinedIcon, { fontSize: "large" }),
|
|
6567
6836
|
},
|
|
6568
6837
|
], tabPanels: [
|
|
6569
|
-
jsx(Steps, { steps: steps }),
|
|
6838
|
+
jsx(Steps, { steps: steps, questions: questions, questionsStepsMap: questionsStepsMap }),
|
|
6570
6839
|
jsx(AgentResponse, { children: children }),
|
|
6571
6840
|
], value: tabValue }) }));
|
|
6572
6841
|
};
|
|
@@ -6635,7 +6904,7 @@ const CombinedContent = ({ botData, props }) => {
|
|
|
6635
6904
|
const validContent = renderedContent.filter(content => content !== null);
|
|
6636
6905
|
const renderCombinedContent = () => (jsx("div", { className: "combined-content-container", children: validContent.length > 0 ? (validContent.map((content, index) => (jsx("div", { className: "combined-content-item", children: content }, `wrapper-${index}`)))) : (jsx("div", { children: "No valid content to display" })) }));
|
|
6637
6906
|
if (isTabEnabled) {
|
|
6638
|
-
return (jsx(TabularContent, { steps: botData?.utilityData?.steps || [], currentTabValue: botData?.utilityData?.currentTabValue || "steps", children: renderCombinedContent() }));
|
|
6907
|
+
return (jsx(TabularContent, { steps: botData?.utilityData?.steps || [], currentTabValue: botData?.utilityData?.currentTabValue || "steps", questions: botData?.utilityData?.questions || [], questionsStepsMap: botData?.utilityData?.questionsStepsMap || {}, children: renderCombinedContent() }));
|
|
6639
6908
|
}
|
|
6640
6909
|
return renderCombinedContent();
|
|
6641
6910
|
};
|
|
@@ -9895,7 +10164,7 @@ const SmartBot = (props) => {
|
|
|
9895
10164
|
setBaseUrl(customBaseUrl);
|
|
9896
10165
|
}
|
|
9897
10166
|
}, [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:
|
|
10167
|
+
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
10168
|
// landingScreen={true}
|
|
9900
10169
|
handleNewChatClick: () => {
|
|
9901
10170
|
localStorage.setItem("isStreaming", "false");
|
|
@@ -10028,7 +10297,7 @@ const SmartBot = (props) => {
|
|
|
10028
10297
|
},
|
|
10029
10298
|
icon: jsx(SvgNavigationIcon, {}),
|
|
10030
10299
|
},
|
|
10031
|
-
], utilityList: utilityList, isAssistantThinking: loader, isCustomScreen: showChatPlaceholder, customScreenJsx: jsx(ChatPlaceholder, { dateFormat: dateFormat, chatDataRef: chatDataRef, currentMode: currentMode, setShowChatPlaceholder: setShowChatPlaceholder, setLoader: setLoader, setCurrentAgentId: setCurrentAgentId, baseUrl: baseUrl, setBaseUrl: setBaseUrl, setCurrentSessionId: setCurrentSessionId, customChatConfig: customChatConfig, chatDataInfoRef: chatDataInfoRef, setChatDataState: setChatDataState, userInput: userInput, legacyAgentScreen: legacyAgentScreen, activeConversationId: activeConversationId, chatBodyRef: chatBodyRef, chatbotContext: chatbotContext, setInitValue: setInitValue, setSessionId: setSessionId, thinkingContent: thinkingContext?.thinkingContent, setThinkingContent: setThinkingContent, isThinking: isThinking, setIsThinking: setIsThinking, chatId: chatId, setChatId: setChatId, isStop: isStop, setIsStop: setIsStop, functionsRef: functionsRef, functionsState: functionsState, setFunctionsState: setFunctionsState, thinkingHeaderMessage: thinkingContext?.thinkingHeaderMessage, setThinkingHeaderMessage: setThinkingHeaderMessage, uniqueChatId: uniqueChatId, setUniqueChatId: setUniqueChatId }), inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
|
|
10300
|
+
], utilityList: utilityList, isAssistantThinking: loader, isCustomScreen: showChatPlaceholder, customScreenJsx: jsx(ChatPlaceholder, { dateFormat: dateFormat, chatDataRef: chatDataRef, currentMode: currentMode, setShowChatPlaceholder: setShowChatPlaceholder, setLoader: setLoader, setCurrentAgentId: setCurrentAgentId, baseUrl: baseUrl, setBaseUrl: setBaseUrl, setCurrentSessionId: setCurrentSessionId, customChatConfig: customChatConfig, chatDataInfoRef: chatDataInfoRef, setChatDataState: setChatDataState, userInput: userInput, legacyAgentScreen: legacyAgentScreen, activeConversationId: activeConversationId, chatBodyRef: chatBodyRef, chatbotContext: chatbotContext, setInitValue: setInitValue, setSessionId: setSessionId, thinkingContent: thinkingContext?.thinkingContent, setThinkingContent: setThinkingContent, isThinking: isThinking, setIsThinking: setIsThinking, chatId: chatId, setChatId: setChatId, isStop: isStop, setIsStop: setIsStop, functionsRef: functionsRef, functionsState: functionsState, setFunctionsState: setFunctionsState, thinkingHeaderMessage: thinkingContext?.thinkingHeaderMessage, setThinkingHeaderMessage: setThinkingHeaderMessage, uniqueChatId: uniqueChatId, setUniqueChatId: setUniqueChatId, fieldNumber: fieldNumber, setFieldNumber: setFieldNumber }), inputText: userInput, threadList: ["Home"], hideMenuArrow: hideMenu, newChatScreen: newChatScreen, isModuleListLoading: modulesLoading, suggestionBanner: {
|
|
10032
10301
|
freeTextHeading: "Try adding more details :",
|
|
10033
10302
|
freeTextContent: "Alan works better when you provide more context and pointed questions",
|
|
10034
10303
|
}, isStopIcon: isStop, onStopIconClick: onStopIconClick, footerText: "AI-generated responses may contain errors\u2014please verify important information", showSuggestionBanner: showSuggestionBanner, onCloseSuggestionBanner: () => {
|