Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

FIX: Bug Fixes and UI/UX Improvements in Prompt Studio (#601)

Tahier Hussain71e091ff5150
diff --git a/frontend/src/components/custom-tools/editable-text/EditableText.css b/frontend/src/components/custom-tools/editable-text/EditableText.css
index 9052bb660..3c6d85586 100644
--- a/frontend/src/components/custom-tools/editable-text/EditableText.css
+++ b/frontend/src/components/custom-tools/editable-text/EditableText.css
@@ -18,4 +18,5 @@
.input-header-text {
font-weight: bold;
+ font-size: 20px;
}
diff --git a/frontend/src/components/custom-tools/editable-text/EditableText.jsx b/frontend/src/components/custom-tools/editable-text/EditableText.jsx
index 37c2c81bd..a4f860d45 100644
--- a/frontend/src/components/custom-tools/editable-text/EditableText.jsx
+++ b/frontend/src/components/custom-tools/editable-text/EditableText.jsx
@@ -101,7 +101,7 @@ function EditableText({
return (
<Input
- className="font-size-14 width-100 input-header-text"
+ className="width-100 input-header-text"
value={text}
onChange={handleTextChange}
placeholder="Enter Key"
diff --git a/frontend/src/components/custom-tools/prompt-card/CopyPromptOutputBtn.jsx b/frontend/src/components/custom-tools/prompt-card/CopyPromptOutputBtn.jsx
new file mode 100644
index 000000000..c44bda95f
--- /dev/null
+++ b/frontend/src/components/custom-tools/prompt-card/CopyPromptOutputBtn.jsx
@@ -0,0 +1,26 @@
+import { CopyOutlined } from "@ant-design/icons";
+import { Button, Tooltip } from "antd";
+import PropTypes from "prop-types";
+
+function CopyPromptOutputBtn({ isDisabled, copyToClipboard }) {
+ return (
+ <Tooltip title="Copy prompt output">
+ <Button
+ size="small"
+ type="text"
+ className="prompt-card-action-button"
+ onClick={copyToClipboard}
+ disabled={isDisabled}
+ >
+ <CopyOutlined className="prompt-card-actions-head" />
+ </Button>
+ </Tooltip>
+ );
+}
+
+CopyPromptOutputBtn.propTypes = {
+ isDisabled: PropTypes.bool.isRequired,
+ copyToClipboard: PropTypes.func.isRequired,
+};
+
+export { CopyPromptOutputBtn };
diff --git a/frontend/src/components/custom-tools/prompt-card/DisplayPromptResult.jsx b/frontend/src/components/custom-tools/prompt-card/DisplayPromptResult.jsx
new file mode 100644
index 000000000..26eeca959
--- /dev/null
+++ b/frontend/src/components/custom-tools/prompt-card/DisplayPromptResult.jsx
@@ -0,0 +1,17 @@
+import { Typography } from "antd";
+import PropTypes from "prop-types";
+import { displayPromptResult } from "../../../helpers/GetStaticData";
+
+function DisplayPromptResult({ output }) {
+ return (
+ <Typography.Paragraph className="prompt-card-display-output font-size-12">
+ <div>{displayPromptResult(output, true)}</div>
+ </Typography.Paragraph>
+ );
+}
+
+DisplayPromptResult.propTypes = {
+ output: PropTypes.any.isRequired,
+};
+
+export { DisplayPromptResult };
diff --git a/frontend/src/components/custom-tools/prompt-card/Header.jsx b/frontend/src/components/custom-tools/prompt-card/Header.jsx
index cde0d827b..02e4bc1fa 100644
--- a/frontend/src/components/custom-tools/prompt-card/Header.jsx
+++ b/frontend/src/components/custom-tools/prompt-card/Header.jsx
@@ -123,54 +123,62 @@ function Header({
/>
</Col>
<Col span={12} className="display-flex-right">
- {progressMsg?.message && (
- <Tooltip title={progressMsg?.message || ""}>
- <Tag
- icon={isCoverageLoading && <LoadingOutlined spin />}
- color={progressMsg?.level === "ERROR" ? "error" : "processing"}
- className="display-flex-align-center"
- >
- <div className="tag-max-width ellipsis">
- {progressMsg?.message}
- </div>
- </Tag>
- </Tooltip>
- )}
- {updateStatus?.promptId === promptDetails?.prompt_id && (
- <>
- {updateStatus?.status === promptStudioUpdateStatus.isUpdating && (
- <Tag
- icon={<SyncOutlined spin />}
- color="processing"
- className="display-flex-align-center"
- >
- Updating
- </Tag>
- )}
- {updateStatus?.status === promptStudioUpdateStatus.done && (
+ <div>
+ {progressMsg?.message && (
+ <Tooltip title={progressMsg?.message || ""}>
<Tag
- icon={<CheckCircleOutlined />}
- color="success"
+ icon={isCoverageLoading && <LoadingOutlined spin />}
+ color={progressMsg?.level === "ERROR" ? "error" : "processing"}
className="display-flex-align-center"
>
- Done
+ <div className="tag-max-width ellipsis">
+ {progressMsg?.message}
+ </div>
</Tag>
- )}
- {updateStatus?.status ===
- promptStudioUpdateStatus.validationError && (
- <Tag
- icon={<CheckCircleOutlined />}
- color="error"
- className="display-flex-align-center"
- >
- Invalid JSON Key
- </Tag>
- )}
+ </Tooltip>
+ )}
+ </div>
+ {updateStatus?.promptId === promptDetails?.prompt_id && (
+ <>
+ <div>
+ {updateStatus?.status === promptStudioUpdateStatus.isUpdating && (
+ <Tag
+ icon={<SyncOutlined spin />}
+ color="processing"
+ className="display-flex-align-center"
+ >
+ Updating
+ </Tag>
+ )}
+ </div>
+ <div>
+ {updateStatus?.status === promptStudioUpdateStatus.done && (
+ <Tag
+ icon={<CheckCircleOutlined />}
+ color="success"
+ className="display-flex-align-center"
+ >
+ Done
+ </Tag>
+ )}
+ </div>
+ <div>
+ {updateStatus?.status ===
+ promptStudioUpdateStatus.validationError && (
+ <Tag
+ icon={<CheckCircleOutlined />}
+ color="error"
+ className="display-flex-align-center"
+ >
+ Invalid JSON Key
+ </Tag>
+ )}
+ </div>
</>
)}
{!singlePassExtractMode && !isSimplePromptStudio && (
<>
- <Tooltip title="Run">
+ <Tooltip title="Run all LLMs for current document">
<Button
size="small"
type="text"
@@ -191,7 +199,7 @@ function Header({
<PlayCircleOutlined className="prompt-card-actions-head" />
</Button>
</Tooltip>
- <Tooltip title="Run All">
+ <Tooltip title="Run all LLMs for all documents">
<Button
size="small"
type="text"
diff --git a/frontend/src/components/custom-tools/prompt-card/PromptCard.css b/frontend/src/components/custom-tools/prompt-card/PromptCard.css
index 6331b11dd..2203e2200 100644
--- a/frontend/src/components/custom-tools/prompt-card/PromptCard.css
+++ b/frontend/src/components/custom-tools/prompt-card/PromptCard.css
@@ -91,6 +91,10 @@
flex-basis: 60%;
}
+.prompt-card-display-output {
+ white-space: pre-wrap;
+}
+
.prompt-card-select-type {
width: 100px;
}
@@ -208,3 +212,16 @@
color: #575859;
font-size: 13px;
}
+
+.prompt-output-pad {
+ padding: 0px 10px;
+}
+
+.prompt-output-llm-bg {
+ background-color: #DDDDDD;
+ padding: 10px;
+}
+
+.prompt-output-title {
+ font-size: 18px;
+}
diff --git a/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsx b/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsx
index ff1ded335..b57b2748b 100644
--- a/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsx
+++ b/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsx
@@ -80,7 +80,6 @@ function PromptCardItems({
const [enabledProfiles, setEnabledProfiles] = useState(
llmProfiles.map((profile) => profile.profile_id)
);
- const [expandedProfiles, setExpandedProfiles] = useState([]); // New state for expanded profiles
const [isIndexOpen, setIsIndexOpen] = useState(false);
const isNotSingleLlmProfile = llmProfiles.length > 1;
const divRef = useRef(null);
@@ -157,9 +156,6 @@ function PromptCardItems({
}, [isSinglePassExtractLoading]);
useEffect(() => {
- if (singlePassExtractMode) {
- setExpandedProfiles([]);
- }
setCoverageCount(getCoverageData());
}, [singlePassExtractMode, coverage]);
@@ -296,8 +292,6 @@ function PromptCardItems({
setOpenIndexProfile={setOpenIndexProfile}
enabledProfiles={enabledProfiles}
setEnabledProfiles={setEnabledProfiles}
- expandedProfiles={expandedProfiles}
- setExpandedProfiles={setExpandedProfiles}
isNotSingleLlmProfile={isNotSingleLlmProfile}
setIsIndexOpen={setIsIndexOpen}
enforceType={enforceType}
diff --git a/frontend/src/components/custom-tools/prompt-card/PromptOutput.jsx b/frontend/src/components/custom-tools/prompt-card/PromptOutput.jsx
index 189f43631..6f314a640 100644
--- a/frontend/src/components/custom-tools/prompt-card/PromptOutput.jsx
+++ b/frontend/src/components/custom-tools/prompt-card/PromptOutput.jsx
@@ -1,5 +1,4 @@
import {
- ArrowsAltOutlined,
CheckCircleOutlined,
DatabaseOutlined,
ExclamationCircleFilled,
@@ -25,6 +24,7 @@ import CheckableTag from "antd/es/tag/CheckableTag";
import {
displayPromptResult,
+ formatNumberWithCommas,
getFormattedTotalCost,
} from "../../../helpers/GetStaticData";
import { SpinnerLoader } from "../../widgets/spinner-loader/SpinnerLoader";
@@ -32,6 +32,10 @@ import { TokenUsage } from "../token-usage/TokenUsage";
import { useWindowDimensions } from "../../../hooks/useWindowDimensions";
import { useCustomToolStore } from "../../../store/custom-tool-store";
import { TABLE_ENFORCE_TYPE } from "./constants";
+import { CopyPromptOutputBtn } from "./CopyPromptOutputBtn";
+import { useAlertStore } from "../../../store/alert-store";
+import { PromptOutputExpandBtn } from "./PromptOutputExpandBtn";
+import { DisplayPromptResult } from "./DisplayPromptResult";
let TableOutput;
try {
@@ -53,8 +57,6 @@ function PromptOutput({
setOpenIndexProfile,
enabledProfiles,
setEnabledProfiles,
- expandedProfiles,
- setExpandedProfiles,
isNotSingleLlmProfile,
setIsIndexOpen,
enforceType,
@@ -69,6 +71,7 @@ function PromptOutput({
isSimplePromptStudio,
isPublicSource,
} = useCustomToolStore();
+ const { setAlertDetails } = useAlertStore();
const tooltipContent = (adapterConf) => (
<div>
@@ -80,15 +83,6 @@ function PromptOutput({
</div>
);
- const handleExpandClick = (profile) => {
- const profileId = profile?.profile_id;
- setExpandedProfiles((prevState) =>
- prevState.includes(profileId)
- ? prevState.filter((id) => id !== profileId)
- : [...prevState, profileId]
- );
- };
-
const handleTagChange = (checked, profileId) => {
setEnabledProfiles((prevState) =>
checked
@@ -99,6 +93,27 @@ function PromptOutput({
const getColSpan = () => (componentWidth < 1200 ? 24 : 6);
+ const copyOutputToClipboard = (text) => {
+ if (!text || text === "undefined" || enforceType === TABLE_ENFORCE_TYPE) {
+ return;
+ }
+
+ navigator.clipboard
+ .writeText(text)
+ .then(() => {
+ setAlertDetails({
+ type: "success",
+ content: "Prompt output copied successfully",
+ });
+ })
+ .catch(() => {
+ setAlertDetails({
+ type: "error",
+ content: "Failed to copy prompt output",
+ });
+ });
+ };
+
if (
(singlePassExtractMode || isSimplePromptStudio) &&
(promptDetails?.active || isSimplePromptStudio) &&
@@ -106,46 +121,30 @@ function PromptOutput({
firstResult?.output === 0 ||
spsLoading[selectedDoc?.document_id])
) {
+ const promptOutput = displayPromptResult(firstResult?.output, true);
return (
<>
<Divider className="prompt-card-divider" />
- <div
- className={`prompt-card-result prompt-card-div ${
- expandedProfiles.includes(firstResult?.profileManager) &&
- "prompt-profile-run-expanded"
- }`}
- >
+ <div className="prompt-card-result prompt-card-div">
{isSinglePassExtractLoading ||
spsLoading[selectedDoc?.document_id] ? (
<Spin indicator={<SpinnerLoader size="small" />} />
) : (
<Typography.Paragraph className="prompt-card-res font-size-12">
- <div
- className={
- expandedProfiles.includes(firstResult?.profileManager)
- ? "expanded-output"
- : "collapsed-output"
- }
- >
- {displayPromptResult(firstResult?.output, true)}
- </div>
+ <div className="expanded-output">{promptOutput}</div>
</Typography.Paragraph>
)}
<div className="prompt-profile-run">
- <Tooltip title="Expand">
- <Button
- size="small"
- type="text"
- className="prompt-card-action-button"
- onClick={() =>
- handleExpandClick({
- profile_id: firstResult?.profileManager,
- })
- }
- >
- <ArrowsAltOutlined className="prompt-card-actions-head" />
- </Button>
- </Tooltip>
+ <CopyPromptOutputBtn
+ isDisabled={enforceType === TABLE_ENFORCE_TYPE}
+ copyToClipboard={() => copyOutputToClipboard(promptOutput)}
+ />
+ <PromptOutputExpandBtn
+ llmProfiles={llmProfileDetails}
+ result={result}
+ enforceType={enforceType}
+ displayLlmProfile={false}
+ />
</div>
</div>
</>
@@ -190,12 +189,9 @@ function PromptOutput({
preview={false}
className="prompt-card-llm-icon"
/>
- <Typography.Title
- className="prompt-card-llm-title"
- level={5}
- >
+ <Typography.Text className="prompt-card-llm-title">
{profile?.conf?.LLM}
- </Typography.Title>
+ </Typography.Text>
</div>
<div className="prompt-cost">
<Typography.Text className="prompt-cost-item">
@@ -205,10 +201,14 @@ function PromptOutput({
)}
</Typography.Text>
<Typography.Text className="prompt-cost-item">
- Time: {timers[tokenUsageId] || 0}s
+ Time:
+ {timers[tokenUsageId] || 0}s
</Typography.Text>
<Typography.Text className="prompt-cost-item">
- Cost: ${getFormattedTotalCost(result, profile)}
+ Cost: $
+ {formatNumberWithCommas(
+ getFormattedTotalCost(result, profile)
+ )}
</Typography.Text>
</div>
<div className="prompt-info">
@@ -273,12 +273,7 @@ function PromptOutput({
</Space>
<>
<Divider className="prompt-card-divider" />
- <div
- className={`prompt-card-result prompt-card-div ${
- expandedProfiles.includes(profileId) &&
- "prompt-profile-run-expanded"
- }`}
- >
+ <div className={"prompt-card-result prompt-card-div"}>
{enforceType === TABLE_ENFORCE_TYPE ? (
<div />
) : (
@@ -289,13 +284,7 @@ function PromptOutput({
<Spin indicator={<SpinnerLoader size="small" />} />
) : (
<Typography.Paragraph className="prompt-card-res font-size-12">
- <div
- className={
- expandedProfiles.includes(profileId)
- ? "expanded-output"
- : "collapsed-output"
- }
- >
+ <div className="expanded-output">
{!result.find(
(r) => r?.profileManager === profileId
)?.output ? (
@@ -308,12 +297,13 @@ function PromptOutput({
Yet to run
</Typography.Text>
) : (
- displayPromptResult(
- result.find(
- (r) => r?.profileManager === profileId
- )?.output,
- true
- )
+ <DisplayPromptResult
+ output={
+ result.find(
+ (r) => r?.profileManager === profileId
+ )?.output
+ }
+ />
)}
</div>
</Typography.Paragraph>
@@ -321,7 +311,7 @@ function PromptOutput({
</>
)}
<div className="prompt-profile-run">
- <Tooltip title="Run">
+ <Tooltip title="Run LLM for current document">
<Button
size="small"
type="text"
@@ -336,7 +326,7 @@ function PromptOutput({
<PlayCircleOutlined className="prompt-card-actions-head" />
</Button>
</Tooltip>
- <Tooltip title="Run All">
+ <Tooltip title="Run LLM for all documents">
<Button
size="small"
type="text"
@@ -351,16 +341,25 @@ function PromptOutput({
<PlayCircleFilled className="prompt-card-actions-head" />
</Button>
</Tooltip>
- <Tooltip title="Expand">
- <Button
- size="small"
- type="text"
- className="prompt-card-action-button"
- onClick={() => handleExpandClick(profile)}
- >
- <ArrowsAltOutlined className="prompt-card-actions-head" />
- </Button>
- </Tooltip>
+ <CopyPromptOutputBtn
+ isDisabled={enforceType === TABLE_ENFORCE_TYPE}
+ copyToClipboard={() =>
+ copyOutputToClipboard(
+ displayPromptResult(
+ result.find(
+ (r) => r?.profileManager === profileId
+ )?.output,
+ true
+ )
+ )
+ }
+ />
+ <PromptOutputExpandBtn
+ llmProfiles={llmProfileDetails}
+ result={result}
+ enforceType={enforceType}
+ displayLlmProfile={true}
+ />
</div>
</div>
{enforceType === TABLE_ENFORCE_TYPE && TableOutput && (
@@ -393,8 +392,6 @@ PromptOutput.propTypes = {
setOpenIndexProfile: PropTypes.func.isRequired,
enabledProfiles: PropTypes.array.isRequired,
setEnabledProfiles: PropTypes.func.isRequired,
- expandedProfiles: PropTypes.array.isRequired,
- setExpandedProfiles: PropTypes.func.isRequired,
isNotSingleLlmProfile: PropTypes.bool.isRequired,
setIsIndexOpen: PropTypes.func.isRequired,
enforceType: PropTypes.string.isRequired,
diff --git a/frontend/src/components/custom-tools/prompt-card/PromptOutputExpandBtn.jsx b/frontend/src/components/custom-tools/prompt-card/PromptOutputExpandBtn.jsx
new file mode 100644
index 000000000..f7c219c41
--- /dev/null
+++ b/frontend/src/components/custom-tools/prompt-card/PromptOutputExpandBtn.jsx
@@ -0,0 +1,46 @@
+import { ArrowsAltOutlined } from "@ant-design/icons";
+import { Button, Tooltip } from "antd";
+import PropTypes from "prop-types";
+import { PromptOutputsModal } from "./PromptOutputsModal";
+import { useState } from "react";
+
+function PromptOutputExpandBtn({
+ llmProfiles,
+ result,
+ enforceType,
+ displayLlmProfile,
+}) {
+ const [openModal, setOpenModal] = useState(false);
+
+ return (
+ <>
+ <Tooltip title="Expand">
+ <Button
+ size="small"
+ type="text"
+ className="prompt-card-action-button"
+ onClick={() => setOpenModal(true)}
+ >
+ <ArrowsAltOutlined className="prompt-card-actions-head" />
+ </Button>
+ </Tooltip>
+ <PromptOutputsModal
+ open={openModal}
+ setOpen={setOpenModal}
+ llmProfiles={llmProfiles}
+ result={result}
+ enforceType={enforceType}
+ displayLlmProfile={displayLlmProfile}
+ />
+ </>
+ );
+}
+
+PromptOutputExpandBtn.propTypes = {
+ llmProfiles: PropTypes.array.isRequired,
+ result: PropTypes.array.isRequired,
+ enforceType: PropTypes.string.isRequired,
+ displayLlmProfile: PropTypes.bool.isRequired,
+};
+
+export { PromptOutputExpandBtn };
diff --git a/frontend/src/components/custom-tools/prompt-card/PromptOutputsModal.jsx b/frontend/src/components/custom-tools/prompt-card/PromptOutputsModal.jsx
new file mode 100644
index 000000000..648570e1b
--- /dev/null
+++ b/frontend/src/components/custom-tools/prompt-card/PromptOutputsModal.jsx
@@ -0,0 +1,103 @@
+import { Col, Image, Modal, Row, Typography } from "antd";
+import PropTypes from "prop-types";
+import { DisplayPromptResult } from "./DisplayPromptResult";
+import { TABLE_ENFORCE_TYPE } from "./constants";
+import SpaceWrapper from "../../widgets/space-wrapper/SpaceWrapper";
+
+let TableOutput;
+try {
+ TableOutput = require("../../../plugins/prompt-card/TableOutput").TableOutput;
+} catch {
+ // The component will remain null of it is not available
+}
+
+function PromptOutputsModal({
+ open,
+ setOpen,
+ llmProfiles,
+ result,
+ enforceType,
+ displayLlmProfile,
+}) {
+ return (
+ <Modal
+ open={open}
+ onCancel={() => setOpen(false)}
+ centered
+ maskClosable={false}
+ footer={null}
+ width={1600}
+ >
+ <SpaceWrapper>
+ <Typography.Text
+ className="prompt-output-pad prompt-output-title"
+ strong
+ >
+ Prompt Results
+ </Typography.Text>
+ <Row style={{ height: "85vh" }}>
+ {llmProfiles.map((profile, index) => {
+ const profileId = profile?.profile_id;
+ return (
+ <Col
+ className={`overflow-hidden height-100 prompt-output-pad ${
+ index < llmProfiles?.length - 1 && "border-right-grey"
+ }`}
+ key={profileId}
+ span={24 / llmProfiles?.length}
+ >
+ <div className="flex-dir-col">
+ <div>
+ {displayLlmProfile && (
+ <div className="llm-info prompt-output-llm-bg">
+ <Image
+ src={profile?.icon}
+ width={15}
+ height={15}
+ preview={false}
+ className="prompt-card-llm-icon"
+ />
+ <Typography.Text className="prompt-card-llm-title">
+ {profile?.conf?.LLM}
+ </Typography.Text>
+ </div>
+ )}
+ </div>
+ <div className="flex-1 overflow-y-auto pad-top-10">
+ {enforceType === TABLE_ENFORCE_TYPE && TableOutput ? (
+ <TableOutput
+ output={
+ result.find((r) => r?.profileManager === profileId)
+ ?.output
+ }
+ pagination={10}
+ />
+ ) : (
+ <DisplayPromptResult
+ output={
+ result.find((r) => r?.profileManager === profileId)
+ ?.output
+ }
+ />
+ )}
+ </div>
+ </div>
+ </Col>
+ );
+ })}
+ </Row>
+ </SpaceWrapper>
+ </Modal>
+ );
+}
+
+PromptOutputsModal.propTypes = {
+ open: PropTypes.bool.isRequired,
+ setOpen: PropTypes.func.isRequired,
+ llmProfiles: PropTypes.array.isRequired,
+ result: PropTypes.array.isRequired,
+ enforceType: PropTypes.string.isRequired,
+ displayLlmProfile: PropTypes.bool.isRequired,
+};
+
+export { PromptOutputsModal };
diff --git a/frontend/src/components/custom-tools/token-usage/TokenUsage.jsx b/frontend/src/components/custom-tools/token-usage/TokenUsage.jsx
index dda05e3f4..2f242dedb 100644
--- a/frontend/src/components/custom-tools/token-usage/TokenUsage.jsx
+++ b/frontend/src/components/custom-tools/token-usage/TokenUsage.jsx
@@ -1,6 +1,7 @@
import PropTypes from "prop-types";
import { useEffect, useState } from "react";
import { useTokenUsageStore } from "../../../store/token-usage-store";
+import { formatNumberWithCommas } from "../../../helpers/GetStaticData";
/**
* TokenUsage component displays token usage details in a tag with a tooltip.
@@ -27,7 +28,7 @@ function TokenUsage({ tokenUsageId }) {
return 0;
}
- return tokens?.total_tokens;
+ return formatNumberWithCommas(tokens?.total_tokens);
}
TokenUsage.propTypes = {
diff --git a/frontend/src/helpers/GetStaticData.js b/frontend/src/helpers/GetStaticData.js
index 6ad179ee8..659cbbcd0 100644
--- a/frontend/src/helpers/GetStaticData.js
+++ b/frontend/src/helpers/GetStaticData.js
@@ -503,6 +503,21 @@ const displayURL = (text) => {
return getBaseUrl() + "/" + text;
};
+const formatNumberWithCommas = (number) => {
+ if (!number && number !== 0) return null;
+
+ // Convert the number to a string and split into integer and decimal parts.
+ const [integerPart, decimalPart] = number.toString().split(".");
+
+ // Add commas to the integer part.
+ const formattedIntegerPart = Number(integerPart).toLocaleString();
+
+ // Reassemble the formatted number, including the decimal part if it exists.
+ return decimalPart
+ ? `${formattedIntegerPart}.${decimalPart}`
+ : formattedIntegerPart;
+};
+
export {
CONNECTOR_TYPE_MAP,
O_AUTH_PROVIDERS,
@@ -547,4 +562,5 @@ export {
pollForCompletion,
getDocIdFromKey,
displayURL,
+ formatNumberWithCommas,
};