@cognizant-ai-lab/ui-common 1.3.3
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/AgentChat/ChatCommon.d.ts +94 -0
- package/dist/components/AgentChat/ChatCommon.js +581 -0
- package/dist/components/AgentChat/ControlButtons.d.ts +16 -0
- package/dist/components/AgentChat/ControlButtons.js +24 -0
- package/dist/components/AgentChat/FormattedMarkdown.d.ts +32 -0
- package/dist/components/AgentChat/FormattedMarkdown.js +82 -0
- package/dist/components/AgentChat/Greetings.d.ts +1 -0
- package/dist/components/AgentChat/Greetings.js +38 -0
- package/dist/components/AgentChat/LlmChatButton.d.ts +12 -0
- package/dist/components/AgentChat/LlmChatButton.js +33 -0
- package/dist/components/AgentChat/SendButton.d.ts +12 -0
- package/dist/components/AgentChat/SendButton.js +28 -0
- package/dist/components/AgentChat/SyntaxHighlighterThemes.d.ts +14 -0
- package/dist/components/AgentChat/SyntaxHighlighterThemes.js +27 -0
- package/dist/components/AgentChat/Types.d.ts +17 -0
- package/dist/components/AgentChat/Types.js +26 -0
- package/dist/components/AgentChat/UserQueryDisplay.d.ts +5 -0
- package/dist/components/AgentChat/UserQueryDisplay.js +33 -0
- package/dist/components/AgentChat/Utils.d.ts +11 -0
- package/dist/components/AgentChat/Utils.js +64 -0
- package/dist/components/AgentChat/VoiceChat/MicrophoneButton.d.ts +29 -0
- package/dist/components/AgentChat/VoiceChat/MicrophoneButton.js +55 -0
- package/dist/components/AgentChat/VoiceChat/VoiceChat.d.ts +33 -0
- package/dist/components/AgentChat/VoiceChat/VoiceChat.js +180 -0
- package/dist/components/Authentication/Auth.d.ts +14 -0
- package/dist/components/Authentication/Auth.js +58 -0
- package/dist/components/ChatBot/ChatBot.d.ts +20 -0
- package/dist/components/ChatBot/ChatBot.js +75 -0
- package/dist/components/Common/Breadcrumbs.d.ts +6 -0
- package/dist/components/Common/Breadcrumbs.js +36 -0
- package/dist/components/Common/LlmChatOptionsButton.d.ts +9 -0
- package/dist/components/Common/LlmChatOptionsButton.js +31 -0
- package/dist/components/Common/LoadingSpinner.d.ts +10 -0
- package/dist/components/Common/LoadingSpinner.js +24 -0
- package/dist/components/Common/MUIAccordion.d.ts +17 -0
- package/dist/components/Common/MUIAccordion.js +76 -0
- package/dist/components/Common/MUIAlert.d.ts +11 -0
- package/dist/components/Common/MUIAlert.js +41 -0
- package/dist/components/Common/MUIDialog.d.ts +16 -0
- package/dist/components/Common/MUIDialog.js +40 -0
- package/dist/components/Common/Navbar.d.ts +15 -0
- package/dist/components/Common/Navbar.js +137 -0
- package/dist/components/Common/PageLoader.d.ts +5 -0
- package/dist/components/Common/PageLoader.js +26 -0
- package/dist/components/Common/Snackbar.d.ts +5 -0
- package/dist/components/Common/Snackbar.js +84 -0
- package/dist/components/Common/confirmationModal.d.ts +14 -0
- package/dist/components/Common/confirmationModal.js +65 -0
- package/dist/components/Common/notification.d.ts +18 -0
- package/dist/components/Common/notification.js +79 -0
- package/dist/components/ErrorPage/ErrorBoundary.d.ts +38 -0
- package/dist/components/ErrorPage/ErrorBoundary.js +77 -0
- package/dist/components/ErrorPage/ErrorPage.d.ts +12 -0
- package/dist/components/ErrorPage/ErrorPage.js +46 -0
- package/dist/components/MultiAgentAccelerator/AgentFlow.d.ts +21 -0
- package/dist/components/MultiAgentAccelerator/AgentFlow.js +394 -0
- package/dist/components/MultiAgentAccelerator/AgentNode.d.ts +18 -0
- package/dist/components/MultiAgentAccelerator/AgentNode.js +129 -0
- package/dist/components/MultiAgentAccelerator/GraphLayouts.d.ts +33 -0
- package/dist/components/MultiAgentAccelerator/GraphLayouts.js +297 -0
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.d.ts +17 -0
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +208 -0
- package/dist/components/MultiAgentAccelerator/PlasmaEdge.d.ts +3 -0
- package/dist/components/MultiAgentAccelerator/PlasmaEdge.js +124 -0
- package/dist/components/MultiAgentAccelerator/Sidebar.d.ts +12 -0
- package/dist/components/MultiAgentAccelerator/Sidebar.js +204 -0
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleEdge.d.ts +12 -0
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleEdge.js +15 -0
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleOverlay.d.ts +11 -0
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleOverlay.js +466 -0
- package/dist/components/MultiAgentAccelerator/const.d.ts +7 -0
- package/dist/components/MultiAgentAccelerator/const.js +39 -0
- package/dist/const.d.ts +10 -0
- package/dist/const.js +30 -0
- package/dist/controller/agent/Agent.d.ts +56 -0
- package/dist/controller/agent/Agent.js +162 -0
- package/dist/controller/llm/LlmChat.d.ts +18 -0
- package/dist/controller/llm/LlmChat.js +65 -0
- package/dist/controller/llm/endpoints.d.ts +1 -0
- package/dist/controller/llm/endpoints.js +17 -0
- package/dist/generated/neuro-san/NeuroSanClient.d.ts +413 -0
- package/dist/generated/neuro-san/NeuroSanClient.js +28 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +52 -0
- package/dist/state/UserInfo.d.ts +16 -0
- package/dist/state/UserInfo.js +27 -0
- package/dist/state/environment.d.ts +18 -0
- package/dist/state/environment.js +33 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/utils/Authentication.d.ts +31 -0
- package/dist/utils/Authentication.js +94 -0
- package/dist/utils/BrowserNavigation.d.ts +5 -0
- package/dist/utils/BrowserNavigation.js +22 -0
- package/dist/utils/Theme.d.ts +7 -0
- package/dist/utils/Theme.js +7 -0
- package/dist/utils/agentConversations.d.ts +24 -0
- package/dist/utils/agentConversations.js +113 -0
- package/dist/utils/text.d.ts +28 -0
- package/dist/utils/text.js +64 -0
- package/dist/utils/title.d.ts +1 -0
- package/dist/utils/title.js +20 -0
- package/dist/utils/types.d.ts +17 -0
- package/dist/utils/types.js +16 -0
- package/dist/utils/useLocalStorage.d.ts +1 -0
- package/dist/utils/useLocalStorage.js +55 -0
- package/dist/utils/zIndexLayers.d.ts +2 -0
- package/dist/utils/zIndexLayers.js +29 -0
- package/package.json +69 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { Fragment } from "react";
|
|
18
|
+
import ReactMarkdown from "react-markdown";
|
|
19
|
+
import SyntaxHighlighter from "react-syntax-highlighter";
|
|
20
|
+
import rehypeRaw from "rehype-raw";
|
|
21
|
+
import rehypeSlug from "rehype-slug";
|
|
22
|
+
import { hashString } from "../../utils/text.js";
|
|
23
|
+
/**
|
|
24
|
+
* Format the output to ensure that text nodes are formatted as markdown but other nodes are passed along as-is.
|
|
25
|
+
*
|
|
26
|
+
* @param props The props for the component. @see FormattedMarkdownProps
|
|
27
|
+
* @returns The formatted output. Consecutive string nodes will be aggregated and wrapped in a markdown component,
|
|
28
|
+
* while other nodes will be passed along as-is.
|
|
29
|
+
*/
|
|
30
|
+
export const FormattedMarkdown = ({ id, nodesList, style, wrapLongLines = false, }) => {
|
|
31
|
+
/**
|
|
32
|
+
* Get the formatted output for a given string. The string is assumed to be in Markdown format.
|
|
33
|
+
* @param stringToFormat The string to format.
|
|
34
|
+
* @param index The index of the string in the nodes list. Used as "salt" to generate a unique key.
|
|
35
|
+
* @returns The formatted markdown.
|
|
36
|
+
*/
|
|
37
|
+
const getFormattedMarkdown = (stringToFormat, index) => (_jsx(ReactMarkdown, { rehypePlugins: [rehypeRaw, rehypeSlug], components: {
|
|
38
|
+
code(codeProps) {
|
|
39
|
+
const { children, className, ...rest } = codeProps;
|
|
40
|
+
const match = /language-(?<language>\w+)/u.exec(className || "");
|
|
41
|
+
return match ? (_jsx(SyntaxHighlighter, { id: `syntax-highlighter-${match.groups["language"]}`, PreTag: "div", language: match.groups["language"], style: style, children: String(children).replace(/\n$/u, "") })) : (_jsx("code", { id: `code-${className}`, ...rest, className: className, style: wrapLongLines ? { whiteSpace: "pre-wrap", wordBreak: "break-word" } : {}, children: children }));
|
|
42
|
+
},
|
|
43
|
+
// Handle links specially since we want them to open in a new tab
|
|
44
|
+
a({ ...codeProps }) {
|
|
45
|
+
return (_jsx("a", { ...codeProps, id: "reference-link", target: "_blank", rel: "noopener noreferrer", children: codeProps.children }));
|
|
46
|
+
},
|
|
47
|
+
}, children: stringToFormat }, `${hashString(stringToFormat)}-${index}`));
|
|
48
|
+
const getNodeKey = (node, index) => {
|
|
49
|
+
// If it has a key, use that
|
|
50
|
+
if (typeof node === "object" && node !== null && "key" in node && node.key !== null) {
|
|
51
|
+
return `${node.key}-${index}`;
|
|
52
|
+
}
|
|
53
|
+
// If not, do our best to synthesize a key
|
|
54
|
+
return `${hashString(node?.toString() || "")}-${index}`;
|
|
55
|
+
};
|
|
56
|
+
// Walk through the nodes list. If we encounter a string node, we'll aggregate it with other string nodes.
|
|
57
|
+
const formattedOutput = [];
|
|
58
|
+
let currentTextNodes = [];
|
|
59
|
+
for (const [i, node] of nodesList.entries()) {
|
|
60
|
+
// If it's a string node, aggregate it with other string nodes
|
|
61
|
+
if (typeof node === "string") {
|
|
62
|
+
currentTextNodes.push(node);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Not a string node. Process any aggregated text nodes
|
|
66
|
+
if (currentTextNodes.length > 0) {
|
|
67
|
+
const concatenatedText = getFormattedMarkdown(currentTextNodes.join(""), i);
|
|
68
|
+
formattedOutput.push(concatenatedText);
|
|
69
|
+
currentTextNodes = [];
|
|
70
|
+
}
|
|
71
|
+
// Not a string node. Add the node as-is
|
|
72
|
+
const key = getNodeKey(node, i);
|
|
73
|
+
formattedOutput.push(_jsx(Fragment, { children: node }, key));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Process any remaining text nodes
|
|
77
|
+
if (currentTextNodes.length > 0) {
|
|
78
|
+
const concatenatedText = getFormattedMarkdown(currentTextNodes.join(""), nodesList.length);
|
|
79
|
+
formattedOutput.push(concatenatedText);
|
|
80
|
+
}
|
|
81
|
+
return _jsx("div", { id: id, children: formattedOutput });
|
|
82
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AGENT_GREETINGS: string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
// Random greetings agents can use
|
|
17
|
+
export const AGENT_GREETINGS = [
|
|
18
|
+
"Hey there! How can I assist you today?",
|
|
19
|
+
"Hi! What can I do for you?",
|
|
20
|
+
"Hello! Need help with something?",
|
|
21
|
+
"Hey! How’s your day going? What can I help with?",
|
|
22
|
+
"Hi there! What’s on your mind?",
|
|
23
|
+
"Hello, friend! How can I make your day easier?",
|
|
24
|
+
"Hey, how can I assist you today?",
|
|
25
|
+
"Hi! Got any questions? I’m here to help!",
|
|
26
|
+
"Hey! What’s up? How can I be of service?",
|
|
27
|
+
"Greetings! What can I do for you?",
|
|
28
|
+
"Hello there! Need any assistance?",
|
|
29
|
+
"Hey, good to see you! How can I help?",
|
|
30
|
+
"Hi! I’d love to assist you—what’s on your mind?",
|
|
31
|
+
"Hey, what’s new? How can I lend a hand?",
|
|
32
|
+
"Hello! I’m here to help—what do you need?",
|
|
33
|
+
"Hi there! Looking for answers? I’ve got you!",
|
|
34
|
+
"Hey! Need some help? I’m all ears!",
|
|
35
|
+
"Hello! What’s something I can help you figure out today?",
|
|
36
|
+
"Hi! How’s it going? What can I do for you?",
|
|
37
|
+
"Hey there! Got a challenge? Let’s solve it together!",
|
|
38
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type LLMChatGroupConfigBtnProps = {
|
|
2
|
+
disabled?: boolean;
|
|
3
|
+
posRight?: number;
|
|
4
|
+
posBottom?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const LlmChatButton: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
7
|
+
ref?: import("react").Ref<HTMLButtonElement>;
|
|
8
|
+
}, "className" | "style" | "classes" | "action" | "centerRipple" | "children" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "tabIndex" | "TouchRippleProps" | "touchRippleRef" | "href" | "color" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "loading" | "loadingIndicator" | "loadingPosition" | "size" | "startIcon" | "variant"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & LLMChatGroupConfigBtnProps, {}, {}>;
|
|
9
|
+
export declare const SmallLlmChatButton: import("@emotion/styled").StyledComponent<import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
10
|
+
ref?: import("react").Ref<HTMLButtonElement>;
|
|
11
|
+
}, "className" | "style" | "classes" | "action" | "centerRipple" | "children" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "tabIndex" | "TouchRippleProps" | "touchRippleRef" | "href" | "color" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "loading" | "loadingIndicator" | "loadingPosition" | "size" | "startIcon" | "variant"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & LLMChatGroupConfigBtnProps, {}, {}>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { styled } from "@mui/material";
|
|
17
|
+
import Button from "@mui/material/Button";
|
|
18
|
+
// #endregion: Types
|
|
19
|
+
export const LlmChatButton = styled(Button, {
|
|
20
|
+
shouldForwardProp: (prop) => !["posRight", "posBottom"].includes(String(prop)),
|
|
21
|
+
})(({ disabled, posRight, posBottom }) => ({
|
|
22
|
+
background: "var(--bs-primary) !important",
|
|
23
|
+
borderRadius: "var(--bs-border-radius)",
|
|
24
|
+
bottom: posBottom !== undefined ? posBottom : 0,
|
|
25
|
+
cursor: disabled ? "default" : "pointer",
|
|
26
|
+
opacity: disabled ? "50%" : "100%",
|
|
27
|
+
right: posRight !== undefined ? posRight : 0,
|
|
28
|
+
position: "absolute",
|
|
29
|
+
}));
|
|
30
|
+
export const SmallLlmChatButton = styled(LlmChatButton)({
|
|
31
|
+
minWidth: 0,
|
|
32
|
+
padding: "0.25rem",
|
|
33
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
interface SendButtonProps {
|
|
3
|
+
enableSendButton: boolean;
|
|
4
|
+
id: string;
|
|
5
|
+
onClickCallback: () => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Generate the Send Button for a chat window.
|
|
9
|
+
* @returns The Send Button.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SendButton: FC<SendButtonProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import SendIcon from "@mui/icons-material/Send";
|
|
18
|
+
import { LlmChatButton } from "./LlmChatButton.js";
|
|
19
|
+
// #endregion: Types
|
|
20
|
+
/**
|
|
21
|
+
* Generate the Send Button for a chat window.
|
|
22
|
+
* @returns The Send Button.
|
|
23
|
+
*/
|
|
24
|
+
export const SendButton = ({ enableSendButton, id, onClickCallback }) => (_jsx(LlmChatButton, { "aria-label": "Send", disabled: !enableSendButton, id: id, onClick: onClickCallback, sx: {
|
|
25
|
+
padding: "0.6rem",
|
|
26
|
+
position: "relative",
|
|
27
|
+
}, tabIndex: 0, children: _jsx(SendIcon, { fontSize: "small", id: "stop-button-icon" // Could update this but it would impact QA
|
|
28
|
+
, sx: { color: "var(--bs-white)" } }) }));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const HLJS_THEMES: {
|
|
2
|
+
a11yDark: {
|
|
3
|
+
[key: string]: import("react").CSSProperties;
|
|
4
|
+
};
|
|
5
|
+
a11yLight: {
|
|
6
|
+
[key: string]: import("react").CSSProperties;
|
|
7
|
+
};
|
|
8
|
+
atelierDuneDark: {
|
|
9
|
+
[key: string]: import("react").CSSProperties;
|
|
10
|
+
};
|
|
11
|
+
docco: {
|
|
12
|
+
[key: string]: import("react").CSSProperties;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* List of available hljs themes for the syntax highlighter.
|
|
18
|
+
* See: https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/src/styles/hljs/index.js
|
|
19
|
+
*/
|
|
20
|
+
import { a11yDark, a11yLight, atelierDuneDark, docco } from "react-syntax-highlighter/dist/cjs/styles/hljs/index.js";
|
|
21
|
+
// hljs themes
|
|
22
|
+
export const HLJS_THEMES = {
|
|
23
|
+
a11yDark,
|
|
24
|
+
a11yLight,
|
|
25
|
+
atelierDuneDark,
|
|
26
|
+
docco,
|
|
27
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum LegacyAgentType {
|
|
2
|
+
OpportunityFinder = "OpportunityFinder",
|
|
3
|
+
ScopingAgent = "ScopingAgent",
|
|
4
|
+
DataGenerator = "DataGenerator",
|
|
5
|
+
DMSChat = "DMSChat",
|
|
6
|
+
ChatBot = "ChatBot"
|
|
7
|
+
}
|
|
8
|
+
export declare const isLegacyAgentType: (agent: string) => boolean;
|
|
9
|
+
export type CombinedAgentType = LegacyAgentType | string;
|
|
10
|
+
/**
|
|
11
|
+
* Models the error we receive from neuro-san agents.
|
|
12
|
+
*/
|
|
13
|
+
export interface AgentErrorProps {
|
|
14
|
+
error: string;
|
|
15
|
+
traceback?: string;
|
|
16
|
+
tool?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export var LegacyAgentType;
|
|
17
|
+
(function (LegacyAgentType) {
|
|
18
|
+
LegacyAgentType["OpportunityFinder"] = "OpportunityFinder";
|
|
19
|
+
LegacyAgentType["ScopingAgent"] = "ScopingAgent";
|
|
20
|
+
LegacyAgentType["DataGenerator"] = "DataGenerator";
|
|
21
|
+
LegacyAgentType["DMSChat"] = "DMSChat";
|
|
22
|
+
LegacyAgentType["ChatBot"] = "ChatBot";
|
|
23
|
+
})(LegacyAgentType || (LegacyAgentType = {}));
|
|
24
|
+
export const isLegacyAgentType = (agent) => {
|
|
25
|
+
return Object.keys(LegacyAgentType).includes(agent);
|
|
26
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { styled } from "@mui/material";
|
|
18
|
+
import { DEFAULT_USER_IMAGE } from "../../const.js";
|
|
19
|
+
// #region: Styled Components
|
|
20
|
+
const UserQueryContainer = styled("div")(({ theme }) => ({
|
|
21
|
+
backgroundColor: theme.palette.background.default,
|
|
22
|
+
border: "var(--bs-border-width) var(--bs-border-style)",
|
|
23
|
+
borderColor: theme.palette.mode === "dark" ? "var(--bs-white)" : "var(--bs-border-color)",
|
|
24
|
+
borderRadius: "var(--bs-border-radius)",
|
|
25
|
+
boxShadow: `0 0px 6px 0 ${theme.palette.mode === "dark" ? "var(--bs-accent2-light)" : "rgba(var(--bs-primary-rgb), 0.15)"}`,
|
|
26
|
+
color: theme.palette.mode === "dark" ? "var(--bs-white)" : "var(--bs-primary)",
|
|
27
|
+
display: "inline-flex",
|
|
28
|
+
padding: "10px",
|
|
29
|
+
}));
|
|
30
|
+
// #endregion: Styled Components
|
|
31
|
+
export const UserQueryDisplay = ({ userQuery, title, userImage, }) => {
|
|
32
|
+
return (_jsx("div", { id: "user-query-div", style: { marginBottom: "1rem" }, children: _jsxs(UserQueryContainer, { id: "user-query-container", children: [_jsx("img", { id: "user-query-image", src: userImage || DEFAULT_USER_IMAGE, width: 30, height: 30, title: title, alt: "", role: "img" }), _jsx("span", { id: "user-query", style: { marginLeft: "0.625rem", marginTop: "0.125rem" }, children: userQuery })] }) }));
|
|
33
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ChatMessage, ChatMessageType } from "../../generated/neuro-san/NeuroSanClient.js";
|
|
2
|
+
export declare const KNOWN_MESSAGE_TYPES: ChatMessageType[];
|
|
3
|
+
export declare const KNOWN_MESSAGE_TYPES_FOR_PLASMA: ChatMessageType[];
|
|
4
|
+
export declare const chatMessageFromChunk: (chunk: string) => ChatMessage | null;
|
|
5
|
+
export declare const checkError: (chatMessageJson: object) => string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Convert FOO_BAR to more human "Foo Bar"
|
|
8
|
+
* @param agentName Agent name in SNAKE_CASE format.
|
|
9
|
+
* @returns User-friendly agent name.
|
|
10
|
+
*/
|
|
11
|
+
export declare const cleanUpAgentName: (agentName: string) => string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import capitalize from "lodash-es/capitalize.js";
|
|
17
|
+
import startCase from "lodash-es/startCase.js";
|
|
18
|
+
import { ChatMessageType } from "../../generated/neuro-san/NeuroSanClient.js";
|
|
19
|
+
// We ignore any messages that are not of these types
|
|
20
|
+
export const KNOWN_MESSAGE_TYPES = [
|
|
21
|
+
ChatMessageType.AI,
|
|
22
|
+
ChatMessageType.AGENT,
|
|
23
|
+
ChatMessageType.AGENT_FRAMEWORK,
|
|
24
|
+
ChatMessageType.HUMAN,
|
|
25
|
+
ChatMessageType.SYSTEM,
|
|
26
|
+
];
|
|
27
|
+
// HUMAN omitted for plasma edges mainly for performance reasons. However, does it make sense for plasma to include
|
|
28
|
+
// human messages anyway?
|
|
29
|
+
export const KNOWN_MESSAGE_TYPES_FOR_PLASMA = KNOWN_MESSAGE_TYPES.filter((type) => type !== ChatMessageType.HUMAN);
|
|
30
|
+
export const chatMessageFromChunk = (chunk) => {
|
|
31
|
+
let chatResponse;
|
|
32
|
+
try {
|
|
33
|
+
chatResponse = JSON.parse(chunk);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const chatMessage = chatResponse?.response;
|
|
39
|
+
const messageType = chatMessage?.type;
|
|
40
|
+
// Check if it's a message type we know how to handle
|
|
41
|
+
if (!KNOWN_MESSAGE_TYPES.includes(messageType)) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return chatResponse.response;
|
|
45
|
+
};
|
|
46
|
+
export const checkError = (chatMessageJson) => {
|
|
47
|
+
if (chatMessageJson && "error" in chatMessageJson) {
|
|
48
|
+
const agentError = chatMessageJson;
|
|
49
|
+
return (`Error occurred. Error: "${agentError.error}", ` +
|
|
50
|
+
`traceback: "${agentError?.traceback}", ` +
|
|
51
|
+
`tool: "${agentError?.tool}"`);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Convert FOO_BAR to more human "Foo Bar"
|
|
59
|
+
* @param agentName Agent name in SNAKE_CASE format.
|
|
60
|
+
* @returns User-friendly agent name.
|
|
61
|
+
*/
|
|
62
|
+
export const cleanUpAgentName = (agentName) => {
|
|
63
|
+
return startCase(capitalize(agentName));
|
|
64
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Dispatch, FC, MutableRefObject, SetStateAction } from "react";
|
|
2
|
+
import { SpeechRecognitionState } from "./VoiceChat.js";
|
|
3
|
+
export interface MicrophoneButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Whether microphone/voice mode is currently enabled
|
|
6
|
+
*/
|
|
7
|
+
isMicOn: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Function to toggle the microphone state
|
|
10
|
+
*/
|
|
11
|
+
onMicToggle: (newState: boolean) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Reference to the SpeechRecognition instance
|
|
14
|
+
*/
|
|
15
|
+
speechRecognitionRef: MutableRefObject<SpeechRecognition | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Current voice input state
|
|
18
|
+
*/
|
|
19
|
+
voiceInputState: SpeechRecognitionState;
|
|
20
|
+
/**
|
|
21
|
+
* Function to update voice input state
|
|
22
|
+
*/
|
|
23
|
+
setVoiceInputState: Dispatch<SetStateAction<SpeechRecognitionState>>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Microphone button component for voice input functionality.
|
|
27
|
+
* Handles toggling voice recognition on/off and displays appropriate visual feedback.
|
|
28
|
+
*/
|
|
29
|
+
export declare const MicrophoneButton: FC<MicrophoneButtonProps>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import MicNoneIcon from "@mui/icons-material/MicNone";
|
|
18
|
+
import MicOffIcon from "@mui/icons-material/MicOff";
|
|
19
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
20
|
+
import { LlmChatButton } from "../LlmChatButton.js";
|
|
21
|
+
import { checkSpeechSupport, toggleListening } from "./VoiceChat.js";
|
|
22
|
+
// #endregion: Types
|
|
23
|
+
/**
|
|
24
|
+
* Microphone button component for voice input functionality.
|
|
25
|
+
* Handles toggling voice recognition on/off and displays appropriate visual feedback.
|
|
26
|
+
*/
|
|
27
|
+
export const MicrophoneButton = ({ isMicOn, onMicToggle, speechRecognitionRef, voiceInputState, setVoiceInputState, }) => {
|
|
28
|
+
const speechSupported = checkSpeechSupport();
|
|
29
|
+
const handleClick = async () => {
|
|
30
|
+
const newMicState = !isMicOn;
|
|
31
|
+
onMicToggle(newMicState);
|
|
32
|
+
if (!speechSupported)
|
|
33
|
+
return;
|
|
34
|
+
// If turning off the microphone, immediately update the voice state
|
|
35
|
+
if (!newMicState) {
|
|
36
|
+
setVoiceInputState((prev) => ({
|
|
37
|
+
...prev,
|
|
38
|
+
isListening: false,
|
|
39
|
+
isProcessingSpeech: false,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
await toggleListening(newMicState, speechRecognitionRef.current);
|
|
43
|
+
};
|
|
44
|
+
const isDisabled = !speechSupported;
|
|
45
|
+
const tooltipText = !speechSupported
|
|
46
|
+
? "Voice input is only supported in Google Chrome on Mac or Windows."
|
|
47
|
+
: isMicOn
|
|
48
|
+
? "Turn microphone off"
|
|
49
|
+
: "Turn microphone on";
|
|
50
|
+
return (_jsx(Tooltip, { title: tooltipText, children: _jsx("span", { style: { display: "inline-block", height: 50, width: 64 }, children: _jsx(LlmChatButton, { "data-testid": "microphone-button", disabled: isDisabled, id: "microphone-button", onClick: handleClick, sx: {
|
|
51
|
+
padding: "0.5rem",
|
|
52
|
+
right: 70,
|
|
53
|
+
backgroundColor: isMicOn && voiceInputState.isListening ? "var(--bs-success)" : "var(--bs-secondary)",
|
|
54
|
+
}, tabIndex: 0, children: voiceInputState.isListening ? (_jsx(MicNoneIcon, { sx: { color: "var(--bs-white)" }, "data-testid": "MicNoneIcon" })) : (_jsx(MicOffIcon, { sx: { color: "var(--bs-white)" }, "data-testid": "MicOffIcon" })) }) }) }));
|
|
55
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Dispatch, MutableRefObject, SetStateAction } from "react";
|
|
2
|
+
export interface SpeechRecognitionHandlers {
|
|
3
|
+
end: () => void;
|
|
4
|
+
error: (event: SpeechRecognitionErrorEvent) => void;
|
|
5
|
+
result: (event: SpeechRecognitionEvent) => void;
|
|
6
|
+
start: () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface SpeechRecognitionState {
|
|
9
|
+
/**
|
|
10
|
+
* currentTranscript holds the interim (live) speech recognition results as the user is speaking.
|
|
11
|
+
* This provides real-time feedback in the UI, showing what the system is currently hearing.
|
|
12
|
+
*/
|
|
13
|
+
currentTranscript: string;
|
|
14
|
+
/**
|
|
15
|
+
* finalTranscript contains the finalized speech recognition result for a segment.
|
|
16
|
+
* This is stable and ready to be used as chat input after the system is confident about what was said.
|
|
17
|
+
*/
|
|
18
|
+
finalTranscript: string;
|
|
19
|
+
/**
|
|
20
|
+
* isListening indicates whether the system is actively listening for speech input.
|
|
21
|
+
* Used to control UI state and microphone activity.
|
|
22
|
+
*/
|
|
23
|
+
isListening: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* isProcessingSpeech indicates whether the system is currently processing interim speech results.
|
|
26
|
+
* Used to show loading indicators or disable UI actions during processing.
|
|
27
|
+
*/
|
|
28
|
+
isProcessingSpeech: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare const checkSpeechSupport: () => boolean;
|
|
31
|
+
export declare function cleanupAndStopSpeechRecognition(speechRecognitionRef: MutableRefObject<SpeechRecognition | null>, handlers: SpeechRecognitionHandlers | null): void;
|
|
32
|
+
export declare function setupSpeechRecognition(setChatInput: Dispatch<SetStateAction<string>>, setVoiceInputState: Dispatch<SetStateAction<SpeechRecognitionState>>, speechRecognitionRef: MutableRefObject<SpeechRecognition | null>): SpeechRecognitionHandlers | null;
|
|
33
|
+
export declare const toggleListening: (isMicOn: boolean, recognition: SpeechRecognition | null) => Promise<void>;
|