diff --git a/src/app/new-project/newproject.js b/src/app/new-project/newproject.js index 9efbe322..a0b685bb 100644 --- a/src/app/new-project/newproject.js +++ b/src/app/new-project/newproject.js @@ -134,6 +134,7 @@ const CreateProject = () => { const [tableData, setTableData] = useState([]); const [searchAnchor, setSearchAnchor] = useState(null); const [is_published, setIsPublished] = useState(false); + const [conceal, setconceal] = useState(false); const [selectedFilters, setsSelectedFilters] = useState({}); const [createannotationsAutomatically, setsCreateannotationsAutomatically] = useState("none"); @@ -393,6 +394,10 @@ const CreateProject = () => { const handleChangeIsPublished = (event) => { setIsPublished(event.target.checked); }; + const handleChangeconceal = (event) => { + setconceal(event.target.checked); + }; + useEffect(() => { setTotalDataitems(DataItems.count); @@ -571,6 +576,7 @@ const CreateProject = () => { is_published: is_published, password: passwordForProjects, metadata_json: questionsJSON, + conceal:conceal }; console.log(newProject); @@ -606,6 +612,7 @@ const CreateProject = () => { is_published: is_published, password: passwordForProjects, metadata_json: questionsJSON, + conceal:conceal }; console.log(newProject); @@ -1502,7 +1509,20 @@ const CreateProject = () => { sx={{ mt: 2, ml: 2, mb: 2 }} /> - ) : null} + ) :null + } + + + Hide Details : + + + + )} { "script", ]; - const formatResponse = (response,isLast) => { - if (ProjectDetails?.metadata_json?.blank_response==true && isLast) { + const formatResponse = (response) => { + if (!response) { return [ { type: "text", @@ -170,13 +170,11 @@ const AnnotatePage = () => { }, ]; } + response = String(response); const output = []; let count = 0; - -console.log(output,"kk"); - while (response) { response = response.trim(); let index = response.indexOf("```"); @@ -444,14 +442,13 @@ console.log(output,"kk"); clear_conversation: value === "delete", }; - if ( ["draft", "skipped", "delete", "labeled", "delete-pair"].includes(value) ) { if (!["draft", "skipped", "delete", "delete-pair"].includes(value)) { console.log("answered variable: "); console.log(chatHistory.length); - + if ( (ProjectDetails.project_type == "ModelInteractionEvaluation" || ProjectDetails.project_type == "MultipleInteractionEvaluation") && @@ -466,10 +463,12 @@ console.log(output,"kk"); setLoading(false); setShowNotes(false); return; - } - else if(ProjectDetails.project_type == "InstructionDrivenChat"&&chatHistory.length==0) { + } else if ( + ProjectDetails.project_type == "InstructionDrivenChat" && + chatHistory.length == 0 + ) { console.log(chatHistory); - + setSnackbarInfo({ open: true, message: "Please enter prompt", @@ -478,7 +477,6 @@ console.log(output,"kk"); setLoading(false); setShowNotes(false); return; - } } const TaskObj = new PatchAnnotationAPI(id, PatchAPIdata); @@ -512,13 +510,12 @@ console.log(output,"kk"); } value === "delete" ? (setSnackbarInfo({ - open: true, - message: "Chat history has been cleared successfully!", - variant: "success", - }), - await getAnnotationsTaskData(taskId), - await getTaskData(taskId) - ) + open: true, + message: "Chat history has been cleared successfully!", + variant: "success", + }), + await getAnnotationsTaskData(taskId), + await getTaskData(taskId)) : value === "delete-pair" ? setSnackbarInfo({ open: true, @@ -530,7 +527,7 @@ console.log(output,"kk"); message: resp?.message, variant: "success", }); - setLoading(false); + setLoading(false); } else { setAutoSave(true); setSnackbarInfo({ @@ -579,7 +576,7 @@ console.log(output,"kk"); }; }, [taskId]); const filterAnnotations = (annotations, user) => { - setLoading(true) + setLoading(true); let disableSkip = false; let disableUpdate = false; let disableDraft = false; @@ -675,7 +672,7 @@ console.log(output,"kk"); setDisableUpdateButton(disableUpdate); setdisableSkipButton(disableSkip); setFilterMessage(Message); - setLoading(false) + setLoading(false); return [ filteredAnnotations, @@ -724,9 +721,12 @@ console.log(output,"kk"); case "InstructionDrivenChat": componentToRender = ( 0 + ? `annotations-${annotations[0]?.id}` + : "annotations-default" + } + handleClick={handleAnnotationClick} chatHistory={chatHistory} setChatHistory={setChatHistory} formatResponse={formatResponse} @@ -745,9 +745,11 @@ console.log(output,"kk"); case "ModelInteractionEvaluation": componentToRender = ( 0 + ? `annotations-${annotations[0]?.id}` + : "annotations-default" + } setCurrentInteraction={setCurrentInteraction} currentInteraction={currentInteraction} interactions={interactions} @@ -766,9 +768,11 @@ console.log(output,"kk"); case "MultipleInteractionEvaluation": componentToRender = ( 0 + ? `annotations-${annotations[0]?.id}` + : "annotations-default" + } setCurrentInteraction={setCurrentInteraction} currentInteraction={currentInteraction} interactions={interactions} @@ -823,14 +827,12 @@ console.log(output,"kk"); <> {loading && }
- + {renderSnackBar()} */} - {ProjectDetails?.project_type=="InstructionDrivenChat"?( - clear the entire chat history - - } - > - - ): ( - Reset the entire chat history - - } - > -)} - )} + + )} + + )} {!disableUpdateButton && taskData?.annotation_users?.some( (users) => users === userData.id, @@ -1269,13 +1295,13 @@ console.log(output,"kk"); Annotation.lead_time, ) } + sx={{ + fontSize: { xs: "0.75rem", sm: "0.875rem", md: "1rem" }, + }} style={{ - minWidth: "150px", color: "black", borderRadius: "5px", border: "0px", - pt: 2, - pb: 2, backgroundColor: "#ee6633", }} > @@ -1291,10 +1317,10 @@ console.log(output,"kk"); )} - - {" "} - {componentToRender}{" "} - + + {" "} + {componentToRender}{" "} +
); diff --git a/src/app/ui/pages/chat/InstructionDrivenChatPage.js b/src/app/ui/pages/chat/InstructionDrivenChatPage.js index 1a55aa91..47b3afe5 100644 --- a/src/app/ui/pages/chat/InstructionDrivenChatPage.js +++ b/src/app/ui/pages/chat/InstructionDrivenChatPage.js @@ -129,21 +129,19 @@ const InstructionDrivenChatPage = ({ ); }; - -const orange = { - 200: "pink", - 400: "#EE6633", - 600: "#EE663366", -}; - -const grey = { - 50: "#F3F6F9", - 200: "#DAE2ED", - 300: "#C7D0DD", - 700: "#434D5B", - 900: "#1C2025", -}; + const orange = { + 200: "pink", + 400: "#EE6633", + 600: "#EE663366", + }; + const grey = { + 50: "#F3F6F9", + 200: "#DAE2ED", + 300: "#C7D0DD", + 700: "#434D5B", + 900: "#1C2025", + }; const copyToClipboard = async (code) => { try { @@ -161,40 +159,27 @@ const grey = { }); } }; - useEffect(() => { let modifiedChatHistory = []; if ( annotation && Array.isArray(annotation[0]?.result) && - [...annotation[0]?.result]?.length + annotation[0]?.result.length > 0 ) { - // if (ProjectDetails?.metadata_json?.blank_response == true) { - // modifiedChatHistory = annotation[0]?.result?.map((interaction) => ({ - // ...interaction, - // output: [], - // })); - // console.log(modifiedChatHistory); - - // setChatHistory(modifiedChatHistory); - // } - // else { - modifiedChatHistory = annotation[0]?.result?.map((interaction,index) => { - const isLastInteraction = index === annotation[0]?.result?.length - 1; - return { - ...interaction, - output: formatResponse(interaction.output,isLastInteraction), - }; - }); - // } - setChatHistory([...modifiedChatHistory]); + modifiedChatHistory = annotation[0]?.result.map((interaction, index) => { + return { + ...interaction, + output: formatResponse(interaction.output), + }; + }); + setChatHistory(modifiedChatHistory); } else { setChatHistory([]); } setAnnotationId(annotation[0]?.id); - if (annotation[0]?.result) setShowChatContainer(true); - }, []); + setShowChatContainer(!!annotation[0]?.result); + }, [annotation]); const cleanMetaInfo = (value) => value.replace(/\(for example:.*?\)/gi, "").trim(); @@ -248,7 +233,7 @@ const grey = { const handleButtonClick = async () => { console.log(inputValue); - + if (inputValue) { setLoading(true); const body = { @@ -292,15 +277,15 @@ const grey = { setChatHistory((prevChatHistory) => { data && data.result && setLoading(false); if (data && data.result) { - modifiedChatHistory = data.result.map((interaction,index) => { - const isLastInteraction = index === data?.result?.length - 1; - return { - ...interaction, - output: formatResponse(interaction.output,isLastInteraction), - }; - }); + modifiedChatHistory = data.result.map((interaction, index) => { + const isLastInteraction = index === data?.result?.length - 1; + return { + ...interaction, + output: formatResponse(interaction.output, isLastInteraction), + }; + }); } else { - setLoading(false) + setLoading(false); setSnackbarInfo({ open: true, message: data?.message, @@ -311,9 +296,7 @@ const grey = { ? [...modifiedChatHistory] : [...prevChatHistory]; }); - } - - else { + } else { setSnackbarInfo({ open: true, message: "Please provide a prompt", @@ -328,10 +311,8 @@ const grey = { console.log(chatHistory, ProjectDetails?.metadata_json); const handleOnchange = (prompt) => { - inputValue = prompt; - console.log(inputValue,chatHistory); - + console.log(inputValue, chatHistory); }; const [text, setText] = useState(""); const [targetLang, setTargetLang] = useState(""); @@ -342,7 +323,9 @@ const grey = { setIsMounted(true); if (typeof window !== "undefined") { - const storedGlobalTransliteration = localStorage.getItem("globalTransliteration"); + const storedGlobalTransliteration = localStorage.getItem( + "globalTransliteration", + ); const storedLanguage = localStorage.getItem("language"); if (storedGlobalTransliteration !== null) { @@ -352,7 +335,11 @@ const grey = { setTargetLang(storedLanguage); } - console.log(globalTransliteration, "lll", localStorage.getItem("globalTransliteration")); + console.log( + globalTransliteration, + "lll", + localStorage.getItem("globalTransliteration"), + ); } }, [chatHistory]); @@ -405,17 +392,14 @@ const grey = { transition: "border-color 0.2s, box-shadow 0.2s", }; - if (!isMounted) { return null; } const handleTextChange = (e, index, message, fieldType) => { - if(globalTransliteration){ + if (globalTransliteration) { var updatedValue = e; - - }else{ + } else { var updatedValue = e.target.value; - } const updatedChatHistory = [...chatHistory]; @@ -442,69 +426,77 @@ const grey = { direction="column" justifyContent="center" alignItems="center" - style={{ padding: '1.5rem',margin:"auto" }} + style={{ padding: "1.5rem", margin: "auto" }} > - + {ProjectDetails?.metadata_json?.editable_prompt ? ( globalTransliteration ? ( (