diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx index 0992c4c50..134536ac3 100644 --- a/src/frontend/src/modals/formModal/index.tsx +++ b/src/frontend/src/modals/formModal/index.tsx @@ -30,6 +30,14 @@ import { import { Textarea } from "../../components/ui/textarea"; import { Badge } from "../../components/ui/badge"; import ToggleShadComponent from "../../components/toggleShadComponent"; +import Dropdown from "../../components/dropdownComponent"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "../../components/ui/dropdown-menu"; +import { Button } from "../../components/ui/button"; export default function FormModal({ flow, @@ -41,7 +49,13 @@ export default function FormModal({ flow: FlowType; }) { const { tabsState, setTabsState } = useContext(TabsContext); - const [chatValue, setChatValue] = useState(tabsState[flow.id].formKeysData.input_keys[Object.keys(tabsState[flow.id].formKeysData.input_keys).find((k) => !tabsState[flow.id].formKeysData.handle_keys.some((j) => j === k))]); + const [chatValue, setChatValue] = useState( + tabsState[flow.id].formKeysData.input_keys[ + Object.keys(tabsState[flow.id].formKeysData.input_keys).find( + (k) => !tabsState[flow.id].formKeysData.handle_keys.some((j) => j === k) + ) + ] + ); const [chatHistory, setChatHistory] = useState([]); const { reactFlowInstance } = useContext(typesContext); const { setErrorData, setNoticeData } = useContext(alertContext); @@ -50,7 +64,11 @@ export default function FormModal({ const isOpen = useRef(open); const messagesRef = useRef(null); const id = useRef(flow.id); - const [chatKey, setChatKey] = useState(Object.keys(tabsState[flow.id].formKeysData.input_keys).find((k) => !tabsState[flow.id].formKeysData.handle_keys.some((j) => j === k))); + const [chatKey, setChatKey] = useState( + Object.keys(tabsState[flow.id].formKeysData.input_keys).find( + (k) => !tabsState[flow.id].formKeysData.handle_keys.some((j) => j === k) + ) + ); useEffect(() => { if (messagesRef.current) { @@ -298,7 +316,7 @@ export default function FormModal({ }, [open]); function formatMessage(inputs: any): string { if (inputs) { - if(typeof inputs == "string") return inputs; + if (typeof inputs == "string") return inputs; // inputs is a object with the keys and values being input_keys and keysValue // so the formated message is a string with the keys and values separated by ": " let message = ""; @@ -382,53 +400,86 @@ export default function FormModal({
+
Input Variables
+ + Chat + +
- {Object.keys(tabsState[id.current].formKeysData.input_keys).map((i, k) => ( - - {i} - -
- {tabsState[id.current].formKeysData.handle_keys.some((t) => t === i) ?
Handle
: -
- - - handleOnCheckedChange(value, i) - } - size="small" - disabled={false} - /> -
- } - + {Object.keys(tabsState[id.current].formKeysData.input_keys).map( + (i, k) => ( +
+ + +
+ + {i} + + +
+ + handleOnCheckedChange(value, i) + } + size="small" + disabled={false} + />
- -
- ))} + + +
+ {tabsState[id.current].formKeysData.handle_keys.some( + (t) => t === i + ) ? ( +
+ Handle +
+ ) : ( + <> + )} + +
+
+ + +
+ ) + )} {tabsState[id.current].formKeysData.memory_keys.map((i, k) => (
-
{i}
+
+ + {i} + +
Used as Memory Key
@@ -437,14 +488,19 @@ export default function FormModal({
-
- -
+
+ +
{setChatValue(value); setTabsState((old) => { - let newTabsState = _.cloneDeep(old); - newTabsState[id.current].formKeysData.input_keys[chatKey] = chatValue; - return newTabsState; - });}} + setChatValue={(value) => { + setChatValue(value); + setTabsState((old) => { + let newTabsState = _.cloneDeep(old); + newTabsState[id.current].formKeysData.input_keys[ + chatKey + ] = chatValue; + return newTabsState; + }); + }} inputRef={ref} />