From 06e5e7dc4cf57dfb20026665602da3c6ea2b9e50 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Thu, 31 Aug 2023 11:48:36 -0300 Subject: [PATCH] Formatting issues --- src/backend/langflow/api/v1/base.py | 4 +- .../components/codeTabsComponent/index.tsx | 3 +- src/frontend/src/components/ui/skeleton.tsx | 6 +- src/frontend/src/contexts/alertContext.tsx | 2 +- src/frontend/src/modals/formModal/index.tsx | 185 +++++++++--------- .../src/modals/genericModal/index.tsx | 6 +- .../extraSidebarComponent/index.tsx | 7 +- src/frontend/src/pages/loginPage/index.tsx | 4 +- 8 files changed, 111 insertions(+), 106 deletions(-) diff --git a/src/backend/langflow/api/v1/base.py b/src/backend/langflow/api/v1/base.py index 39c8b0b9f..acffc1bc3 100644 --- a/src/backend/langflow/api/v1/base.py +++ b/src/backend/langflow/api/v1/base.py @@ -21,7 +21,7 @@ class FrontendNodeRequest(FrontendNode): class ValidatePromptRequest(BaseModel): name: str template: str - #optional for tweak call + # optional for tweak call frontend_node: Optional[FrontendNodeRequest] @@ -41,7 +41,7 @@ class CodeValidationResponse(BaseModel): class PromptValidationResponse(BaseModel): input_variables: list - #object return for tweak call + # object return for tweak call frontend_node: FrontendNodeRequest | object diff --git a/src/frontend/src/components/codeTabsComponent/index.tsx b/src/frontend/src/components/codeTabsComponent/index.tsx index 2fa6563a6..d807326f0 100644 --- a/src/frontend/src/components/codeTabsComponent/index.tsx +++ b/src/frontend/src/components/codeTabsComponent/index.tsx @@ -28,7 +28,6 @@ import { TabsList, TabsTrigger, } from "../../components/ui/tabs"; -import { alertContext } from "../../contexts/alertContext"; import { darkContext } from "../../contexts/darkContext"; import { typesContext } from "../../contexts/typesContext"; import { codeTabsPropsType } from "../../types/components"; @@ -57,7 +56,7 @@ export default function CodeTabsComponent({ }, [flow]); useEffect(() => { - if(tweaks){ + if (tweaks) { unselectAllNodes({ data, updateNodes: (nodes) => { diff --git a/src/frontend/src/components/ui/skeleton.tsx b/src/frontend/src/components/ui/skeleton.tsx index 6556585a4..f7a1573f2 100644 --- a/src/frontend/src/components/ui/skeleton.tsx +++ b/src/frontend/src/components/ui/skeleton.tsx @@ -1,4 +1,4 @@ -import { cn } from "../../utils/utils" +import { cn } from "../../utils/utils"; function Skeleton({ className, @@ -9,7 +9,7 @@ function Skeleton({ className={cn("animate-pulse rounded-md bg-border", className)} {...props} /> - ) + ); } -export { Skeleton } +export { Skeleton }; diff --git a/src/frontend/src/contexts/alertContext.tsx b/src/frontend/src/contexts/alertContext.tsx index ba46dddac..0b183a297 100644 --- a/src/frontend/src/contexts/alertContext.tsx +++ b/src/frontend/src/contexts/alertContext.tsx @@ -25,7 +25,7 @@ const initialValue: alertContextType = { notificationList: [], pushNotificationList: () => {}, clearNotificationList: () => {}, - removeFromNotificationList: () => {} + removeFromNotificationList: () => {}, }; export const alertContext = createContext(initialValue); diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx index 0a9bf7483..2982b8738 100644 --- a/src/frontend/src/modals/formModal/index.tsx +++ b/src/frontend/src/modals/formModal/index.tsx @@ -8,7 +8,7 @@ import { classNames } from "../../utils/utils"; import ChatInput from "./chatInput"; import ChatMessage from "./chatMessage"; -import _, { set } from "lodash"; +import _ from "lodash"; import AccordionComponent from "../../components/AccordionComponent"; import IconComponent from "../../components/genericIconComponent"; import ToggleShadComponent from "../../components/toggleShadComponent"; @@ -25,9 +25,9 @@ import { Textarea } from "../../components/ui/textarea"; import { CHAT_FORM_DIALOG_SUBTITLE } from "../../constants/constants"; import { AuthContext } from "../../contexts/authContext"; import { TabsContext } from "../../contexts/tabsContext"; +import { getBuildStatus } from "../../controllers/API"; import { TabsState } from "../../types/tabs"; import { validateNodes } from "../../utils/reactflowUtils"; -import { getBuildStatus } from "../../controllers/API"; export default function FormModal({ flow, @@ -156,19 +156,21 @@ export default function FormModal({ function handleOnClose(event: CloseEvent): void { if (isOpen.current) { - getBuildStatus(flow.id).then((response) => { - if (response.data.built) { - connectWS(); - } - else { + getBuildStatus(flow.id) + .then((response) => { + if (response.data.built) { + connectWS(); + } else { + setErrorData({ + title: "Please build the flow again before using the chat.", + }); + } + }) + .catch((error) => { setErrorData({ - title: "Please build the flow again before using the chat." - }) - } - }).catch((error) => { - setErrorData({title:error.data?.detail?error.data.detail:error.message}) - - }); + title: error.data?.detail ? error.data.detail : error.message, + }); + }); setErrorData({ title: event.reason }); setTimeout(() => { setLockChat(false); @@ -186,8 +188,9 @@ export default function FormModal({ const host = isDevelopment ? "localhost:7860" : window.location.host; const chatEndpoint = `/api/v1/chat/${chatId}`; - return `${isDevelopment ? "ws" : webSocketProtocol - }://${host}${chatEndpoint}?token=${encodeURIComponent(accessToken!)}`; + return `${ + isDevelopment ? "ws" : webSocketProtocol + }://${host}${chatEndpoint}?token=${encodeURIComponent(accessToken!)}`; } function handleWsMessage(data: any) { @@ -209,20 +212,20 @@ export default function FormModal({ newChatHistory.push( chatItem.files ? { - isSend: !chatItem.is_bot, - message: chatItem.message, - template: chatItem.template, - thought: chatItem.intermediate_steps, - files: chatItem.files, - chatKey: chatItem.chatKey, - } + isSend: !chatItem.is_bot, + message: chatItem.message, + template: chatItem.template, + thought: chatItem.intermediate_steps, + files: chatItem.files, + chatKey: chatItem.chatKey, + } : { - isSend: !chatItem.is_bot, - message: chatItem.message, - template: chatItem.template, - thought: chatItem.intermediate_steps, - chatKey: chatItem.chatKey, - } + isSend: !chatItem.is_bot, + message: chatItem.message, + template: chatItem.template, + thought: chatItem.intermediate_steps, + chatKey: chatItem.chatKey, + } ); } } @@ -442,73 +445,73 @@ export default function FormModal({ {tabsState[id.current]?.formKeysData?.input_keys ? Object.keys( - tabsState[id.current].formKeysData.input_keys! - ).map((key, index) => ( -
- - - {key} - + tabsState[id.current].formKeysData.input_keys! + ).map((key, index) => ( +
+ + + {key} + -
{ - event.stopPropagation(); - }} - > - - handleOnCheckedChange(value, key) - } - size="small" - disabled={tabsState[ - id.current - ].formKeysData.handle_keys!.some( - (t) => t === key - )} - /> +
{ + event.stopPropagation(); + }} + > + + handleOnCheckedChange(value, key) + } + size="small" + disabled={tabsState[ + id.current + ].formKeysData.handle_keys!.some( + (t) => t === key + )} + /> +
-
- } - key={index} - keyValue={key} - > -
- {tabsState[id.current].formKeysData.handle_keys!.some( - (t) => t === key - ) && ( + } + key={index} + keyValue={key} + > +
+ {tabsState[id.current].formKeysData.handle_keys!.some( + (t) => t === key + ) && (
Source: Component
)} - -
- -
- )) + +
+ + + )) : null} {tabsState[id.current].formKeysData.memory_keys!.map( (key, index) => ( @@ -522,7 +525,7 @@ export default function FormModal({
{ }} + setEnabled={() => {}} size="small" disabled={true} /> diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index e0875eba3..b29c5acf8 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -136,7 +136,11 @@ export default function GenericModal({ setSuccessData({ title: "Prompt is ready", }); - if(JSON.stringify(apiReturn.data?.frontend_node)!==JSON.stringify({})) setNodeClass!(apiReturn.data?.frontend_node); + if ( + JSON.stringify(apiReturn.data?.frontend_node) !== + JSON.stringify({}) + ) + setNodeClass!(apiReturn.data?.frontend_node); setModalOpen(closeModal); setValue(inputValue); } diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index c8dd34628..8ea74390a 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -21,8 +21,7 @@ export default function ExtraSidebar(): JSX.Element { const { data, templates } = useContext(typesContext); const { flows, tabId, uploadFlow, tabsState, saveFlow, isBuilt } = useContext(TabsContext); - const { setSuccessData, setErrorData } = - useContext(alertContext); + const { setSuccessData, setErrorData } = useContext(alertContext); const [dataFilter, setFilterData] = useState(data); const [search, setSearch] = useState(""); const isPending = tabsState[tabId]?.isPending; @@ -101,9 +100,7 @@ export default function ExtraSidebar(): JSX.Element {
{flow && flow.data && ( -
+
- +