diff --git a/langflow/frontend/src/App.tsx b/langflow/frontend/src/App.tsx index eaccbd36a..ec204466e 100644 --- a/langflow/frontend/src/App.tsx +++ b/langflow/frontend/src/App.tsx @@ -8,7 +8,6 @@ import SuccessAlert from "./alerts/success"; import ExtraSidebar from "./components/ExtraSidebarComponent"; import { alertContext } from "./contexts/alertContext"; import { locationContext } from "./contexts/locationContext"; -import Header from "./components/HeaderComponent"; import TabsManagerComponent from "./pages/FlowPage/components/tabsManagerComponent"; export default function App() { diff --git a/langflow/frontend/src/alerts/alertDropDown/index.tsx b/langflow/frontend/src/alerts/alertDropDown/index.tsx index 1d6d883f7..3c97bf034 100644 --- a/langflow/frontend/src/alerts/alertDropDown/index.tsx +++ b/langflow/frontend/src/alerts/alertDropDown/index.tsx @@ -25,13 +25,13 @@ export default function AlertDropdown({}: AlertDropdownType) { Notifications
- {renderLayer(
)} - -
- - - - ) -} \ No newline at end of file diff --git a/langflow/frontend/src/components/chatComponent/index.tsx b/langflow/frontend/src/components/chatComponent/index.tsx index ec4475112..613c5afad 100644 --- a/langflow/frontend/src/components/chatComponent/index.tsx +++ b/langflow/frontend/src/components/chatComponent/index.tsx @@ -1,13 +1,14 @@ import { Transition } from "@headlessui/react"; import { Bars3CenterLeftIcon, + LockClosedIcon, PaperAirplaneIcon, XMarkIcon, } from "@heroicons/react/24/outline"; import { useContext, useEffect, useRef, useState } from "react"; import { sendAll } from "../../controllers/NodesServices"; import { alertContext } from "../../contexts/alertContext"; -import { nodeColors } from "../../utils"; +import { classNames, nodeColors } from "../../utils"; import { TabsContext } from "../../contexts/tabsContext"; import { ChatType } from "../../types/chat"; @@ -16,6 +17,7 @@ const _ = require("lodash"); export default function Chat({ flow, reactFlowInstance }: ChatType) { const { updateFlow } = useContext(TabsContext); const [saveChat, setSaveChat] = useState(false); + const [lockChat, setLockChat] = useState(false); const [open, setOpen] = useState(true); const [chatValue, setChatValue] = useState(""); const [chatHistory, setChatHistory] = useState(flow.chat); @@ -69,15 +71,22 @@ export default function Chat({ flow, reactFlowInstance }: ChatType) { function sendMessage() { if (chatValue !== "") { if (validateNodes()) { + setLockChat(true); let message = chatValue; setChatValue(""); addChatHistory(message, true); console.log({ ...reactFlowInstance.toObject(), message, chatHistory }); - sendAll({ ...reactFlowInstance.toObject(), message, chatHistory }).then( - (r) => { + + sendAll({ ...reactFlowInstance.toObject(), message, chatHistory }) + .then((r) => { + console.log(r.data); addChatHistory(r.data.result, false); - } - ); + setLockChat(false); + }) + .catch((error) => { + setErrorData({ title: error.message ?? "unknow error" }); + setLockChat(false); + }); } else { setErrorData({ title: "Error sending message", @@ -106,9 +115,12 @@ export default function Chat({ flow, reactFlowInstance }: ChatType) { >
-
{ - setOpen(false); - }} className="flex justify-between cursor-pointer items-center px-5 py-2 border-b dark:border-b-gray-700"> +
{ + setOpen(false); + }} + className="flex justify-between cursor-pointer items-center px-5 py-2 border-b dark:border-b-gray-700" + >
{ - if (event.key === "Enter") { + if (event.key === "Enter" && !lockChat) { sendMessage(); } }} type="text" + disabled={lockChat} value={chatValue} onChange={(e) => { setChatValue(e.target.value); }} - className="form-input block w-full rounded-md border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white pr-10 sm:text-sm" + className={classNames( + lockChat ? "bg-gray-500" : "dark:bg-gray-700", + "form-input block w-full rounded-md border-gray-300 dark:border-gray-600 dark:text-white pr-10 sm:text-sm" + )} placeholder="Send a message..." />
-
@@ -180,7 +203,7 @@ export default function Chat({ flow, reactFlowInstance }: ChatType) { leaveTo="translate-y-96" >
-
+