LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
FIX: Optimized the Re-rendering of the Prompt Card Component (#696)
Tahier Hussain70bdcf4944ae
diff --git a/frontend/src/components/custom-tools/document-parser/DocumentParser.jsx b/frontend/src/components/custom-tools/document-parser/DocumentParser.jsxindex 17ac6ae45..18b603b50 100644--- a/frontend/src/components/custom-tools/document-parser/DocumentParser.jsx+++ b/frontend/src/components/custom-tools/document-parser/DocumentParser.jsx@@ -4,10 +4,7 @@ import { DndProvider } from "react-dnd";import { HTML5Backend } from "react-dnd-html5-backend";import "./DocumentParser.css";-import {- promptStudioUpdateStatus,- promptType,-} from "../../../helpers/GetStaticData";+import { promptType } from "../../../helpers/GetStaticData";import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate";import { useAlertStore } from "../../../store/alert-store";import { useCustomToolStore } from "../../../store/custom-tool-store";@@ -36,11 +33,8 @@ function DocumentParser({scrollToBottom,setScrollToBottom,}) {- const [updateStatus, setUpdateStatus] = useState({- promptId: null,- status: null,- });const [enforceTypeList, setEnforceTypeList] = useState([]);+ const [updatedPromptsCopy, setUpdatedPromptsCopy] = useState({});const bottomRef = useRef(null);const { details, isSimplePromptStudio, updateCustomTool, getDropdownItems } =useCustomToolStore();@@ -56,6 +50,22 @@ function DocumentParser({return { value: outputTypeData[item] };});setEnforceTypeList(dropdownList1);++ return () => {+ // Set the prompts with updated changes when the component is unmounted+ const modifiedDetails = { ...details };+ const modifiedPrompts = [...(modifiedDetails?.prompts || [])].map(+ (item) => {+ const itemPromptId = item?.prompt_id;+ if (itemPromptId && updatedPromptsCopy[itemPromptId]) {+ return updatedPromptsCopy[itemPromptId];+ }+ return item;+ }+ );+ modifiedDetails["prompts"] = modifiedPrompts;+ updateCustomTool({ details: modifiedDetails });+ };}, []);useEffect(() => {@@ -70,45 +80,14 @@ function DocumentParser({return `/api/v1/unstract/${sessionDetails?.orgId}/prompt-studio/prompt/${urlPath}`;};- const handleChange = async (- event,- promptId,- dropdownItem,- isUpdateStatus = false,- isPromptUpdate = false- ) => {+ const handleChangePromptCard = async (name, value, promptId) => {const promptsAndNotes = details?.prompts || [];- let name = "";- let value = "";- if (dropdownItem?.length) {- name = dropdownItem;- value = event;- } else {- name = event.target.name;- value = event.target.value;- }if (name === "prompt_key") {// Return if the prompt or the prompt key is emptyif (!value) {return;}- if (!isValidJsonKey(value)) {- handleUpdateStatus(- isUpdateStatus,- promptId,- promptStudioUpdateStatus.validationError- );- return;- }- }-- function isValidJsonKey(key) {- // Check for Prompt-Key- // Allowed case, contains alphanumeric characters and underscores,- // and doesn't start with a number.- const regex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;- return regex.test(key);}const index = promptsAndNotes.findIndex(@@ -143,72 +122,13 @@ function DocumentParser({data: body,};- const modifiedDetails = { ...details };- const modifiedPrompts = [...(modifiedDetails?.prompts || [])].map(- (item) => {- if (item?.prompt_id === promptId) {- return {- ...item,- [name]: value, // Update the specific field instantly- };- }- return item;- }- );- modifiedDetails["prompts"] = modifiedPrompts;- updateCustomTool({ details: modifiedDetails });-- handleUpdateStatus(- isUpdateStatus,- promptId,- promptStudioUpdateStatus.isUpdating- );-return axiosPrivate(requestOptions)- .then((res) => {- const data = res?.data;- const modifiedPrompts = [...(modifiedDetails?.prompts || [])].map(- (item) => {- if (item?.prompt_id === data?.prompt_id) {- return data;- }- return item;- }- );- modifiedDetails["prompts"] = modifiedPrompts;- if (!isPromptUpdate) {- updateCustomTool({ details: modifiedDetails });- }- handleUpdateStatus(- isUpdateStatus,- promptId,- promptStudioUpdateStatus.done- );- })+ .then((res) => res).catch((err) => {setAlertDetails(handleException(err, "Failed to update"));- updateCustomTool({ details });- handleUpdateStatus(isUpdateStatus, promptId, null);- })- .finally(() => {- if (isUpdateStatus) {- setTimeout(() => {- handleUpdateStatus(true, promptId, null);- }, 3000);- }});};- const handleUpdateStatus = (isUpdate, promptId, value) => {- if (!isUpdate) {- return;- }- setUpdateStatus({- promptId: promptId,- status: value,- });- };-const handleDelete = (promptId) => {let url = promptUrl(promptId + "/");if (isSimplePromptStudio) {@@ -351,12 +271,12 @@ function DocumentParser({<PromptDnditem={item}index={index}- handleChange={handleChange}+ handleChangePromptCard={handleChangePromptCard}handleDelete={handleDelete}- updateStatus={updateStatus}moveItem={moveItem}outputs={getPromptOutputs(item?.prompt_id)}enforceTypeList={enforceTypeList}+ setUpdatedPromptsCopy={setUpdatedPromptsCopy}/><div ref={bottomRef} className="doc-parser-pad-bottom" /></div>diff --git a/frontend/src/components/custom-tools/editable-text/EditableText.jsx b/frontend/src/components/custom-tools/editable-text/EditableText.jsxindex a4f860d45..b2f90bd4c 100644--- a/frontend/src/components/custom-tools/editable-text/EditableText.jsx+++ b/frontend/src/components/custom-tools/editable-text/EditableText.jsx@@ -30,7 +30,7 @@ function EditableText({useEffect(() => {setText(defaultText);- }, []);+ }, [defaultText]);useEffect(() => {// Attach the event listener when the component mountsdiff --git a/frontend/src/components/custom-tools/notes-card/NotesCard.jsx b/frontend/src/components/custom-tools/notes-card/NotesCard.jsxindex 309ed28b5..162e16e20 100644--- a/frontend/src/components/custom-tools/notes-card/NotesCard.jsx+++ b/frontend/src/components/custom-tools/notes-card/NotesCard.jsx@@ -7,32 +7,96 @@ import {import { Button, Card, Col, Collapse, Row, Space, Tag, Tooltip } from "antd";import PropTypes from "prop-types";import "./NotesCard.css";-import { useState } from "react";+import { useEffect, useState } from "react";import { EditableText } from "../editable-text/EditableText";import { ConfirmModal } from "../../widgets/confirm-modal/ConfirmModal";import { promptStudioUpdateStatus } from "../../../helpers/GetStaticData";import { ExpandCardBtn } from "../prompt-card/ExpandCardBtn";+import { handleUpdateStatus } from "../prompt-card/constants";function NotesCard({- details,- handleChange,+ promptDetails,+ handleChangePromptCard,handleDelete,- updateStatus,updatePlaceHolder,+ setUpdatedPromptsCopy,}) {+ const [promptDetailsState, setPromptDetailsState] = useState({});+ const [isPromptDetailsStateUpdated, setIsPromptDetailsStateUpdated] =+ useState(false);+ const [updateStatus, setUpdateStatus] = useState({+ promptId: null,+ status: null,+ });const [promptKey, setPromptKey] = useState("");const [promptText, setPromptText] = useState("");const [isEditingTitle, setIsEditingTitle] = useState(false);const [isEditingNote, setIsEditingNote] = useState(false);const [expandCard, setExpandCard] = useState(true);+ useEffect(() => {+ if (+ isPromptDetailsStateUpdated ||+ !Object.keys(promptDetails || {})?.length+ )+ return;+ setPromptDetailsState(promptDetails);+ setIsPromptDetailsStateUpdated(true);+ }, [promptDetails]);+const enableEdit = (event) => {event.stopPropagation();setIsEditingTitle(true);setIsEditingNote(true);};+ const handleChange = async (+ value,+ promptId,+ name,+ isUpdateStatus = false+ ) => {+ const prevPromptDetailsState = { ...promptDetailsState };++ const updatedPromptDetailsState = { ...promptDetailsState };+ updatedPromptDetailsState[name] = value;++ handleUpdateStatus(+ isUpdateStatus,+ promptId,+ promptStudioUpdateStatus.isUpdating,+ setUpdateStatus+ );+ setPromptDetailsState(updatedPromptDetailsState);++ return handleChangePromptCard(name, value, promptId)+ .then((res) => {+ const data = res?.data;+ setUpdatedPromptsCopy((prev) => {+ prev[promptId] = data;+ return prev;+ });+ handleUpdateStatus(+ isUpdateStatus,+ promptId,+ promptStudioUpdateStatus.done,+ setUpdateStatus+ );+ })+ .catch(() => {+ handleUpdateStatus(isUpdateStatus, promptId, null, setUpdateStatus);+ setPromptDetailsState(prevPromptDetailsState);+ })+ .finally(() => {+ if (isUpdateStatus) {+ setTimeout(() => {+ handleUpdateStatus(true, promptId, null, setUpdateStatus);+ }, 3000);+ }+ });+ };+return (<Card className="tool-ide-notes-card"><Space@@ -47,14 +111,14 @@ function NotesCard({setIsEditing={setIsEditingTitle}text={promptKey}setText={setPromptKey}- promptId={details?.prompt_id}- defaultText={details?.prompt_key}+ promptId={promptDetailsState?.prompt_id}+ defaultText={promptDetailsState?.prompt_key}handleChange={handleChange}placeHolder={updatePlaceHolder}/></Col><Col span={6} className="display-flex-right">- {updateStatus?.promptId === details?.prompt_id && (+ {updateStatus?.promptId === promptDetailsState?.prompt_id && (<>{updateStatus?.status ===promptStudioUpdateStatus.isUpdating && (@@ -92,7 +156,7 @@ function NotesCard({</Button></Tooltip><ConfirmModal- handleConfirm={() => handleDelete(details?.prompt_id)}+ handleConfirm={() => handleDelete(promptDetailsState?.prompt_id)}content="The note will be permanently deleted."><Tooltip title="Delete">@@ -114,8 +178,8 @@ function NotesCard({setIsEditing={setIsEditingNote}text={promptText}setText={setPromptText}- promptId={details?.prompt_id}- defaultText={details?.prompt}+ promptId={promptDetailsState?.prompt_id}+ defaultText={promptDetailsState?.prompt}handleChange={handleChange}isTextarea={true}placeHolder={updatePlaceHolder}@@ -128,11 +192,11 @@ function NotesCard({}NotesCard.propTypes = {- details: PropTypes.object.isRequired,- handleChange: PropTypes.func.isRequired,+ promptDetails: PropTypes.object.isRequired,+ handleChangePromptCard: PropTypes.func.isRequired,handleDelete: PropTypes.func.isRequired,- updateStatus: PropTypes.object.isRequired,updatePlaceHolder: PropTypes.string,+ setUpdatedPromptsCopy: PropTypes.func.isRequired,};export { NotesCard };diff --git a/frontend/src/components/custom-tools/prompt-card/PrompDnd.jsx b/frontend/src/components/custom-tools/prompt-card/PrompDnd.jsxindex d921d9820..9fbd3ad65 100644--- a/frontend/src/components/custom-tools/prompt-card/PrompDnd.jsx+++ b/frontend/src/components/custom-tools/prompt-card/PrompDnd.jsx@@ -10,12 +10,12 @@ import { useCustomToolStore } from "../../../store/custom-tool-store";function PromptDnd({item,index,- handleChange,+ handleChangePromptCard,handleDelete,- updateStatus,moveItem,outputs,enforceTypeList,+ setUpdatedPromptsCopy,}) {const ref = useRef(null);const { isSimplePromptStudio } = useCustomToolStore();@@ -41,21 +41,21 @@ function PromptDnd({{(item.prompt_type === promptType.prompt || isSimplePromptStudio) && (<PromptCardpromptDetails={item}- handleChange={handleChange}+ handleChangePromptCard={handleChangePromptCard}handleDelete={handleDelete}- updateStatus={updateStatus}updatePlaceHolder="Enter Prompt"promptOutputs={outputs}enforceTypeList={enforceTypeList}+ setUpdatedPromptsCopy={setUpdatedPromptsCopy}/>)}{item.prompt_type === promptType.notes && (<NotesCard- details={item}- handleChange={handleChange}+ promptDetails={item}+ handleChangePromptCard={handleChangePromptCard}handleDelete={handleDelete}- updateStatus={updateStatus}updatePlaceHolder="Enter Notes"+ setUpdatedPromptsCopy={setUpdatedPromptsCopy}/>)}</div>@@ -65,12 +65,12 @@ function PromptDnd({PromptDnd.propTypes = {item: PropTypes.object.isRequired,index: PropTypes.number.isRequired,- handleChange: PropTypes.func.isRequired,+ handleChangePromptCard: PropTypes.func.isRequired,handleDelete: PropTypes.func.isRequired,- updateStatus: PropTypes.object.isRequired,moveItem: PropTypes.func.isRequired,outputs: PropTypes.object.isRequired,enforceTypeList: PropTypes.array.isRequired,+ setUpdatedPromptsCopy: PropTypes.func.isRequired,};export { PromptDnd };diff --git a/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx b/frontend/src/components/custom-tools/prompt-card/PromptCard.jsxindex 4be0efbe8..9f5ea896e 100644--- a/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx+++ b/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx@@ -4,6 +4,7 @@ import { useEffect, useState } from "react";import {generateUUID,pollForCompletion,+ promptStudioUpdateStatus,} from "../../../helpers/GetStaticData";import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate";import { useExceptionHandler } from "../../../hooks/useExceptionHandler";@@ -16,6 +17,7 @@ import usePostHogEvents from "../../../hooks/usePostHogEvents";import { PromptCardItems } from "./PromptCardItems";import "./PromptCard.css";import usePromptOutput from "../../../hooks/usePromptOutput";+import { handleUpdateStatus } from "./constants";let promptRunApiSps;try {@@ -27,13 +29,20 @@ try {function PromptCard({promptDetails,- handleChange,+ handleChangePromptCard,handleDelete,- updateStatus,updatePlaceHolder,promptOutputs,enforceTypeList,+ setUpdatedPromptsCopy,}) {+ const [promptDetailsState, setPromptDetailsState] = useState({});+ const [isPromptDetailsStateUpdated, setIsPromptDetailsStateUpdated] =+ useState(false);+ const [updateStatus, setUpdateStatus] = useState({+ promptId: null,+ status: null,+ });const [isRunLoading, setIsRunLoading] = useState({});const [promptKey, setPromptKey] = useState("");const [promptText, setPromptText] = useState("");@@ -67,13 +76,23 @@ function PromptCard({const { setPostHogCustomEvent } = usePostHogEvents();const { updatePromptOutputState } = usePromptOutput();+ useEffect(() => {+ if (+ isPromptDetailsStateUpdated ||+ !Object.keys(promptDetails || {})?.length+ )+ return;+ setPromptDetailsState(promptDetails);+ setIsPromptDetailsStateUpdated(true);+ }, [promptDetails]);+useEffect(() => {// Find the latest message that matches the criteriaconst msg = [...messages].reverse().find((item) =>- (item?.component?.prompt_id === promptDetails?.prompt_id ||+ (item?.component?.prompt_id === promptDetailsState?.prompt_id ||item?.component?.prompt_key === promptKey) &&(item?.level === "INFO" || item?.level === "ERROR"));@@ -92,9 +111,9 @@ function PromptCard({useEffect(() => {setSelectedLlmProfileId(- promptDetails?.profile_manager || llmProfiles[0]?.profile_id+ promptDetailsState?.profile_manager || llmProfiles[0]?.profile_id);- }, [promptDetails]);+ }, [promptDetailsState]);useEffect(() => {resetInfoMsgs();@@ -109,7 +128,7 @@ function PromptCard({useEffect(() => {let listOfIds = [...disableLlmOrDocChange];- const promptId = promptDetails?.prompt_id;+ const promptId = promptDetailsState?.prompt_id;const isIncluded = listOfIds.includes(promptId);const isDocLoading = docOutputs?.some(@@ -129,7 +148,7 @@ function PromptCard({}updateCustomTool({ disableLlmOrDocChange: listOfIds });- }, [docOutputs, promptDetails, updateCustomTool]);+ }, [docOutputs]);useEffect(() => {if (isCoverageLoading && coverageTotal === listOfDocs?.length) {@@ -153,6 +172,61 @@ function PromptCard({}}, [llmProfiles]);+ const handleChange = async (+ event,+ promptId,+ dropdownItem,+ isUpdateStatus = false+ ) => {+ let name = "";+ let value = "";+ if (dropdownItem?.length) {+ name = dropdownItem;+ value = event;+ } else {+ name = event.target.name;+ value = event.target.value;+ }++ const prevPromptDetailsState = { ...promptDetailsState };++ const updatedPromptDetailsState = { ...promptDetailsState };+ updatedPromptDetailsState[name] = value;++ handleUpdateStatus(+ isUpdateStatus,+ promptId,+ promptStudioUpdateStatus.isUpdating,+ setUpdateStatus+ );+ setPromptDetailsState(updatedPromptDetailsState);+ return handleChangePromptCard(name, value, promptId)+ .then((res) => {+ const data = res?.data;+ setUpdatedPromptsCopy((prev) => {+ prev[promptId] = data;+ return prev;+ });+ handleUpdateStatus(+ isUpdateStatus,+ promptId,+ promptStudioUpdateStatus.done,+ setUpdateStatus+ );+ })+ .catch(() => {+ handleUpdateStatus(isUpdateStatus, promptId, null, setUpdateStatus);+ setPromptDetailsState(prevPromptDetailsState);+ })+ .finally(() => {+ if (isUpdateStatus) {+ setTimeout(() => {+ handleUpdateStatus(true, promptId, null, setUpdateStatus);+ }, 3000);+ }+ });+ };+// Function to update loading state for a specific document and profileconst handleIsRunLoading = (docId, profileId, isLoading) => {setIsRunLoading((prevLoadingProfiles) => ({@@ -163,11 +237,15 @@ function PromptCard({const handleSelectDefaultLLM = (llmProfileId) => {setSelectedLlmProfileId(llmProfileId);- handleChange(llmProfileId, promptDetails?.prompt_id, "profile_manager");+ handleChange(+ llmProfileId,+ promptDetailsState?.prompt_id,+ "profile_manager"+ );};const handleTypeChange = (value) => {- handleChange(value, promptDetails?.prompt_id, "enforce_type", true);+ handleChange(value, promptDetailsState?.prompt_id, "enforce_type", true);};const handleDocOutputs = (docId, promptId, profileId, isLoading, output) => {@@ -229,7 +307,7 @@ function PromptCard({) => {if (!profileManagerId &&- !promptDetails?.profile_manager?.length &&+ !promptDetailsState?.profile_manager?.length &&!(!coverAllDoc && selectedLlmProfiles?.length > 0) &&!isSimplePromptStudio) {@@ -305,7 +383,7 @@ function PromptCard({for (const profile of selectedProfiles) {handleDocOutputs(docId,- promptDetails?.prompt_id,+ promptDetailsState?.prompt_id,profile?.profile_id,true,null@@ -321,23 +399,22 @@ function PromptCard({updatePromptOutputState(data, false);handleDocOutputs(docId,- promptDetails?.prompt_id,+ promptDetailsState?.prompt_id,profile?.profile_id,false,value);updateDocCoverage(- promptDetails?.prompt_id,+ promptDetailsState?.prompt_id,profile?.profile_id,docId);}).catch((err) => {- handleIsRunLoading(docId, profile?.profile_id, false);handleDocOutputs(docId,- promptDetails?.prompt_id,+ promptDetailsState?.prompt_id,profile?.profile_id,false,null@@ -347,6 +424,7 @@ function PromptCard({);}).finally(() => {+ handleIsRunLoading(docId, profile?.profile_id, false);setIsCoverageLoading(false);});runCoverageForAllDoc(coverAllDoc, profile.profile_id);@@ -355,7 +433,7 @@ function PromptCard({handleIsRunLoading(selectedDoc?.document_id, profileManagerId, true);handleDocOutputs(docId,- promptDetails?.prompt_id,+ promptDetailsState?.prompt_id,profileManagerId,true,null@@ -366,10 +444,14 @@ function PromptCard({const value = data[0]?.output;updatePromptOutputState(data, false);- updateDocCoverage(promptDetails?.prompt_id, profileManagerId, docId);+ updateDocCoverage(+ promptDetailsState?.prompt_id,+ profileManagerId,+ docId+ );handleDocOutputs(docId,- promptDetails?.prompt_id,+ promptDetailsState?.prompt_id,profileManagerId,false,value@@ -384,7 +466,7 @@ function PromptCard({);handleDocOutputs(docId,- promptDetails?.prompt_id,+ promptDetailsState?.prompt_id,profileManagerId,false,null@@ -444,7 +526,7 @@ function PromptCard({setIsCoverageLoading(true);handleDocOutputs(docId,- promptDetails?.prompt_id,+ promptDetailsState?.prompt_id,profileManagerId,true,null@@ -453,10 +535,14 @@ function PromptCard({.then((res) => {const data = res?.data || [];const outputValue = data[0]?.output;- updateDocCoverage(promptDetails?.prompt_id, profileManagerId, docId);+ updateDocCoverage(+ promptDetailsState?.prompt_id,+ profileManagerId,+ docId+ );handleDocOutputs(docId,- promptDetails?.prompt_id,+ promptDetailsState?.prompt_id,profileManagerId,false,outputValue@@ -465,7 +551,7 @@ function PromptCard({.catch((err) => {handleDocOutputs(docId,- promptDetails?.prompt_id,+ promptDetailsState?.prompt_id,profileManagerId,false,null@@ -515,7 +601,7 @@ function PromptCard({};const handleRunApiRequest = async (docId, profileManagerId) => {- const promptId = promptDetails?.prompt_id;+ const promptId = promptDetailsState?.prompt_id;const runId = generateUUID();const maxWaitTime = 30 * 1000; // 30 secondsconst pollingInterval = 5000; // 5 seconds@@ -603,7 +689,7 @@ function PromptCard({return (<><PromptCardItems- promptDetails={promptDetails}+ promptDetails={promptDetailsState}enforceTypeList={enforceTypeList}isRunLoading={isRunLoading}promptKey={promptKey}@@ -630,8 +716,8 @@ function PromptCard({<OutputForDocModalopen={openOutputForDoc}setOpen={setOpenOutputForDoc}- promptId={promptDetails?.prompt_id}- promptKey={promptDetails?.prompt_key}+ promptId={promptDetailsState?.prompt_id}+ promptKey={promptDetailsState?.prompt_key}profileManagerId={selectedLlmProfileId}docOutputs={docOutputs}/>@@ -641,12 +727,12 @@ function PromptCard({PromptCard.propTypes = {promptDetails: PropTypes.object.isRequired,- handleChange: PropTypes.func.isRequired,+ handleChangePromptCard: PropTypes.func.isRequired,handleDelete: PropTypes.func.isRequired,- updateStatus: PropTypes.object.isRequired,updatePlaceHolder: PropTypes.string,promptOutputs: PropTypes.object.isRequired,enforceTypeList: PropTypes.array.isRequired,+ setUpdatedPromptsCopy: PropTypes.func.isRequired,};export { PromptCard };diff --git a/frontend/src/components/custom-tools/prompt-card/constants.js b/frontend/src/components/custom-tools/prompt-card/constants.jsindex e88a6f482..951e737ee 100644--- a/frontend/src/components/custom-tools/prompt-card/constants.js+++ b/frontend/src/components/custom-tools/prompt-card/constants.js@@ -1,3 +1,13 @@const TABLE_ENFORCE_TYPE = "table";-export { TABLE_ENFORCE_TYPE };+const handleUpdateStatus = (isUpdate, promptId, value, setUpdateStatus) => {+ if (!isUpdate) {+ return;+ }+ setUpdateStatus({+ promptId: promptId,+ status: value,+ });+};++export { TABLE_ENFORCE_TYPE, handleUpdateStatus };diff --git a/frontend/src/helpers/GetStaticData.js b/frontend/src/helpers/GetStaticData.jsindex 2172eb61e..f44d0284c 100644--- a/frontend/src/helpers/GetStaticData.js+++ b/frontend/src/helpers/GetStaticData.js@@ -515,6 +515,14 @@ const formatNumberWithCommas = (number) => {: formattedIntegerPart;};+const isValidJsonKey = (key) => {+ // Check for Prompt-Key+ // Allowed case, contains alphanumeric characters and underscores,+ // and doesn't start with a number.+ const regex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;+ return regex.test(key);+};+export {CONNECTOR_TYPE_MAP,O_AUTH_PROVIDERS,@@ -560,4 +568,5 @@ export {getDocIdFromKey,displayURL,formatNumberWithCommas,+ isValidJsonKey,};