diff --git a/src/frontend/src/modals/formModal/chatMessage/index.tsx b/src/frontend/src/modals/formModal/chatMessage/index.tsx
index 5078e251d..a819bc8d3 100644
--- a/src/frontend/src/modals/formModal/chatMessage/index.tsx
+++ b/src/frontend/src/modals/formModal/chatMessage/index.tsx
@@ -33,7 +33,7 @@ export default function ChatMessage({
className={classNames(
"w-full py-2 px-2 pl-4 flex",
chat.isSend
- ? "bg-input dark:bg-gray-900 "
+ ? " dark:bg-gray-900 "
: " dark:bg-gray-800"
)}
>
@@ -151,9 +151,9 @@ export default function ChatMessage({
) : (
-
+
"),
}}
diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx
index 347c61dae..f7baab69a 100644
--- a/src/frontend/src/modals/formModal/index.tsx
+++ b/src/frontend/src/modals/formModal/index.tsx
@@ -37,6 +37,7 @@ import { AccordionHeader } from "@radix-ui/react-accordion";
import { Textarea } from "../../components/ui/textarea";
import { Badge } from "../../components/ui/badge";
import { Separator } from "../../components/ui/separator";
+import { Switch } from "../../components/ui/switch";
export default function FormModal({
flow,
@@ -48,6 +49,7 @@ export default function FormModal({
flow: FlowType;
}) {
const [chatValue, setChatValue] = useState("");
+ const [keysValue, setKeysValue] = useState([]);
const [chatHistory, setChatHistory] = useState([]);
const { reactFlowInstance } = useContext(typesContext);
const { setErrorData, setNoticeData } = useContext(alertContext);
@@ -57,6 +59,7 @@ export default function FormModal({
const isOpen = useRef(open);
const messagesRef = useRef(null);
const id = useRef(flow.id);
+ const [chatKey, setChatKey] = useState(0);
useEffect(() => {
if (messagesRef.current) {
@@ -69,7 +72,7 @@ export default function FormModal({
}, [open]);
useEffect(() => {
id.current = flow.id;
- console.log(tabsState[flow.id]);
+ setKeysValue(Array(tabsState[flow.id].formKeysData.input_keys.length).fill(""));
}, [flow.id]);
var isStream = false;
@@ -309,9 +312,15 @@ export default function FormModal({
let nodeValidationErrors = validateNodes(reactFlowInstance);
if (nodeValidationErrors.length === 0) {
setLockChat(true);
- let message = chatValue;
+ // Message variable makes a object with the keys being the names from tabsState[flow.id].formKeysData.input_keys and the values being the keysValue of the correspondent index
+ let keys = tabsState[flow.id].formKeysData.input_keys; // array of keys
+ let values = keysValue.map((k, i) => i == chatKey ? chatValue : k); // array of values
+ let message = keys.reduce((object, key, index) => {
+ object[key] = values[index];
+ return object;
+ }, {});
setChatValue("");
- addChatHistory(message, true);
+ addChatHistory(message.toString(), true);
sendAll({
...reactFlowInstance.toObject(),
message,
@@ -341,6 +350,12 @@ export default function FormModal({
function setModalOpen(x: boolean) {
setOpen(x);
}
+
+ function handleOnCheckedChange(checked: boolean, index: number) {
+ if(checked === true){
+ setChatKey(index);
+ }
+ }
return (