diff --git a/src/assets/images/icons/ExpandContent.svg b/src/assets/images/icons/ExpandContent.svg new file mode 100644 index 000000000..ae14d718b --- /dev/null +++ b/src/assets/images/icons/ExpandContent.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/UI/Form/Input/Input.module.css b/src/components/UI/Form/Input/Input.module.css index 13e87385a..52b86704e 100644 --- a/src/components/UI/Form/Input/Input.module.css +++ b/src/components/UI/Form/Input/Input.module.css @@ -28,10 +28,6 @@ font-weight: 400; } -.Multiline { - padding-bottom: 35px; -} - .Resend { color: #119656; font-weight: bold; diff --git a/src/components/UI/Form/Input/Input.tsx b/src/components/UI/Form/Input/Input.tsx index a8f0de056..41258eb81 100644 --- a/src/components/UI/Form/Input/Input.tsx +++ b/src/components/UI/Form/Input/Input.tsx @@ -113,7 +113,7 @@ export const Input = ({ textArea = false, disabled = false, inputLabel = null, . inputComponent={editor ? editor.inputComponent : undefined} inputProps={editor ? editor.inputProps : inputProp} type={fieldType} - classes={{ multiline: styles.Multiline, input: !textArea ? inputStyles : '' }} + classes={{ input: !textArea ? inputStyles : '' }} disabled={disabled} error={showError} multiline={textArea} diff --git a/src/containers/Assistants/Assistants.test.tsx b/src/containers/Assistants/Assistants.test.tsx index f50d0ccbb..11504eb8f 100644 --- a/src/containers/Assistants/Assistants.test.tsx +++ b/src/containers/Assistants/Assistants.test.tsx @@ -241,3 +241,27 @@ test('it should show errors for invalid value in temperature', async () => { expect(screen.getByText('Temperature value should be between 0-2')).toBeInTheDocument(); }); }); + +test('it opens the instruction dialog box', async () => { + render(assistantsComponent()); + + await waitFor(() => { + expect(screen.getByText('Assistants')).toBeInTheDocument(); + expect(screen.getByText('Assistant-1')).toBeInTheDocument(); + }); + + await waitFor(() => { + expect(screen.getByTestId('expandIcon')).toBeInTheDocument(); + }); + + fireEvent.click(screen.getByTestId('expandIcon')); + fireEvent.click(screen.getByTestId('cancel-button')); + fireEvent.click(screen.getByTestId('expandIcon')); + + fireEvent.change(screen.getByRole('textbox'), { target: { value: 'test instructions' } }); + fireEvent.click(screen.getByTestId('save-button')); + + await waitFor(() => { + expect(screen.getByText('test instructions')).toBeInTheDocument(); + }); +}); diff --git a/src/containers/Assistants/CreateAssistant/CreateAssistant.module.css b/src/containers/Assistants/CreateAssistant/CreateAssistant.module.css index f2f8f3480..61a5b5779 100644 --- a/src/containers/Assistants/CreateAssistant/CreateAssistant.module.css +++ b/src/containers/Assistants/CreateAssistant/CreateAssistant.module.css @@ -66,3 +66,56 @@ .DeleteIcon { margin-right: 0.5rem; } + +.Expand { + height: 100%; + display: flex; + align-items: end; + max-height: none; +} + +.ExpandButton { + cursor: pointer; +} + +.ExpandButton:hover { + background-color: #00000017; + border-radius: 0.5rem; +} + +.InstructionsBox { + height: 100%; + display: flex; + align-items: center; + justify-content: center; +} + +.Instructions { + background-color: #fff; + width: 50%; + padding: 1rem; + border-radius: 1rem; +} + +.Instructions h5 { + margin: 0; + font-size: 18px; + font-weight: 500; + line-height: 1.4; +} + +.Instructions { + display: flex; + flex-direction: column; + gap: 1rem; +} + +.Input { + width: 100%; +} + +.InstructionButtons { + width: 100%; + display: flex; + justify-content: end; +} diff --git a/src/containers/Assistants/CreateAssistant/CreateAssistant.tsx b/src/containers/Assistants/CreateAssistant/CreateAssistant.tsx index c8488e8a1..f96ed0ea9 100644 --- a/src/containers/Assistants/CreateAssistant/CreateAssistant.tsx +++ b/src/containers/Assistants/CreateAssistant/CreateAssistant.tsx @@ -1,5 +1,5 @@ import { useLazyQuery, useMutation, useQuery } from '@apollo/client'; -import { Typography } from '@mui/material'; +import { InputAdornment, Modal, OutlinedInput, Typography } from '@mui/material'; import { Field, FormikProvider, useFormik } from 'formik'; import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -19,6 +19,7 @@ import { DELETE_ASSISTANT, UPDATE_ASSISTANT } from 'graphql/mutations/Assistant' import CopyIcon from 'assets/images/CopyGreen.svg?react'; import DeleteIcon from 'assets/images/icons/Delete/White.svg?react'; +import ExpandIcon from 'assets/images/icons/ExpandContent.svg?react'; import { AssistantOptions } from '../AssistantOptions/AssistantOptions'; @@ -38,6 +39,7 @@ export const CreateAssistant = ({ currentId, setUpdateList, setCurrentId, update const [instructions, setInstructions] = useState(''); const [options, setOptions] = useState({ fileSearch: true, temperature: 1 }); const [showConfirmation, setShowConfirmation] = useState(false); + const [openInstructions, setOpenInstructions] = useState(false); const { t } = useTranslation(); const states = { @@ -109,6 +111,12 @@ export const CreateAssistant = ({ currentId, setUpdateList, setCurrentId, update }); }; + const expandIcon = ( + + setOpenInstructions(true)} className={styles.ExpandButton} /> + + ); + const formFields: any = [ { component: AutoComplete, @@ -145,6 +153,7 @@ export const CreateAssistant = ({ currentId, setUpdateList, setCurrentId, update textArea: true, helperText: t('Set the instructions according to your requirements.'), onChange: (value: any) => setInstructions(value), + endAdornment: expandIcon, }, { component: AssistantOptions, @@ -187,6 +196,7 @@ export const CreateAssistant = ({ currentId, setUpdateList, setCurrentId, update }; let dialog; + let instructionsDialog; if (showConfirmation) { dialog = ( ); } + if (openInstructions) { + instructionsDialog = ( + setOpenInstructions(false)}> +
+
+
Edit system instructions
+ setInstructions(event.target.value)} + value={instructions} + className={styles.Input} + multiline + rows={16} + /> +
+ + +
+
+
+
+ ); + } if (loading || listLoading) { return ; @@ -243,6 +280,7 @@ export const CreateAssistant = ({ currentId, setUpdateList, setCurrentId, update {dialog} + {instructionsDialog} );