From c960d294f6f449ed86375fb34d9575862b5be40e Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 9 Mar 2023 18:48:50 -0300 Subject: [PATCH 1/4] close alert on click --- langflow/frontend/src/alerts/error/index.tsx | 120 +++++++++--------- langflow/frontend/src/alerts/notice/index.tsx | 119 ++++++++--------- .../frontend/src/alerts/success/index.tsx | 93 +++++++------- 3 files changed, 168 insertions(+), 164 deletions(-) diff --git a/langflow/frontend/src/alerts/error/index.tsx b/langflow/frontend/src/alerts/error/index.tsx index 65a582be5..94e71a98e 100644 --- a/langflow/frontend/src/alerts/error/index.tsx +++ b/langflow/frontend/src/alerts/error/index.tsx @@ -1,64 +1,66 @@ import { Transition } from "@headlessui/react"; import { XCircleIcon, XMarkIcon } from "@heroicons/react/24/outline"; import { useEffect, useState } from "react"; -import { ErrorAlertType} from "../../types/alerts"; +import { ErrorAlertType } from "../../types/alerts"; -export default function ErrorAlert({ title, list = [], id, removeAlert }:ErrorAlertType) { - const [show, setShow] = useState(true); - useEffect(() => { - if(show){ - setTimeout(() => { - setShow(false); setTimeout(() => {removeAlert(id);}, 500); - }, 5000); - } - }, [id, removeAlert, show]); - return ( - -
-
-
-
-
-

{title}

- {list.length !== 0 - ? -
-
    - {list.map((item, index) => ( -
  • {item}
  • - ))} -
-
- : - <> - } - -
-
-
- -
-
-
-
-
- ); +export default function ErrorAlert({ + title, + list = [], + id, + removeAlert, +}: ErrorAlertType) { + const [show, setShow] = useState(true); + useEffect(() => { + if (show) { + setTimeout(() => { + setShow(false); + setTimeout(() => { + removeAlert(id); + }, 500); + }, 5000); + } + }, [id, removeAlert, show]); + return ( + +
{ + setShow(false); + setTimeout(() => { + removeAlert(id); + }, 500); + }} + className="rounded-md w-96 mt-6 shadow-xl bg-red-50 p-4 cursor-pointer" + > +
+
+
+
+

{title}

+ {list.length !== 0 ? ( +
+
    + {list.map((item, index) => ( +
  • {item}
  • + ))} +
+
+ ) : ( + <> + )} +
+
+
+
+ ); } diff --git a/langflow/frontend/src/alerts/notice/index.tsx b/langflow/frontend/src/alerts/notice/index.tsx index 86e55c8e4..3c5095339 100644 --- a/langflow/frontend/src/alerts/notice/index.tsx +++ b/langflow/frontend/src/alerts/notice/index.tsx @@ -4,63 +4,64 @@ import { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { NoticeAlertType } from "../../types/alerts"; -export default function NoticeAlert({ title, link = "", id, removeAlert }:NoticeAlertType) { - const [show, setShow] = useState(true); - useEffect(() => { - if(show){ - setTimeout(() => { - setShow(false); setTimeout(() => {removeAlert(id);}, 500); - }, 5000); - } - }, [id, removeAlert, show]); - return ( - -
-
-
-
-
-

{title}

-

- {link !== "" - ? - - Details - - : - <> - } -

-
-
-
- -
-
-
-
-
- ); +export default function NoticeAlert({ + title, + link = "", + id, + removeAlert, +}: NoticeAlertType) { + const [show, setShow] = useState(true); + useEffect(() => { + if (show) { + setTimeout(() => { + setShow(false); + setTimeout(() => { + removeAlert(id); + }, 500); + }, 5000); + } + }, [id, removeAlert, show]); + return ( + +
{ + setShow(false); + removeAlert(id); + }} + className="rounded-md w-96 mt-6 shadow-xl bg-blue-50 p-4" + > +
+
+
+
+

{title}

+

+ {link !== "" ? ( + + Details + + ) : ( + <> + )} +

+
+
+
+
+ ); } diff --git a/langflow/frontend/src/alerts/success/index.tsx b/langflow/frontend/src/alerts/success/index.tsx index 07659c19e..80b98b05d 100644 --- a/langflow/frontend/src/alerts/success/index.tsx +++ b/langflow/frontend/src/alerts/success/index.tsx @@ -3,50 +3,51 @@ import { CheckCircleIcon, XMarkIcon } from "@heroicons/react/24/outline"; import { useEffect, useState } from "react"; import { SuccessAlertType } from "../../types/alerts"; -export default function SuccessAlert({ title, id, removeAlert }:SuccessAlertType) { - const [show, setShow] = useState(true); - useEffect(() => { - if(show){ - setTimeout(() => { - setShow(false); setTimeout(() => {removeAlert(id);}, 500); - }, 5000); - } - }, [id, removeAlert, show]); - return ( - -
-
-
-
-
-

{title}

-
-
-
- -
-
-
-
-
- ); +export default function SuccessAlert({ + title, + id, + removeAlert, +}: SuccessAlertType) { + const [show, setShow] = useState(true); + useEffect(() => { + if (show) { + setTimeout(() => { + setShow(false); + setTimeout(() => { + removeAlert(id); + }, 500); + }, 5000); + } + }, [id, removeAlert, show]); + return ( + +
{ + setShow(false); + removeAlert(id); + }} + className="rounded-md w-96 mt-6 shadow-xl bg-green-50 p-4" + > +
+
+
+
+

{title}

+
+
+
+
+ ); } From 950f61d12da49d10aae61f4df5fff212bb5324a9 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 9 Mar 2023 19:01:43 -0300 Subject: [PATCH 2/4] alert after download flow --- langflow/frontend/src/contexts/tabsContext.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/langflow/frontend/src/contexts/tabsContext.tsx b/langflow/frontend/src/contexts/tabsContext.tsx index 7b3f60e06..ba148f2d9 100644 --- a/langflow/frontend/src/contexts/tabsContext.tsx +++ b/langflow/frontend/src/contexts/tabsContext.tsx @@ -1,7 +1,8 @@ -import { createContext, useEffect, useState, useRef, ReactNode } from "react"; +import { createContext, useEffect, useState, useRef, ReactNode, useContext } from "react"; import { FlowType } from "../types/flow"; import { TabsContextType } from "../types/tabs"; import { normalCaseToSnakeCase } from "../utils"; +import { alertContext } from "./alertContext"; const TabsContextInitialValue: TabsContextType = { tabIndex: 0, @@ -20,6 +21,7 @@ export const TabsContext = createContext( ); export function TabsProvider({ children }: { children: ReactNode }) { + const {setNoticeData} = useContext(alertContext) const [tabIndex, setTabIndex] = useState(0); const [flows, setFlows] = useState>([]); const [id, setId] = useState(0); @@ -66,6 +68,7 @@ export function TabsProvider({ children }: { children: ReactNode }) { // simulate a click on the link element to trigger the download link.click(); + setNoticeData({title:"Warning: Critical data, including API keys, in JSON file. Keep secure and do not share."}) } /** From d9fddaf16376816b2979f238c86ad8cdece68345 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 9 Mar 2023 20:17:00 -0300 Subject: [PATCH 3/4] typo fixed --- langflow/frontend/src/components/chatComponent/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langflow/frontend/src/components/chatComponent/index.tsx b/langflow/frontend/src/components/chatComponent/index.tsx index 4cf6dcd82..0ddd1764c 100644 --- a/langflow/frontend/src/components/chatComponent/index.tsx +++ b/langflow/frontend/src/components/chatComponent/index.tsx @@ -147,7 +147,7 @@ export default function Chat({ flow, reactFlowInstance }: ChatType) { clearChat(); }} > - clear + Clear
From 66e4b33b7c966d9a073699f5d37b6c007dd34ce9 Mon Sep 17 00:00:00 2001 From: Ibis Prevedello Date: Thu, 9 Mar 2023 21:23:42 -0300 Subject: [PATCH 4/4] refac: remove iosession as required --- .../backend/langflow_backend/interface/signature.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/langflow/backend/langflow_backend/interface/signature.py b/langflow/backend/langflow_backend/interface/signature.py index ad1ffbb79..c5d24d560 100644 --- a/langflow/backend/langflow_backend/interface/signature.py +++ b/langflow/backend/langflow_backend/interface/signature.py @@ -86,7 +86,7 @@ def get_tool_signature(name: str): type_dict = { "str": { "type": "str", - "required": False, + "required": True, "list": False, "show": True, "placeholder": "", @@ -111,9 +111,15 @@ def get_tool_signature(name: str): params = [] template = { - param: (type_dict[param] if param == "llm" else type_dict["str"]) + param: (type_dict[param].copy() if param == "llm" else type_dict["str"].copy()) for param in params - } # type: Dict[str, Any] + } + + # Remove required from aiosession + if "aiosession" in template.keys(): + template["aiosession"]["required"] = False + template["aiosession"]["show"] = False + template["_type"] = tool_type return {