@cognizant-ai-lab/ui-common 1.5.1 → 1.7.0

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.
Files changed (57) hide show
  1. package/dist/components/AgentChat/ChatCommon/ChatCommon.d.ts +16 -6
  2. package/dist/components/AgentChat/ChatCommon/ChatCommon.js +250 -166
  3. package/dist/components/AgentChat/ChatCommon/ChatHistory.d.ts +1 -7
  4. package/dist/components/AgentChat/ChatCommon/ChatHistory.js +33 -22
  5. package/dist/components/AgentChat/ChatCommon/Conversation.d.ts +3 -5
  6. package/dist/components/AgentChat/ChatCommon/Conversation.js +35 -57
  7. package/dist/components/AgentChat/ChatCommon/ConversationTurn.d.ts +9 -5
  8. package/dist/components/AgentChat/ChatCommon/ConversationTurn.js +3 -2
  9. package/dist/components/AgentChat/ChatCommon/FormattedMarkdown.js +5 -3
  10. package/dist/components/AgentChat/ChatCommon/SampleQueries.d.ts +3 -0
  11. package/dist/components/AgentChat/ChatCommon/SampleQueries.js +6 -3
  12. package/dist/components/AgentChat/ChatCommon/Thinking.d.ts +12 -0
  13. package/dist/components/AgentChat/ChatCommon/Thinking.js +51 -0
  14. package/dist/components/AgentChat/Common/LlmChatButton.d.ts +2 -2
  15. package/dist/components/AgentChat/Common/Types.d.ts +6 -5
  16. package/dist/components/AgentChat/Common/Types.js +5 -0
  17. package/dist/components/AgentChat/Common/Utils.d.ts +1 -1
  18. package/dist/components/AgentChat/Common/Utils.js +13 -7
  19. package/dist/components/ChatBot/ChatBot.d.ts +0 -4
  20. package/dist/components/ChatBot/ChatBot.js +2 -2
  21. package/dist/components/Common/AccordionLite.d.ts +14 -0
  22. package/dist/components/Common/AccordionLite.js +25 -0
  23. package/dist/components/Common/ConfirmationModal.d.ts +1 -1
  24. package/dist/components/Common/CustomerLogo.js +1 -3
  25. package/dist/components/Common/MUIAlert.d.ts +1 -0
  26. package/dist/components/Common/MUIAlert.js +3 -4
  27. package/dist/components/MultiAgentAccelerator/AgentFlow.d.ts +1 -0
  28. package/dist/components/MultiAgentAccelerator/AgentFlow.js +154 -59
  29. package/dist/components/MultiAgentAccelerator/AgentNode.d.ts +1 -0
  30. package/dist/components/MultiAgentAccelerator/AgentNode.js +46 -45
  31. package/dist/components/MultiAgentAccelerator/GraphLayouts.js +12 -4
  32. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +103 -24
  33. package/dist/components/Settings/ApiKeyInput.d.ts +16 -0
  34. package/dist/components/Settings/ApiKeyInput.js +70 -0
  35. package/dist/components/Settings/SettingsDialog.js +30 -3
  36. package/dist/controller/llm/Providers.d.ts +2 -0
  37. package/dist/controller/llm/Providers.js +41 -0
  38. package/dist/index.d.ts +0 -1
  39. package/dist/index.js +0 -1
  40. package/dist/state/Settings.d.ts +2 -0
  41. package/dist/state/Settings.js +1 -0
  42. package/dist/tsconfig.build.tsbuildinfo +1 -1
  43. package/package.json +2 -2
  44. package/dist/components/AgentChat/ChatCommon/AgentConnectivity.d.ts +0 -14
  45. package/dist/components/AgentChat/ChatCommon/AgentConnectivity.js +0 -23
  46. package/dist/components/AgentChat/ChatCommon/AgentIntro.d.ts +0 -12
  47. package/dist/components/AgentChat/ChatCommon/AgentIntro.js +0 -19
  48. package/dist/components/AgentChat/ChatCommon/AgentMetadata.d.ts +0 -14
  49. package/dist/components/AgentChat/ChatCommon/AgentMetadata.js +0 -43
  50. package/dist/components/AgentChat/ChatCommon/Const.d.ts +0 -1
  51. package/dist/components/AgentChat/ChatCommon/Const.js +0 -2
  52. package/dist/components/AgentChat/ChatCommon/Greetings.d.ts +0 -1
  53. package/dist/components/AgentChat/ChatCommon/Greetings.js +0 -38
  54. package/dist/components/AgentChat/ChatCommon/UserQueryDisplay.d.ts +0 -7
  55. package/dist/components/AgentChat/ChatCommon/UserQueryDisplay.js +0 -32
  56. package/dist/components/Common/LlmChatOptionsButton.d.ts +0 -6
  57. package/dist/components/Common/LlmChatOptionsButton.js +0 -31
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cognizant-ai-lab/ui-common",
3
3
  "description": "A shared UI component library for Cognizant AI Labs projects",
4
- "version": "1.5.1",
4
+ "version": "1.7.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "yarn clean && yarn generate && yarn run --top-level tsc --project tsconfig.build.json && fix-esm-import-path dist > /dev/null",
@@ -14,7 +14,6 @@
14
14
  "@langchain/core": "1.1.17",
15
15
  "@xyflow/react": "12.10.1",
16
16
  "http-status": "1.7.3",
17
- "jsonrepair": "3.8.0",
18
17
  "lodash-es": "4.18.1",
19
18
  "notistack": "3.0.2",
20
19
  "react-joyride": "3.1.0",
@@ -22,6 +21,7 @@
22
21
  "react-syntax-highlighter": "16.1.0",
23
22
  "rehype-raw": "7.0.0",
24
23
  "rehype-slug": "6.0.0",
24
+ "remark-gfm": "4.0.1",
25
25
  "uuid": "14.0.0",
26
26
  "zustand": "4.5.7"
27
27
  },
@@ -1,14 +0,0 @@
1
- import { FC } from "react";
2
- import { ConnectivityInfo } from "../../../generated/neuro-san/NeuroSanClient.js";
3
- interface AgentConnectivityProps {
4
- readonly id: string;
5
- readonly description: string;
6
- readonly connectivityInfo?: readonly ConnectivityInfo[];
7
- readonly targetAgent: string;
8
- }
9
- /**
10
- * Render the connectivity info as a list of origins and their tools
11
- * @returns A MUIAccordion representing the connectivity info with agents and their tools
12
- */
13
- export declare const AgentConnectivity: FC<AgentConnectivityProps>;
14
- export {};
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { MUIAccordion } from "../../Common/MUIAccordion.js";
3
- const renderConnectivityInfo = (targetAgent, connectivityInfo) => (_jsx(_Fragment, { children: connectivityInfo
4
- // Don't show connection to self
5
- ?.filter((info) => info.origin.toLowerCase() !== targetAgent.toLowerCase())
6
- // Sort by origin name
7
- .sort((a, b) => a.origin.localeCompare(b.origin))
8
- // Render each origin and its tools
9
- .map((info) => (_jsxs("li", { id: info.origin, children: [_jsx("b", { children: info.origin }), _jsx("ul", { id: `${info.origin}-tools`, style: { marginLeft: "8px" }, children: info?.tools?.map((tool) => (_jsx("li", { children: tool }, tool))) })] }, info.origin))) }));
10
- /**
11
- * Render the connectivity info as a list of origins and their tools
12
- * @returns A MUIAccordion representing the connectivity info with agents and their tools
13
- */
14
- export const AgentConnectivity = ({ connectivityInfo, description, id, targetAgent }) => (_jsx(MUIAccordion, { id: `${id}-agent-details`, sx: { marginTop: "1rem", marginBottom: "1rem" }, items: [
15
- {
16
- title: "Network Details",
17
- content: [
18
- `My description is: "${description}"`,
19
- _jsx("h6", { id: "connectivity-header", style: { marginTop: "1rem" }, children: "I can connect you to the following agents" }, "item-1"),
20
- _jsx("ul", { id: "connectivity-list", "aria-labelledby": "connectivity-header", style: { marginTop: "1rem" }, children: renderConnectivityInfo(targetAgent, connectivityInfo) }, "item-2"),
21
- ],
22
- },
23
- ] }));
@@ -1,12 +0,0 @@
1
- import { FC } from "react";
2
- import { CombinedAgentType } from "../Common/Types.js";
3
- interface AgentIntroProps {
4
- readonly agentDisplayName: string;
5
- readonly customAgentGreetings?: Partial<Record<CombinedAgentType, string>>;
6
- readonly targetAgent: string;
7
- }
8
- /**
9
- * Component to display agent intro, including agent name, image, and greeting.
10
- */
11
- export declare const AgentIntro: FC<AgentIntroProps>;
12
- export {};
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import { AGENT_IMAGE } from "./Const.js";
4
- import { GENERIC_AGENT_GREETINGS } from "./Greetings.js";
5
- import { UserQueryDisplay } from "./UserQueryDisplay.js";
6
- /**
7
- * Component to display agent intro, including agent name, image, and greeting.
8
- */
9
- export const AgentIntro = ({ agentDisplayName, customAgentGreetings, targetAgent }) => {
10
- // eslint-disable-next-line react/hook-use-state -- we want to set this an "on mount" value only and never update
11
- const [greeting] = useState(() => {
12
- if (customAgentGreetings?.[targetAgent]) {
13
- return customAgentGreetings[targetAgent];
14
- }
15
- const randomIndex = Math.floor(Math.random() * GENERIC_AGENT_GREETINGS.length);
16
- return GENERIC_AGENT_GREETINGS[randomIndex];
17
- });
18
- return (_jsxs(_Fragment, { children: [_jsx(UserQueryDisplay, { userQuery: agentDisplayName, title: targetAgent, userImage: AGENT_IMAGE }), greeting] }));
19
- };
@@ -1,14 +0,0 @@
1
- import { FC } from "react";
2
- interface AgentMetadataDisplayProps {
3
- readonly currentUser: string;
4
- readonly disableQueries: boolean;
5
- readonly handleSend: (query: string) => Promise<void>;
6
- readonly id: string;
7
- readonly neuroSanURL: string;
8
- readonly targetAgent: string;
9
- }
10
- /**
11
- * Component to display agent metadata, including connectivity info and sample queries.
12
- */
13
- export declare const AgentMetadata: FC<AgentMetadataDisplayProps>;
14
- export {};
@@ -1,43 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useState } from "react";
3
- import { AgentConnectivity } from "./AgentConnectivity.js";
4
- import { SampleQueries } from "./SampleQueries.js";
5
- import { getAgentFunction, getConnectivity } from "../../../controller/agent/Agent.js";
6
- import { NotificationType, sendNotification } from "../../Common/notification.js";
7
- import { isLegacyAgentType } from "../Common/Types.js";
8
- /**
9
- * Component to display agent metadata, including connectivity info and sample queries.
10
- */
11
- export const AgentMetadata = ({ currentUser, disableQueries, handleSend, id, neuroSanURL, targetAgent, }) => {
12
- const [sampleQueries, setSampleQueries] = useState([]);
13
- const [connectivityInfo, setConnectivityInfo] = useState([]);
14
- const [description, setDescription] = useState("");
15
- useEffect(() => {
16
- const fetchAgentDetails = async () => {
17
- // It is a Neuro-san agent, so get the function and connectivity info
18
- try {
19
- const agentFunction = await getAgentFunction(neuroSanURL, targetAgent, currentUser);
20
- setDescription(agentFunction?.function?.description || "");
21
- }
22
- catch {
23
- // For now, just return. May be a legacy agent without a functional description in Neuro-san.
24
- return;
25
- }
26
- try {
27
- const connectivity = await getConnectivity(neuroSanURL, targetAgent, currentUser);
28
- setConnectivityInfo(connectivity?.connectivity_info);
29
- const sampleQueriesTmp = (connectivity?.metadata?.["sample_queries"] || []);
30
- setSampleQueries(sampleQueriesTmp);
31
- }
32
- catch (e) {
33
- // If we got here, it means we got the agent function successfully, but failed to get connectivity info.
34
- // This is unexpected.
35
- sendNotification(NotificationType.error, `Failed to get connectivity info for ${targetAgent}. Error: ${e}`);
36
- }
37
- };
38
- if (targetAgent && !isLegacyAgentType(targetAgent)) {
39
- void fetchAgentDetails();
40
- }
41
- }, [currentUser, neuroSanURL, targetAgent]);
42
- return (_jsxs(_Fragment, { children: [description && connectivityInfo?.length > 0 && (_jsx(AgentConnectivity, { connectivityInfo: connectivityInfo, description: description, id: `${id}-connectivity`, targetAgent: targetAgent })), sampleQueries?.length > 0 && (_jsx(SampleQueries, { disabled: disableQueries, handleSend: handleSend, sampleQueries: sampleQueries }))] }));
43
- };
@@ -1 +0,0 @@
1
- export declare const AGENT_IMAGE = "/agent.svg";
@@ -1,2 +0,0 @@
1
- // Avatar to use for agents in chat
2
- export const AGENT_IMAGE = "/agent.svg";
@@ -1 +0,0 @@
1
- export declare const GENERIC_AGENT_GREETINGS: string[];
@@ -1,38 +0,0 @@
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 GENERIC_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
- ];
@@ -1,7 +0,0 @@
1
- import { SxProps } from "@mui/material/styles";
2
- export declare const UserQueryDisplay: ({ sx, userQuery, title, userImage, }: {
3
- sx?: SxProps;
4
- userQuery: string;
5
- title: string;
6
- userImage: string;
7
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,32 +0,0 @@
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 Box from "@mui/material/Box";
18
- import { styled } from "@mui/material/styles";
19
- import { DEFAULT_USER_IMAGE } from "../../../const.js";
20
- // #region: Styled Components
21
- const UserQueryContainer = styled("div")(({ theme }) => ({
22
- backgroundColor: theme.palette.background.paper,
23
- border: "var(--bs-border-width) var(--bs-border-style)",
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
- display: "inline-flex",
27
- padding: "10px",
28
- }));
29
- // #endregion: Styled Components
30
- export const UserQueryDisplay = ({ sx, userQuery, title, userImage, }) => {
31
- return (_jsx(Box, { id: "user-query-div", sx: [{ marginBottom: "1rem" }, ...(Array.isArray(sx) ? sx : [sx])], 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", style: { alignSelf: "center" } }), _jsx("span", { id: "user-query", style: { marginLeft: "0.625rem", marginTop: "0.125rem" }, children: userQuery })] }) }));
32
- };
@@ -1,6 +0,0 @@
1
- type LLMChatGroupConfigBtnProps = {
2
- enabled?: boolean;
3
- posRight?: number;
4
- };
5
- export declare const LlmChatOptionsButton: import("@emotion/styled").StyledComponent<import("@mui/material/Button").ButtonOwnProps & Omit<import("@mui/material/ButtonBase").ButtonBaseOwnProps, keyof import("@mui/material/Button").ButtonOwnProps> & Omit<import("@mui/material/ButtonBase").ButtonBaseOwnProps, "tabIndex" | "type" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "nativeButton" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | keyof import("@mui/material/Button").ButtonOwnProps> & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "style" | "color" | "sx" | "children" | "className" | "tabIndex" | "type" | "classes" | "variant" | "disabled" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "nativeButton" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "href" | "size" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "loading" | "loadingIndicator" | "loadingPosition" | "startIcon"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & LLMChatGroupConfigBtnProps, {}, {}>;
6
- export {};
@@ -1,31 +0,0 @@
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 Button from "@mui/material/Button";
17
- import { styled } from "@mui/material/styles";
18
- import { getZIndex } from "../../utils/zIndexLayers.js";
19
- export const LlmChatOptionsButton = styled(Button, {
20
- shouldForwardProp: (prop) => prop !== "enabled" && prop !== "posRight" && prop !== "posBottom",
21
- })(({ theme, enabled, posRight }) => ({
22
- position: "absolute",
23
- top: 10,
24
- right: posRight || null,
25
- zIndex: getZIndex(1, null), // Seems to only be needed on Analytics Chat, but apply to all.
26
- background: `${enabled ? theme.palette.primary.main : theme.palette.grey[600]} !important`,
27
- borderColor: `${enabled ? theme.palette.primary.main : theme.palette.grey[600]} !important`,
28
- borderRadius: "var(--bs-border-radius)",
29
- width: "30px",
30
- height: "30px",
31
- }));