From 259fd285c60454bd3591e486044a52010b009e57 Mon Sep 17 00:00:00 2001 From: Akansha Sakhre Date: Wed, 13 Nov 2024 10:48:47 +0530 Subject: [PATCH] fixed temperature slider --- src/components/UI/Heading/Heading.tsx | 17 ++--- .../AssistantOptions.module.css | 24 +++++-- .../AssistantOptions/AssistantOptions.tsx | 68 +++++++++++-------- .../CreateAssistant/CreateAssistant.tsx | 40 +++-------- src/i18n/en/en.json | 2 +- 5 files changed, 76 insertions(+), 75 deletions(-) diff --git a/src/components/UI/Heading/Heading.tsx b/src/components/UI/Heading/Heading.tsx index 631402922..296fabc5e 100644 --- a/src/components/UI/Heading/Heading.tsx +++ b/src/components/UI/Heading/Heading.tsx @@ -20,14 +20,7 @@ export interface HeadingProps { }; } -export const Heading = ({ - formTitle, - helpData, - showHeaderHelp = true, - backLink, - headerHelp, - button, -}: HeadingProps) => { +export const Heading = ({ formTitle, helpData, showHeaderHelp = true, backLink, headerHelp, button }: HeadingProps) => { const navigate = useNavigate(); const addIcon = ; @@ -39,12 +32,12 @@ export const Heading = ({
-
{formTitle}
+
+ {formTitle} +
{helpData ? : ''}
-
- {showHeaderHelp ? headerHelp || `Please enter below details.` : ''} -
+
{showHeaderHelp ? headerHelp || `Please enter below details.` : ''}
{button && button.show && ( diff --git a/src/containers/Assistants/AssistantOptions/AssistantOptions.module.css b/src/containers/Assistants/AssistantOptions/AssistantOptions.module.css index ca21b53f2..f26b427f2 100644 --- a/src/containers/Assistants/AssistantOptions/AssistantOptions.module.css +++ b/src/containers/Assistants/AssistantOptions/AssistantOptions.module.css @@ -21,15 +21,21 @@ .Temperature { display: flex; column-gap: 1rem; - align-items: center; + align-items: start; padding: 1rem 0; } +.SliderContainer { + width: 100%; + display: flex; + flex-direction: column; +} + .Slider { - width: 80%; display: flex; align-items: center; column-gap: 1rem; + justify-content: space-between; } .SliderDisplay { @@ -37,10 +43,21 @@ padding: 4px 12px; border: 0.5px solid #a4a4a4; border-radius: 4px; - width: 15%; text-align: center; } +.Error { + border-color: #fb5c5c; +} + +.ErrorText { + width: 100%; + color: #fb5c5c; + font-size: 0.8rem; + margin-top: 0.5rem; + text-align: right; +} + .SliderDisplay:focus { outline: none; } @@ -147,7 +164,6 @@ .VectorStore { display: flex; width: 100%; - padding: 1rem 2rem; background-color: #ebf8ee; font-size: 0.8rem; padding: 0.5rem 1rem; diff --git a/src/containers/Assistants/AssistantOptions/AssistantOptions.tsx b/src/containers/Assistants/AssistantOptions/AssistantOptions.tsx index 642a4aea1..4383c40ab 100644 --- a/src/containers/Assistants/AssistantOptions/AssistantOptions.tsx +++ b/src/containers/Assistants/AssistantOptions/AssistantOptions.tsx @@ -34,6 +34,7 @@ const temperatureInfo = export const AssistantOptions = ({ currentId, options, setOptions }: AssistantOptionsProps) => { const [showUploadDialog, setShowUploadDialog] = useState(false); const [files, setFiles] = useState([]); + const [error, setError] = useState(false); const { t } = useTranslation(); const [uploadFile, { loading: uploadingFile }] = useMutation(UPLOAD_FILE_TO_OPENAI); @@ -201,34 +202,45 @@ export const AssistantOptions = ({ currentId, options, setOptions }: AssistantOp }} /> - -
- { - setOptions({ - ...options, - temperature: value, - }); - }} - value={options.temperature} - step={0.01} - max={2} - /> - { - setOptions({ - ...options, - temperature: event.target.value, - }); - }} - className={styles.SliderDisplay} - /> +
+
+ { + setOptions({ + ...options, + temperature: value, + }); + }} + value={options.temperature} + step={0.01} + max={2} + min={0} + /> + { + const value = parseFloat(event.target.value); + if (value < 0 || value > 2) { + setError(true); + return; + } + setError(false); + setOptions({ + ...options, + temperature: value, + }); + }} + className={`${styles.SliderDisplay} ${error ? styles.Error : ''}`} + /> +
+ {error &&

Temperature value should be between 0-1

}
diff --git a/src/containers/Assistants/CreateAssistant/CreateAssistant.tsx b/src/containers/Assistants/CreateAssistant/CreateAssistant.tsx index 063f93e1f..456011f66 100644 --- a/src/containers/Assistants/CreateAssistant/CreateAssistant.tsx +++ b/src/containers/Assistants/CreateAssistant/CreateAssistant.tsx @@ -31,12 +31,7 @@ interface CreateAssistantProps { setUpdateList: any; } -export const CreateAssistant = ({ - currentId, - setUpdateList, - setCurrentId, - updateList, -}: CreateAssistantProps) => { +export const CreateAssistant = ({ currentId, setUpdateList, setCurrentId, updateList }: CreateAssistantProps) => { const [assistantId, setAssistantId] = useState(''); const [name, setName] = useState(''); const [model, setModel] = useState(null); @@ -75,9 +70,7 @@ export const CreateAssistant = ({ onCompleted: ({ assistant }) => { setAssistantId(assistant?.assistant?.assistantId); setName(assistant?.assistant?.name); - let modelValue = modelOptions?.find( - (item: any) => item.label === assistant?.assistant?.model - ); + let modelValue = modelOptions?.find((item: any) => item.label === assistant?.assistant?.model); setModel(modelValue); setInstructions(assistant?.assistant?.instructions || ''); setOptions({ @@ -90,12 +83,7 @@ export const CreateAssistant = ({ }, [currentId, modelsList]); const handleCreate = () => { - const { - instructions: instructionsValue, - model: modelValue, - name: nameValue, - options: optionsValue, - } = states; + const { instructions: instructionsValue, model: modelValue, name: nameValue, options: optionsValue } = states; const payload = { instructions: instructionsValue, @@ -138,9 +126,7 @@ export const CreateAssistant = ({ onChange: (value: any) => setName(value), helperText: (
- - {t('Give a recognizable name for your assistant')} - + {t('Give a recognizable name for your assistant')}
copyToClipboard(assistantId)}> {assistantId} @@ -191,10 +177,7 @@ export const CreateAssistant = ({ }, onCompleted: ({ deleteAssistant }) => { setShowConfirmation(false); - setNotification( - `Assistant ${deleteAssistant.assistant.name} deleted successfully`, - 'success' - ); + setNotification(`Assistant ${deleteAssistant.assistant.name} deleted successfully`, 'success'); setCurrentId(null); setUpdateList(!updateList); }, @@ -205,7 +188,7 @@ export const CreateAssistant = ({ if (showConfirmation) { dialog = ( -
{t("You won't be able to use this assistant.")}
+
+ {t('Please confirm that this assistant is not being used in any of the active flows.')} +
); } @@ -240,12 +225,7 @@ export const CreateAssistant = ({ ))}
-