diff --git a/src/common/HelpData.tsx b/src/common/HelpData.tsx index cbf425fe6..feed84a86 100644 --- a/src/common/HelpData.tsx +++ b/src/common/HelpData.tsx @@ -1,6 +1,6 @@ export interface HelpDataProps { heading: string; - link: string; + link?: string; } export const speedSendInfo: HelpDataProps = { diff --git a/src/components/UI/HelpIcon/HelpIcon.tsx b/src/components/UI/HelpIcon/HelpIcon.tsx index fb0901e6c..5648f5a1c 100644 --- a/src/components/UI/HelpIcon/HelpIcon.tsx +++ b/src/components/UI/HelpIcon/HelpIcon.tsx @@ -26,14 +26,16 @@ export const HelpIcon = ({
{helpData.heading} -
{ - window.open(helpData.link); - }} - > - Learn more -
+ {helpData.link && ( +
{ + window.open(helpData.link); + }} + > + Learn more +
+ )}
)} diff --git a/src/containers/AIToolkit/AssistantOptions/AssistantOptions.module.css b/src/containers/AIToolkit/AssistantOptions/AssistantOptions.module.css new file mode 100644 index 000000000..10bcd68bb --- /dev/null +++ b/src/containers/AIToolkit/AssistantOptions/AssistantOptions.module.css @@ -0,0 +1,40 @@ +.AssistantOptions { + margin: 1rem 0; + display: flex; + flex-direction: column; + row-gap: 1rem; +} + +.Label { + font-size: 1rem; + font-weight: 600; + color: #555; + display: flex; + align-items: center; + column-gap: 0.5rem; +} + +.Temperature { + display: flex; + column-gap: 1rem; + align-items: center; +} + +.Slider { + width: 80%; + display: flex; + align-items: center; + column-gap: 1rem; +} + +.SliderDisplay { + font-size: 15px; + padding: 4px 8px; + border: 0.5px solid #a4a4a4; + border-radius: 4px; + width: 15%; +} + +.SliderDisplay:focus { + outline: none; +} diff --git a/src/containers/AIToolkit/AssistantOptions/AssistantOptions.tsx b/src/containers/AIToolkit/AssistantOptions/AssistantOptions.tsx new file mode 100644 index 000000000..c850397e6 --- /dev/null +++ b/src/containers/AIToolkit/AssistantOptions/AssistantOptions.tsx @@ -0,0 +1,86 @@ +import { FormControlLabel, Slider, Switch, Typography } from '@mui/material'; +import { useState } from 'react'; +import styles from './AssistantOptions.module.css'; +import InfoIcon from 'assets/images/icons/Info.svg?react'; +import Tooltip from 'components/UI/Tooltip/Tooltip'; +import HelpIcon from 'components/UI/HelpIcon/HelpIcon'; + +interface AssistantOptionsProps { + form: any; + field: any; + fileSearch: boolean; +} + +const temperatureInfo = + 'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.'; + +const fileSearchInfo = + 'File search enables the assistant with knowledge from files that you or your users upload. Once a file is uploaded, the assistant automatically decides when to retrieve content based on user requests.'; + +export const AssistantOptions = ({ form, field, fileSearch }: AssistantOptionsProps) => { + const [checked, setChecked] = useState(false); + console.log(field.value); + + return ( +
+
+ + Tools + + { + form.setFieldValue('options', { + ...field.value, + fileSearch: event.target.checked, + }); + console.log(event.target.checked); + }} + /> + } + label="File Search" + /> + + +
+ +
+ + Temperature + + + +
+ { + form.setFieldValue('options', { + ...field.value, + temperature: value, + }); + }} + value={field.value.temperature} + step={0.01} + max={2} + /> + { + form.setFieldValue('options', { + ...field.value, + temperature: event.target.value, + }); + }} + className={styles.SliderDisplay} + /> +
+
+
+ ); +}; diff --git a/src/containers/AIToolkit/Assistants/Assistants.module.css b/src/containers/AIToolkit/Assistants/Assistants.module.css index 3fbac510c..2981f138a 100644 --- a/src/containers/AIToolkit/Assistants/Assistants.module.css +++ b/src/containers/AIToolkit/Assistants/Assistants.module.css @@ -5,7 +5,7 @@ .MainContainer { width: 100%; - height: 80%; + height: calc(100vh - 110px); display: flex; } @@ -15,19 +15,28 @@ border-right: 1px solid #00000029; padding: 2rem 4rem; background-color: #f8faf5; + position: relative; } .RightContainer { height: 100%; width: 50% !important; + overflow-y: scroll; +} + +.Search { + width: 50%; + position: absolute; + top: 0; + margin: 1rem 0; } .AssistantList { + margin-top: 2rem; height: 100%; display: flex; flex-direction: column; row-gap: 0.5rem; - margin: 1rem 0; overflow-y: scroll; } diff --git a/src/containers/AIToolkit/Assistants/Assistants.tsx b/src/containers/AIToolkit/Assistants/Assistants.tsx index 50fa1c1a3..1debb9785 100644 --- a/src/containers/AIToolkit/Assistants/Assistants.tsx +++ b/src/containers/AIToolkit/Assistants/Assistants.tsx @@ -14,6 +14,7 @@ export const Assistants = () => { inserted_at: '6:30 PM', }, ]; + return (
{ />
-
+
{}} diff --git a/src/containers/AIToolkit/CreateAssistant.tsx/CreateAssistant.tsx b/src/containers/AIToolkit/CreateAssistant.tsx/CreateAssistant.tsx index a79d7d556..6eb16790c 100644 --- a/src/containers/AIToolkit/CreateAssistant.tsx/CreateAssistant.tsx +++ b/src/containers/AIToolkit/CreateAssistant.tsx/CreateAssistant.tsx @@ -1,69 +1,91 @@ import { AutoComplete } from 'components/UI/Form/AutoComplete/AutoComplete'; import { Input } from 'components/UI/Form/Input/Input'; -import { FormLayout } from 'containers/Form/FormLayout'; import { CREATE_COLLECTION, DELETE_COLLECTION, UPDATE_COLLECTION, } from 'graphql/mutations/Collection'; import { GET_COLLECTION } from 'graphql/queries/Collection'; +import { AssistantOptions } from '../AssistantOptions/AssistantOptions'; +import { useState } from 'react'; +import { FormLayout } from '../FormLayout/FormLayout'; + +const queries = { + getItemQuery: GET_COLLECTION, + createItemQuery: CREATE_COLLECTION, + updateItemQuery: UPDATE_COLLECTION, + deleteItemQuery: DELETE_COLLECTION, +}; export const CreateAssistant = () => { - const queries = { - getItemQuery: GET_COLLECTION, - createItemQuery: CREATE_COLLECTION, - updateItemQuery: UPDATE_COLLECTION, - deleteItemQuery: DELETE_COLLECTION, - }; + const [name, setName] = useState(''); + const [model, setModel] = useState(); + const [prompt, setPrompt] = useState(''); + const [fileSearch, setFileSearch] = useState(true); + const [options, setOptions] = useState({ fileSearch: true, temperature: 1 }); + + const models = [ + { id: '1', name: 'gpt-4o ' }, + { id: '2', name: 'GPT-4' }, + { id: '3', name: 'GPT-5' }, + ]; + const formFields = [ { component: AutoComplete, name: 'model', - options: [], + options: models, optionLabel: 'name', label: 'Model', skipPayload: true, helperText: 'Choose the best model for your needs', + multiple: false, }, { component: Input, name: 'name', type: 'text', label: 'Name', - helpeText: 'Give a recognizable name for your assistant', + helperText: 'Give a recognizable name for your assistant', }, { component: Input, - name: 'description', + name: 'prompt', type: 'text', - label: 'Description', + label: 'Instructions', rows: 3, textArea: true, + helperText: 'Set the instructions according to your requirements.', + }, + { + component: AssistantOptions, + name: 'options', + fileSearch, + options, }, ]; - const states = {}; - const setStates = () => {}; - const setPayload = () => {}; + + const states = { + name, + model, + prompt, + fileSearch, + options, + }; + + const setStates = ({ name: nameValue, prompt: promptValue, model: modelValue }: any) => { + setName(nameValue); + setModel(modelValue); + setPrompt(promptValue); + }; + + const setPayload = (payload: any) => { + console.log(payload); + }; const FormSchema = {}; return ( - + ); }; diff --git a/src/containers/AIToolkit/FormLayout/FormLayout.module.css b/src/containers/AIToolkit/FormLayout/FormLayout.module.css new file mode 100644 index 000000000..fd5063108 --- /dev/null +++ b/src/containers/AIToolkit/FormLayout/FormLayout.module.css @@ -0,0 +1,34 @@ +.FormContainer { + padding: 3rem; + height: 100%; + position: relative; +} + +.Form { + height: 100%; + overflow-y: scroll; +} + +.Form::-webkit-scrollbar { + display: none; +} + +.Label { + color: #555; + font-size: 1rem; + font-weight: 500; + margin-bottom: 0.5rem; +} + +.FormFields { + display: flex; + flex-direction: column; + row-gap: 1rem; +} + +.Buttons { + background-color: #fff; + padding: 1rem 0; + position: absolute; + bottom: 0; +} diff --git a/src/containers/AIToolkit/FormLayout/FormLayout.tsx b/src/containers/AIToolkit/FormLayout/FormLayout.tsx new file mode 100644 index 000000000..b84dcff0b --- /dev/null +++ b/src/containers/AIToolkit/FormLayout/FormLayout.tsx @@ -0,0 +1,52 @@ +import { Field, Form, Formik, FormikProvider, useFormik } from 'formik'; +import styles from './FormLayout.module.css'; +import { Typography } from '@mui/material'; +import { Button } from 'components/UI/Form/Button/Button'; + +interface FormLayoutProps { + initialValues: any; + validationSchema: any; + formFieldItems: any; + skipSave?: boolean; +} + +export const FormLayout = ({ + initialValues, + validationSchema, + formFieldItems, + skipSave = false, +}: FormLayoutProps) => { + const formik = useFormik({ + initialValues, + validationSchema, + enableReinitialize: true, + onSubmit: (values, { setErrors }) => {}, + }); + + return ( + +
+
+
+ {formFieldItems.map((field: any) => ( +
+ + {field.label} + + + +
+ ))} +
+
+ {!skipSave && } + + +
+
+
+
+ ); +}; diff --git a/src/containers/Form/FormLayout.module.css b/src/containers/Form/FormLayout.module.css index 3703a146d..1d6a7b45a 100644 --- a/src/containers/Form/FormLayout.module.css +++ b/src/containers/Form/FormLayout.module.css @@ -26,7 +26,7 @@ } .ItemAdd { - height: 100vh; + height: 100%; background-color: #ffffff; }