diff --git a/frontend/src/components/custom-tools/document-manager/DocumentManager.css b/frontend/src/components/custom-tools/document-manager/DocumentManager.css index 788878b2a9..97a507856d 100644 --- a/frontend/src/components/custom-tools/document-manager/DocumentManager.css +++ b/frontend/src/components/custom-tools/document-manager/DocumentManager.css @@ -32,4 +32,9 @@ .rpv-default-layout__container { border: 0 !important; -} \ No newline at end of file +} + +.doc-main-title{ + color: darkgray; + font-weight: 600; +} diff --git a/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx b/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx index 7545890985..850e3dc91f 100644 --- a/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx +++ b/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx @@ -171,15 +171,20 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) { /> +
+ {selectedDoc ? ( + + {selectedDoc} + + ) : null} +
diff --git a/frontend/src/components/custom-tools/document-parser/DocumentParser.jsx b/frontend/src/components/custom-tools/document-parser/DocumentParser.jsx index 95f1fdcabb..2528f1c663 100644 --- a/frontend/src/components/custom-tools/document-parser/DocumentParser.jsx +++ b/frontend/src/components/custom-tools/document-parser/DocumentParser.jsx @@ -57,9 +57,27 @@ function DocumentParser({ value = event.target.value; } - if (!value && name === "prompt_key") { + if (name === "prompt_key") { // Return if the prompt or the prompt key is empty - return; + if (!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( @@ -149,7 +167,6 @@ function DocumentParser({ if (!isUpdate) { return; } - setUpdateStatus({ promptId: promptId, status: value, diff --git a/frontend/src/components/custom-tools/editable-text/EditableText.css b/frontend/src/components/custom-tools/editable-text/EditableText.css index 8cf908e74f..9052bb660f 100644 --- a/frontend/src/components/custom-tools/editable-text/EditableText.css +++ b/frontend/src/components/custom-tools/editable-text/EditableText.css @@ -14,4 +14,8 @@ .edit-text-display-hover:hover { border: 1px solid #bdbdbd; border-radius: 4px; -} \ No newline at end of file +} + +.input-header-text { + font-weight: bold; +} diff --git a/frontend/src/components/custom-tools/editable-text/EditableText.jsx b/frontend/src/components/custom-tools/editable-text/EditableText.jsx index 3e2882d0f0..466b40115e 100644 --- a/frontend/src/components/custom-tools/editable-text/EditableText.jsx +++ b/frontend/src/components/custom-tools/editable-text/EditableText.jsx @@ -5,7 +5,6 @@ import debounce from "lodash/debounce"; import "./EditableText.css"; import { useCustomToolStore } from "../../../store/custom-tool-store"; - function EditableText({ isEditing, setIsEditing, @@ -92,7 +91,7 @@ function EditableText({ return ( - + - + {isCoverageLoading && ( } @@ -654,6 +654,16 @@ function PromptCard({ Done )} + {updateStatus?.status === + promptStudioUpdateStatus.validationError && ( + } + color="error" + className="display-flex-align-center" + > + Invalid JSON Key + + )} )} diff --git a/frontend/src/helpers/GetStaticData.js b/frontend/src/helpers/GetStaticData.js index 6b2701d851..30337cae6a 100644 --- a/frontend/src/helpers/GetStaticData.js +++ b/frontend/src/helpers/GetStaticData.js @@ -230,6 +230,7 @@ const endpointType = { const promptStudioUpdateStatus = { isUpdating: "IS_UPDATING", done: "DONE", + validationError: "VALIDATION_ERROR", }; const getTimeForLogs = () => {