From f1c174e8db068c4f58c954159d8d508774eb7b6b Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 17:08:48 -0300 Subject: [PATCH 01/20] delete dead code --- .../components/parameterComponent/index.tsx | 2 +- src/frontend/src/utils.ts | 109 ------------------ .../src/{util => utils}/reactflowUtils.ts | 2 +- 3 files changed, 2 insertions(+), 111 deletions(-) rename src/frontend/src/{util => utils}/reactflowUtils.ts (95%) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index a3e3e6357..f45a6a562 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -17,7 +17,6 @@ import { PopUpContext } from "../../../../contexts/popUpContext"; import { TabsContext } from "../../../../contexts/tabsContext"; import { typesContext } from "../../../../contexts/typesContext"; import { ParameterComponentType } from "../../../../types/components"; -import { cleanEdges } from "../../../../util/reactflowUtils"; import { classNames, getRandomKeyByssmm, @@ -27,6 +26,7 @@ import { nodeIconsLucide, nodeNames, } from "../../../../utils"; +import { cleanEdges } from "../../../../utils/reactflowUtils"; export default function ParameterComponent({ left, diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 5ae191c67..9663c95ef 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -62,29 +62,6 @@ export enum TypeModal { PROMPT = 2, } -export const textColors = { - white: "text-white", - red: "text-red-700", - orange: "text-orange-700", - amber: "text-amber-700", - yellow: "text-yellow-700", - lime: "text-lime-700", - green: "text-green-700", - emerald: "text-emerald-700", - teal: "text-teal-700", - cyan: "text-cyan-700", - sky: "text-sky-700", - blue: "text-blue-700", - indigo: "text-indigo-700", - violet: "text-violet-700", - purple: "text-purple-700", - fuchsia: "text-fuchsia-700", - pink: "text-pink-700", - rose: "text-rose-700", - black: "text-black-700", - gray: "text-gray-700", -}; - export const borderLColors = { white: "border-l-white", red: "border-l-red-500", @@ -343,92 +320,6 @@ export const gradients = [ "bg-gradient-to-br from-lime-600 via-yellow-300 to-red-600", ]; -export const bgColors = { - white: "bg-white", - red: "bg-red-100", - orange: "bg-orange-100", - amber: "bg-amber-100", - yellow: "bg-yellow-100", - lime: "bg-lime-100", - green: "bg-green-100", - emerald: "bg-emerald-100", - teal: "bg-teal-100", - cyan: "bg-cyan-100", - sky: "bg-sky-100", - blue: "bg-blue-100", - indigo: "bg-indigo-100", - violet: "bg-violet-100", - purple: "bg-purple-100", - fuchsia: "bg-fuchsia-100", - pink: "bg-pink-100", - rose: "bg-rose-100", - black: "bg-black-100", - gray: "bg-gray-100", -}; - -export const bgColorsHover = { - white: "hover:bg-white", - black: "hover:bg-black-50", - gray: "hover:bg-gray-50", - red: "hover:bg-red-50", - orange: "hover:bg-orange-50", - amber: "hover:bg-amber-50", - yellow: "hover:bg-yellow-50", - lime: "hover:bg-lime-50", - green: "hover:bg-green-50", - emerald: "hover:bg-emerald-50", - teal: "hover:bg-teal-50", - cyan: "hover:bg-cyan-50", - sky: "hover:bg-sky-50", - blue: "hover:bg-blue-50", - indigo: "hover:bg-indigo-50", - violet: "hover:bg-violet-50", - purple: "hover:bg-purple-50", - fuchsia: "hover:bg-fuchsia-50", - pink: "hover:bg-pink-50", - rose: "hover:bg-rose-50", -}; - -export const textColorsHex = { - red: "rgb(185 28 28)", - orange: "rgb(194 65 12)", - amber: "rgb(180 83 9)", - yellow: "rgb(161 98 7)", - lime: "rgb(77 124 15)", - green: "rgb(21 128 61)", - emerald: "rgb(4 120 87)", - teal: "rgb(15 118 110)", - cyan: "rgb(14 116 144)", - sky: "rgb(3 105 161)", - blue: "rgb(29 78 216)", - indigo: "rgb(67 56 202)", - violet: "rgb(109 40 217)", - purple: "rgb(126 34 206)", - fuchsia: "rgb(162 28 175)", - pink: "rgb(190 24 93)", - rose: "rgb(190 18 60)", -}; - -export const bgColorsHex = { - red: "rgb(254 226 226)", - orange: "rgb(255 237 213)", - amber: "rgb(254 243 199)", - yellow: "rgb(254 249 195)", - lime: "rgb(236 252 203)", - green: "rgb(220 252 231)", - emerald: "rgb(209 250 229)", - teal: "rgb(204 251 241)", - cyan: "rgb(207 250 254)", - sky: "rgb(224 242 254)", - blue: "rgb(219 234 254)", - indigo: "rgb(224 231 255)", - violet: "rgb(237 233 254)", - purple: "rgb(243 232 255)", - fuchsia: "rgb(250 232 255)", - pink: "rgb(252 231 243)", - rose: "rgb(255 228 230)", -}; - export const taskTypeMap: { [key: string]: string } = { MULTICLASS_CLASSIFICATION: "Multiclass Classification", }; diff --git a/src/frontend/src/util/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts similarity index 95% rename from src/frontend/src/util/reactflowUtils.ts rename to src/frontend/src/utils/reactflowUtils.ts index da04cc75c..2f9c58343 100644 --- a/src/frontend/src/util/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -1,5 +1,5 @@ import _ from "lodash"; -import { cleanEdgesType } from "./../types/utils/reactflowUtils"; +import { cleanEdgesType } from "../types/utils/reactflowUtils"; export function cleanEdges({ flow: { edges, nodes }, From dfd7ecf6672de40de52bddf818b349d59dcf087d Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 17:12:24 -0300 Subject: [PATCH 02/20] remove dead code --- src/frontend/src/utils.ts | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 9663c95ef..eea82ca70 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -62,29 +62,6 @@ export enum TypeModal { PROMPT = 2, } -export const borderLColors = { - white: "border-l-white", - red: "border-l-red-500", - orange: "border-l-orange-500", - amber: "border-l-amber-500", - yellow: "border-l-yellow-500", - lime: "border-l-lime-500", - green: "border-l-green-500", - emerald: "border-l-emerald-500", - teal: "border-l-teal-500", - cyan: "border-l-cyan-500", - sky: "border-l-sky-500", - blue: "border-l-blue-500", - indigo: "border-l-indigo-500", - violet: "border-l-violet-500", - purple: "border-l-purple-500", - fuchsia: "border-l-fuchsia-500", - pink: "border-l-pink-500", - rose: "border-l-rose-500", - black: "border-l-black-500", - gray: "border-l-gray-500", -}; - export const nodeColors: { [char: string]: string } = { prompts: "#4367BF", llms: "#6344BE", From 11e4bd3aa20d8784f1c76e2171d55ba550802a4e Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 17:29:48 -0300 Subject: [PATCH 03/20] nodeColors passed tl styleUtils --- .../components/parameterComponent/index.tsx | 2 +- .../src/CustomNodes/GenericNode/index.tsx | 8 +-- .../src/components/cardComponent/index.tsx | 2 +- src/frontend/src/modals/NodeModal/index.tsx | 2 +- .../modals/formModal/chatMessage/index.tsx | 2 +- .../src/modals/genericModal/index.tsx | 22 ++++--- .../extraSidebarComponent/index.tsx | 8 +-- src/frontend/src/utils.ts | 57 ------------------- src/frontend/src/utils/styleUtils.ts | 56 ++++++++++++++++++ 9 files changed, 79 insertions(+), 80 deletions(-) create mode 100644 src/frontend/src/utils/styleUtils.ts diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index f45a6a562..8fabc07e2 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -22,11 +22,11 @@ import { getRandomKeyByssmm, groupByFamily, isValidConnection, - nodeColors, nodeIconsLucide, nodeNames, } from "../../../../utils"; import { cleanEdges } from "../../../../utils/reactflowUtils"; +import { nodeColors } from "../../../../utils/styleUtils"; export default function ParameterComponent({ left, diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index ee62461bd..18b42c670 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -10,12 +10,8 @@ import { typesContext } from "../../contexts/typesContext"; import NodeModal from "../../modals/NodeModal"; import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent"; import { NodeDataType } from "../../types/flow"; -import { - classNames, - nodeColors, - nodeIconsLucide, - toTitleCase, -} from "../../utils"; +import { classNames, nodeIconsLucide, toTitleCase } from "../../utils"; +import { nodeColors } from "../../utils/styleUtils"; import ParameterComponent from "./components/parameterComponent"; export default function GenericNode({ diff --git a/src/frontend/src/components/cardComponent/index.tsx b/src/frontend/src/components/cardComponent/index.tsx index 285aa91b7..5f4498f97 100644 --- a/src/frontend/src/components/cardComponent/index.tsx +++ b/src/frontend/src/components/cardComponent/index.tsx @@ -2,7 +2,7 @@ import { Trash2 } from "lucide-react"; import { useContext } from "react"; import { TabsContext } from "../../contexts/tabsContext"; import { FlowType } from "../../types/flow"; -import { gradients } from "../../utils"; +import { gradients } from "../../utils/styleUtils"; import { Card, CardDescription, diff --git a/src/frontend/src/modals/NodeModal/index.tsx b/src/frontend/src/modals/NodeModal/index.tsx index c61af4ff4..95c0e5512 100644 --- a/src/frontend/src/modals/NodeModal/index.tsx +++ b/src/frontend/src/modals/NodeModal/index.tsx @@ -7,10 +7,10 @@ import { NodeDataType } from "../../types/flow"; import { classNames, limitScrollFieldsModal, - nodeColors, nodeIconsLucide, toTitleCase, } from "../../utils"; +import { nodeColors } from "../../utils/styleUtils"; import ModalField from "./components/ModalField"; export default function NodeModal({ data }: { data: NodeDataType }) { diff --git a/src/frontend/src/modals/formModal/chatMessage/index.tsx b/src/frontend/src/modals/formModal/chatMessage/index.tsx index 9affce87e..953aed530 100644 --- a/src/frontend/src/modals/formModal/chatMessage/index.tsx +++ b/src/frontend/src/modals/formModal/chatMessage/index.tsx @@ -81,7 +81,7 @@ export default function ChatMessage({ remarkPlugins={[remarkGfm, remarkMath]} rehypePlugins={[rehypeMathjax]} className="markdown prose inline-block break-words text-primary - dark:prose-invert sm:max-w-[30vw] lg:max-w-[40vw] sm:w-[30vw] lg:w-[40vw]" + dark:prose-invert sm:w-[30vw] sm:max-w-[30vw] lg:w-[40vw] lg:max-w-[40vw]" components={{ code: ({ node, diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index b76a71c4b..fa26af1be 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -6,7 +6,11 @@ import { Badge } from "../../components/ui/badge"; import { Button } from "../../components/ui/button"; import { DialogTitle } from "../../components/ui/dialog"; import { Textarea } from "../../components/ui/textarea"; -import { MAX_WORDS_HIGHLIGHT, PROMPT_DIALOG_SUBTITLE, TEXT_DIALOG_SUBTITLE } from "../../constants"; +import { + MAX_WORDS_HIGHLIGHT, + PROMPT_DIALOG_SUBTITLE, + TEXT_DIALOG_SUBTITLE, +} from "../../constants"; import { alertContext } from "../../contexts/alertContext"; import { darkContext } from "../../contexts/darkContext"; import { PopUpContext } from "../../contexts/popUpContext"; @@ -120,15 +124,16 @@ export default function GenericModal({ ); }; - function getClassByNumberLength(){ + function getClassByNumberLength() { let sumOfCaracteres: number = 0; - wordsHighlight.forEach(element => { - sumOfCaracteres = sumOfCaracteres + element.replace(/[{}]/g, "").length + wordsHighlight.forEach((element) => { + sumOfCaracteres = sumOfCaracteres + element.replace(/[{}]/g, "").length; }); - return sumOfCaracteres > MAX_WORDS_HIGHLIGHT ? "code-highlight" : "code-nohighlight" + return sumOfCaracteres > MAX_WORDS_HIGHLIGHT + ? "code-highlight" + : "code-nohighlight"; } - function validatePrompt(closeModal: boolean) { postValidatePrompt(field_name, inputValue, nodeClass) .then((apiReturn) => { @@ -234,7 +239,10 @@ export default function GenericModal({
{type === TypeModal.PROMPT && (
-
+
diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index f7223d67a..7317341e2 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -9,12 +9,8 @@ import { typesContext } from "../../../../contexts/typesContext"; import ApiModal from "../../../../modals/ApiModal"; import ExportModal from "../../../../modals/exportModal"; import { APIClassType, APIObjectType } from "../../../../types/api"; -import { - classNames, - nodeColors, - nodeIconsLucide, - nodeNames, -} from "../../../../utils"; +import { classNames, nodeIconsLucide, nodeNames } from "../../../../utils"; +import { nodeColors } from "../../../../utils/styleUtils"; import DisclosureComponent from "../DisclosureComponent"; export default function ExtraSidebar() { diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index eea82ca70..c5db58157 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -62,29 +62,6 @@ export enum TypeModal { PROMPT = 2, } -export const nodeColors: { [char: string]: string } = { - prompts: "#4367BF", - llms: "#6344BE", - chains: "#FE7500", - agents: "#903BBE", - tools: "#FF3434", - memories: "#F5B85A", - advanced: "#000000", - chat: "#198BF6", - thought: "#272541", - embeddings: "#42BAA7", - documentloaders: "#7AAE42", - vectorstores: "#AA8742", - textsplitters: "#B47CB5", - toolkits: "#DB2C2C", - wrappers: "#E6277A", - utilities: "#31A3CC", - output_parsers: "#E6A627", - str: "#049524", - retrievers: "#e6b25a", - unknown: "#9CA3AF", -}; - export const nodeNames: { [char: string]: string } = { prompts: "Prompts", llms: "LLMs", @@ -263,40 +240,6 @@ export const nodeIconsLucide: { >, }; -export const gradients = [ - "bg-gradient-to-br from-gray-800 via-rose-700 to-violet-900", - "bg-gradient-to-br from-green-200 via-green-300 to-blue-500", - "bg-gradient-to-br from-yellow-200 via-yellow-400 to-yellow-700", - "bg-gradient-to-br from-green-200 via-green-400 to-purple-700", - "bg-gradient-to-br from-blue-100 via-blue-300 to-blue-500", - "bg-gradient-to-br from-purple-400 to-yellow-400", - "bg-gradient-to-br from-red-800 via-yellow-600 to-yellow-500", - "bg-gradient-to-br from-blue-300 via-green-200 to-yellow-300", - "bg-gradient-to-br from-blue-700 via-blue-800 to-gray-900", - "bg-gradient-to-br from-green-300 to-purple-400", - "bg-gradient-to-br from-yellow-200 via-pink-200 to-pink-400", - "bg-gradient-to-br from-green-500 to-green-700", - "bg-gradient-to-br from-rose-400 via-fuchsia-500 to-indigo-500", - "bg-gradient-to-br from-sky-400 to-blue-500", - "bg-gradient-to-br from-green-200 via-green-400 to-green-500", - "bg-gradient-to-br from-red-400 via-gray-300 to-blue-500", - "bg-gradient-to-br from-gray-900 to-gray-600 bg-gradient-to-r", - "bg-gradient-to-br from-rose-500 via-red-400 to-red-500", - "bg-gradient-to-br from-fuchsia-600 to-pink-600", - "bg-gradient-to-br from-emerald-500 to-lime-600", - "bg-gradient-to-br from-rose-500 to-indigo-700", - "bg-gradient-to-br bg-gradient-to-tr from-violet-500 to-orange-300", - "bg-gradient-to-br from-gray-900 via-purple-900 to-violet-600", - "bg-gradient-to-br from-yellow-200 via-red-500 to-fuchsia-500", - "bg-gradient-to-br from-sky-400 to-indigo-900", - "bg-gradient-to-br from-amber-200 via-violet-600 to-sky-900", - "bg-gradient-to-br from-amber-700 via-orange-300 to-rose-800", - "bg-gradient-to-br from-gray-300 via-fuchsia-600 to-orange-600", - "bg-gradient-to-br from-fuchsia-500 via-red-600 to-orange-400", - "bg-gradient-to-br from-sky-400 via-rose-400 to-lime-400", - "bg-gradient-to-br from-lime-600 via-yellow-300 to-red-600", -]; - export const taskTypeMap: { [key: string]: string } = { MULTICLASS_CLASSIFICATION: "Multiclass Classification", }; diff --git a/src/frontend/src/utils/styleUtils.ts b/src/frontend/src/utils/styleUtils.ts new file mode 100644 index 000000000..ac42d2072 --- /dev/null +++ b/src/frontend/src/utils/styleUtils.ts @@ -0,0 +1,56 @@ +export const gradients = [ + "bg-gradient-to-br from-gray-800 via-rose-700 to-violet-900", + "bg-gradient-to-br from-green-200 via-green-300 to-blue-500", + "bg-gradient-to-br from-yellow-200 via-yellow-400 to-yellow-700", + "bg-gradient-to-br from-green-200 via-green-400 to-purple-700", + "bg-gradient-to-br from-blue-100 via-blue-300 to-blue-500", + "bg-gradient-to-br from-purple-400 to-yellow-400", + "bg-gradient-to-br from-red-800 via-yellow-600 to-yellow-500", + "bg-gradient-to-br from-blue-300 via-green-200 to-yellow-300", + "bg-gradient-to-br from-blue-700 via-blue-800 to-gray-900", + "bg-gradient-to-br from-green-300 to-purple-400", + "bg-gradient-to-br from-yellow-200 via-pink-200 to-pink-400", + "bg-gradient-to-br from-green-500 to-green-700", + "bg-gradient-to-br from-rose-400 via-fuchsia-500 to-indigo-500", + "bg-gradient-to-br from-sky-400 to-blue-500", + "bg-gradient-to-br from-green-200 via-green-400 to-green-500", + "bg-gradient-to-br from-red-400 via-gray-300 to-blue-500", + "bg-gradient-to-br from-gray-900 to-gray-600 bg-gradient-to-r", + "bg-gradient-to-br from-rose-500 via-red-400 to-red-500", + "bg-gradient-to-br from-fuchsia-600 to-pink-600", + "bg-gradient-to-br from-emerald-500 to-lime-600", + "bg-gradient-to-br from-rose-500 to-indigo-700", + "bg-gradient-to-br bg-gradient-to-tr from-violet-500 to-orange-300", + "bg-gradient-to-br from-gray-900 via-purple-900 to-violet-600", + "bg-gradient-to-br from-yellow-200 via-red-500 to-fuchsia-500", + "bg-gradient-to-br from-sky-400 to-indigo-900", + "bg-gradient-to-br from-amber-200 via-violet-600 to-sky-900", + "bg-gradient-to-br from-amber-700 via-orange-300 to-rose-800", + "bg-gradient-to-br from-gray-300 via-fuchsia-600 to-orange-600", + "bg-gradient-to-br from-fuchsia-500 via-red-600 to-orange-400", + "bg-gradient-to-br from-sky-400 via-rose-400 to-lime-400", + "bg-gradient-to-br from-lime-600 via-yellow-300 to-red-600", +]; + +export const nodeColors: { [char: string]: string } = { + prompts: "#4367BF", + llms: "#6344BE", + chains: "#FE7500", + agents: "#903BBE", + tools: "#FF3434", + memories: "#F5B85A", + advanced: "#000000", + chat: "#198BF6", + thought: "#272541", + embeddings: "#42BAA7", + documentloaders: "#7AAE42", + vectorstores: "#AA8742", + textsplitters: "#B47CB5", + toolkits: "#DB2C2C", + wrappers: "#E6277A", + utilities: "#31A3CC", + output_parsers: "#E6A627", + str: "#049524", + retrievers: "#e6b25a", + unknown: "#9CA3AF", +}; From d88be5dd99c02d52b65f10bc75b095027c929253 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 17:31:28 -0300 Subject: [PATCH 04/20] remove dead code --- src/frontend/src/utils.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index c5db58157..5fd11f3a6 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -240,10 +240,6 @@ export const nodeIconsLucide: { >, }; -export const taskTypeMap: { [key: string]: string } = { - MULTICLASS_CLASSIFICATION: "Multiclass Classification", -}; - const charWidths: { [char: string]: number } = { " ": 0.2, "!": 0.2, From 1c769e54f919752f9196adfd5bcca6843466f4bd Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 17:36:46 -0300 Subject: [PATCH 05/20] update node names --- .../components/parameterComponent/index.tsx | 3 +-- .../extraSidebarComponent/index.tsx | 4 ++-- src/frontend/src/utils.ts | 21 ------------------- src/frontend/src/utils/styleUtils.ts | 21 +++++++++++++++++++ 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 8fabc07e2..91d41800a 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -23,10 +23,9 @@ import { groupByFamily, isValidConnection, nodeIconsLucide, - nodeNames, } from "../../../../utils"; import { cleanEdges } from "../../../../utils/reactflowUtils"; -import { nodeColors } from "../../../../utils/styleUtils"; +import { nodeColors, nodeNames } from "../../../../utils/styleUtils"; export default function ParameterComponent({ left, diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index 7317341e2..68a3f7b94 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -9,8 +9,8 @@ import { typesContext } from "../../../../contexts/typesContext"; import ApiModal from "../../../../modals/ApiModal"; import ExportModal from "../../../../modals/exportModal"; import { APIClassType, APIObjectType } from "../../../../types/api"; -import { classNames, nodeIconsLucide, nodeNames } from "../../../../utils"; -import { nodeColors } from "../../../../utils/styleUtils"; +import { classNames, nodeIconsLucide } from "../../../../utils"; +import { nodeColors, nodeNames } from "../../../../utils/styleUtils"; import DisclosureComponent from "../DisclosureComponent"; export default function ExtraSidebar() { diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 5fd11f3a6..7b06e47d5 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -62,27 +62,6 @@ export enum TypeModal { PROMPT = 2, } -export const nodeNames: { [char: string]: string } = { - prompts: "Prompts", - llms: "LLMs", - chains: "Chains", - agents: "Agents", - tools: "Tools", - memories: "Memories", - advanced: "Advanced", - chat: "Chat", - embeddings: "Embeddings", - documentloaders: "Loaders", - vectorstores: "Vector Stores", - toolkits: "Toolkits", - wrappers: "Wrappers", - textsplitters: "Text Splitters", - retrievers: "Retrievers", - utilities: "Utilities", - output_parsers: "Output Parsers", - unknown: "Unknown", -}; - export const nodeIconsLucide: { [char: string]: React.ForwardRefExoticComponent< ComponentType> diff --git a/src/frontend/src/utils/styleUtils.ts b/src/frontend/src/utils/styleUtils.ts index ac42d2072..2e96d48cd 100644 --- a/src/frontend/src/utils/styleUtils.ts +++ b/src/frontend/src/utils/styleUtils.ts @@ -54,3 +54,24 @@ export const nodeColors: { [char: string]: string } = { retrievers: "#e6b25a", unknown: "#9CA3AF", }; + +export const nodeNames: { [char: string]: string } = { + prompts: "Prompts", + llms: "LLMs", + chains: "Chains", + agents: "Agents", + tools: "Tools", + memories: "Memories", + advanced: "Advanced", + chat: "Chat", + embeddings: "Embeddings", + documentloaders: "Loaders", + vectorstores: "Vector Stores", + toolkits: "Toolkits", + wrappers: "Wrappers", + textsplitters: "Text Splitters", + retrievers: "Retrievers", + utilities: "Utilities", + output_parsers: "Output Parsers", + unknown: "Unknown", +}; From 2aabf54b9d4cd84ab73bbc12d7f0e045155891cb Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 17:55:21 -0300 Subject: [PATCH 06/20] remove some constants from utils to constants --- .../src/components/promptComponent/index.tsx | 11 +++++------ .../src/components/textAreaComponent/index.tsx | 2 +- src/frontend/src/{constants.tsx => constants.ts} | 14 ++++++++++++++ src/frontend/src/modals/NodeModal/index.tsx | 8 ++------ src/frontend/src/modals/genericModal/index.tsx | 2 +- src/frontend/src/utils.ts | 7 ------- 6 files changed, 23 insertions(+), 21 deletions(-) rename src/frontend/src/{constants.tsx => constants.ts} (97%) diff --git a/src/frontend/src/components/promptComponent/index.tsx b/src/frontend/src/components/promptComponent/index.tsx index 22384c299..6e547d683 100644 --- a/src/frontend/src/components/promptComponent/index.tsx +++ b/src/frontend/src/components/promptComponent/index.tsx @@ -1,12 +1,11 @@ -import { useContext, useEffect, useState } from "react"; -import { PopUpContext } from "../../contexts/popUpContext"; -import GenericModal from "../../modals/genericModal"; -import { TextAreaComponentType } from "../../types/components"; -import { TypeModal } from "../../utils"; - import { ExternalLink } from "lucide-react"; +import { useContext, useEffect, useState } from "react"; +import { TypeModal } from "../../constants"; +import { PopUpContext } from "../../contexts/popUpContext"; import { typesContext } from "../../contexts/typesContext"; import { postValidatePrompt } from "../../controllers/API"; +import GenericModal from "../../modals/genericModal"; +import { TextAreaComponentType } from "../../types/components"; export default function PromptAreaComponent({ field_name, diff --git a/src/frontend/src/components/textAreaComponent/index.tsx b/src/frontend/src/components/textAreaComponent/index.tsx index 8083b4eb7..873bab1e0 100644 --- a/src/frontend/src/components/textAreaComponent/index.tsx +++ b/src/frontend/src/components/textAreaComponent/index.tsx @@ -2,9 +2,9 @@ import { useContext, useEffect, useState } from "react"; import { PopUpContext } from "../../contexts/popUpContext"; import GenericModal from "../../modals/genericModal"; import { TextAreaComponentType } from "../../types/components"; -import { TypeModal } from "../../utils"; import { ExternalLink } from "lucide-react"; +import { TypeModal } from "../../constants"; import { TabsContext } from "../../contexts/tabsContext"; export default function TextAreaComponent({ diff --git a/src/frontend/src/constants.tsx b/src/frontend/src/constants.ts similarity index 97% rename from src/frontend/src/constants.tsx rename to src/frontend/src/constants.ts index 9c167c271..d7c8f01ae 100644 --- a/src/frontend/src/constants.tsx +++ b/src/frontend/src/constants.ts @@ -5,6 +5,14 @@ import { FlowType } from "./types/flow"; import { TabsState } from "./types/tabs"; import { buildInputs, buildTweaks } from "./utils"; +/** + * enum for the different types of nodes + * @enum + */ +export enum TypeModal { + TEXT = 1, + PROMPT = 2, +} /** * Number maximum of components to scroll on tooltips * @constant @@ -17,6 +25,12 @@ export const MAX_LENGTH_TO_SCROLL_TOOLTIP = 200; */ export const MAX_WORDS_HIGHLIGHT = 79; +/** + * Limit of items before show scroll on fields modal + * @constant + */ +export const limitScrollFieldsModal = 10; + /** * The base text for subtitle of Export Dialog (Toolbar) * @constant diff --git a/src/frontend/src/modals/NodeModal/index.tsx b/src/frontend/src/modals/NodeModal/index.tsx index 95c0e5512..c84858c6d 100644 --- a/src/frontend/src/modals/NodeModal/index.tsx +++ b/src/frontend/src/modals/NodeModal/index.tsx @@ -1,15 +1,11 @@ import { Dialog, Transition } from "@headlessui/react"; import { X } from "lucide-react"; import { Fragment, useContext, useRef, useState } from "react"; +import { limitScrollFieldsModal } from "../../constants"; import { PopUpContext } from "../../contexts/popUpContext"; import { typesContext } from "../../contexts/typesContext"; import { NodeDataType } from "../../types/flow"; -import { - classNames, - limitScrollFieldsModal, - nodeIconsLucide, - toTitleCase, -} from "../../utils"; +import { classNames, nodeIconsLucide, toTitleCase } from "../../utils"; import { nodeColors } from "../../utils/styleUtils"; import ModalField from "./components/ModalField"; diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index fa26af1be..9de3b1b73 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -10,6 +10,7 @@ import { MAX_WORDS_HIGHLIGHT, PROMPT_DIALOG_SUBTITLE, TEXT_DIALOG_SUBTITLE, + TypeModal, } from "../../constants"; import { alertContext } from "../../contexts/alertContext"; import { darkContext } from "../../contexts/darkContext"; @@ -18,7 +19,6 @@ import { postValidatePrompt } from "../../controllers/API"; import { APIClassType } from "../../types/api"; import { INVALID_CHARACTERS, - TypeModal, classNames, getRandomKeyByssmm, regexHighlight, diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 7b06e47d5..e327877b7 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -55,13 +55,6 @@ export function classNames(...classes: Array) { return classes.filter(Boolean).join(" "); } -export const limitScrollFieldsModal = 10; - -export enum TypeModal { - TEXT = 1, - PROMPT = 2, -} - export const nodeIconsLucide: { [char: string]: React.ForwardRefExoticComponent< ComponentType> From 6cde1f5f3724b5f20622176b0ab1bbdce692a0a7 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 18:00:49 -0300 Subject: [PATCH 07/20] remove dead code --- src/frontend/src/utils.ts | 76 --------------------------------------- 1 file changed, 76 deletions(-) diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index e327877b7..53efccd74 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -212,86 +212,10 @@ export const nodeIconsLucide: { >, }; -const charWidths: { [char: string]: number } = { - " ": 0.2, - "!": 0.2, - '"': 0.3, - "#": 0.5, - $: 0.5, - "%": 0.5, - "&": 0.5, - "(": 0.2, - ")": 0.2, - "*": 0.5, - "+": 0.5, - ",": 0.2, - "-": 0.2, - ".": 0.1, - "/": 0.5, - ":": 0.2, - ";": 0.2, - "<": 0.5, - "=": 0.5, - ">": 0.5, - "?": 0.2, - "@": 0.5, - "[": 0.2, - "\\": 0.5, - "]": 0.2, - "^": 0.5, - _: 0.2, - "`": 0.5, - "{": 0.2, - "|": 0.2, - "}": 0.2, - "~": 0.5, -}; - -for (let i = 65; i <= 90; i++) { - charWidths[String.fromCharCode(i)] = 0.6; -} -for (let i = 97; i <= 122; i++) { - charWidths[String.fromCharCode(i)] = 0.5; -} - -export function measureTextWidth(text: string, fontSize: number) { - let wordWidth = 0; - for (let j = 0; j < text.length; j++) { - let char = text[j]; - let charWidth = charWidths[char] || 0.5; - wordWidth += charWidth * fontSize; - } - return wordWidth; -} - export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } -export function measureTextHeight( - text: string, - width: number, - fontSize: number -) { - const charHeight = fontSize; - const lineHeight = charHeight * 1.5; - const words = text.split(" "); - let lineWidth = 0; - let totalHeight = 0; - for (let i = 0; i < words.length; i++) { - let word = words[i]; - let wordWidth = measureTextWidth(word, fontSize); - if (lineWidth + wordWidth + charWidths[" "] * fontSize <= width) { - lineWidth += wordWidth + charWidths[" "] * fontSize; - } else { - totalHeight += lineHeight; - lineWidth = wordWidth; - } - } - totalHeight += lineHeight; - return totalHeight; -} - export function toCamelCase(str: string) { return str .split(" ") From 3dc89726a3d4971d2ecd0b88807ede74e65f8d06 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 18:17:27 -0300 Subject: [PATCH 08/20] icons in styleUtils --- .../components/parameterComponent/index.tsx | 7 +- .../src/CustomNodes/GenericNode/index.tsx | 4 +- src/frontend/src/modals/NodeModal/index.tsx | 4 +- .../extraSidebarComponent/index.tsx | 8 +- src/frontend/src/utils.ts | 209 +----------------- src/frontend/src/utils/styleUtils.ts | 209 ++++++++++++++++++ 6 files changed, 225 insertions(+), 216 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 91d41800a..d63a91ea2 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -22,10 +22,13 @@ import { getRandomKeyByssmm, groupByFamily, isValidConnection, - nodeIconsLucide, } from "../../../../utils"; import { cleanEdges } from "../../../../utils/reactflowUtils"; -import { nodeColors, nodeNames } from "../../../../utils/styleUtils"; +import { + nodeColors, + nodeIconsLucide, + nodeNames, +} from "../../../../utils/styleUtils"; export default function ParameterComponent({ left, diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 18b42c670..f53c0bb97 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -10,8 +10,8 @@ import { typesContext } from "../../contexts/typesContext"; import NodeModal from "../../modals/NodeModal"; import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent"; import { NodeDataType } from "../../types/flow"; -import { classNames, nodeIconsLucide, toTitleCase } from "../../utils"; -import { nodeColors } from "../../utils/styleUtils"; +import { classNames, toTitleCase } from "../../utils"; +import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils"; import ParameterComponent from "./components/parameterComponent"; export default function GenericNode({ diff --git a/src/frontend/src/modals/NodeModal/index.tsx b/src/frontend/src/modals/NodeModal/index.tsx index c84858c6d..2446f1148 100644 --- a/src/frontend/src/modals/NodeModal/index.tsx +++ b/src/frontend/src/modals/NodeModal/index.tsx @@ -5,8 +5,8 @@ import { limitScrollFieldsModal } from "../../constants"; import { PopUpContext } from "../../contexts/popUpContext"; import { typesContext } from "../../contexts/typesContext"; import { NodeDataType } from "../../types/flow"; -import { classNames, nodeIconsLucide, toTitleCase } from "../../utils"; -import { nodeColors } from "../../utils/styleUtils"; +import { classNames, toTitleCase } from "../../utils"; +import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils"; import ModalField from "./components/ModalField"; export default function NodeModal({ data }: { data: NodeDataType }) { diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index 68a3f7b94..883777f29 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -9,8 +9,12 @@ import { typesContext } from "../../../../contexts/typesContext"; import ApiModal from "../../../../modals/ApiModal"; import ExportModal from "../../../../modals/exportModal"; import { APIClassType, APIObjectType } from "../../../../types/api"; -import { classNames, nodeIconsLucide } from "../../../../utils"; -import { nodeColors, nodeNames } from "../../../../utils/styleUtils"; +import { classNames } from "../../../../utils"; +import { + nodeColors, + nodeIconsLucide, + nodeNames, +} from "../../../../utils/styleUtils"; import DisclosureComponent from "../DisclosureComponent"; export default function ExtraSidebar() { diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 53efccd74..de42e7819 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -1,52 +1,8 @@ import clsx, { ClassValue } from "clsx"; import _ from "lodash"; -import { - Compass, - Cpu, - FileSearch, - Fingerprint, - Gift, - Hammer, - HelpCircle, - Laptop2, - Layers, - Lightbulb, - Link, - MessageCircle, - Paperclip, - Rocket, - Scissors, - TerminalSquare, - Wand2, - Wrench, -} from "lucide-react"; -import { ComponentType, SVGProps } from "react"; -import { Connection, Edge, Node, ReactFlowInstance } from "reactflow"; +import { Connection, ReactFlowInstance } from "reactflow"; import { twMerge } from "tailwind-merge"; import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./flow_constants"; -import { AirbyteIcon } from "./icons/Airbyte"; -import { AnthropicIcon } from "./icons/Anthropic"; -import { BingIcon } from "./icons/Bing"; -import { ChromaIcon } from "./icons/ChromaIcon"; -import { CohereIcon } from "./icons/Cohere"; -import { EvernoteIcon } from "./icons/Evernote"; -import { FBIcon } from "./icons/FacebookMessenger"; -import { GitBookIcon } from "./icons/GitBook"; -import { GoogleIcon } from "./icons/Google"; -import { HuggingFaceIcon } from "./icons/HuggingFace"; -import { IFixIcon } from "./icons/IFixIt"; -import { MetaIcon } from "./icons/Meta"; -import { MidjourneyIcon } from "./icons/Midjorney"; -import { MongoDBIcon } from "./icons/MongoDB"; -import { NotionIcon } from "./icons/Notion"; -import { OpenAiIcon } from "./icons/OpenAi"; -import { PineconeIcon } from "./icons/Pinecone"; -import { QDrantIcon } from "./icons/QDrant"; -import { SearxIcon } from "./icons/Searx"; -import { SlackIcon } from "./icons/Slack"; -import { VertexAIIcon } from "./icons/VertexAI"; -import { HackerNewsIcon } from "./icons/hackerNews"; -import { SupabaseIcon } from "./icons/supabase"; import { APITemplateType } from "./types/api"; import { IVarHighlightType } from "./types/components"; import { FlowType, NodeType } from "./types/flow"; @@ -55,163 +11,6 @@ export function classNames(...classes: Array) { return classes.filter(Boolean).join(" "); } -export const nodeIconsLucide: { - [char: string]: React.ForwardRefExoticComponent< - ComponentType> - >; -} = { - Chroma: ChromaIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - AirbyteJSONLoader: AirbyteIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - Anthropic: AnthropicIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - ChatAnthropic: AnthropicIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - BingSearchAPIWrapper: BingIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - BingSearchRun: BingIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - Cohere: CohereIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - CohereEmbeddings: CohereIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - EverNoteLoader: EvernoteIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - FacebookChatLoader: FBIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - GitbookLoader: GitBookIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - GoogleSearchAPIWrapper: GoogleIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - GoogleSearchResults: GoogleIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - GoogleSearchRun: GoogleIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - HNLoader: HackerNewsIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - HuggingFaceHub: HuggingFaceIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - HuggingFaceEmbeddings: HuggingFaceIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - IFixitLoader: IFixIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - Meta: MetaIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - Midjorney: MidjourneyIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - MongoDBAtlasVectorSearch: MongoDBIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - NotionDirectoryLoader: NotionIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - ChatOpenAI: OpenAiIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - OpenAI: OpenAiIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - OpenAIEmbeddings: OpenAiIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - Pinecone: PineconeIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - Qdrant: QDrantIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - Searx: SearxIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - SlackDirectoryLoader: SlackIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - SupabaseVectorStore: SupabaseIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - VertexAI: VertexAIIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - ChatVertexAI: VertexAIIcon as React.ForwardRefExoticComponent< - ComponentType> - >, - agents: Rocket as React.ForwardRefExoticComponent< - ComponentType> - >, - chains: Link as React.ForwardRefExoticComponent< - ComponentType> - >, - memories: Cpu as React.ForwardRefExoticComponent< - ComponentType> - >, - llms: Lightbulb as React.ForwardRefExoticComponent< - ComponentType> - >, - prompts: TerminalSquare as React.ForwardRefExoticComponent< - ComponentType> - >, - tools: Wrench as React.ForwardRefExoticComponent< - ComponentType> - >, - advanced: Laptop2 as React.ForwardRefExoticComponent< - ComponentType> - >, - chat: MessageCircle as React.ForwardRefExoticComponent< - ComponentType> - >, - embeddings: Fingerprint as React.ForwardRefExoticComponent< - ComponentType> - >, - documentloaders: Paperclip as React.ForwardRefExoticComponent< - ComponentType> - >, - vectorstores: Layers as React.ForwardRefExoticComponent< - ComponentType> - >, - toolkits: Hammer as React.ForwardRefExoticComponent< - ComponentType> - >, - textsplitters: Scissors as React.ForwardRefExoticComponent< - ComponentType> - >, - wrappers: Gift as React.ForwardRefExoticComponent< - ComponentType> - >, - utilities: Wand2 as React.ForwardRefExoticComponent< - ComponentType> - >, - output_parsers: Compass as React.ForwardRefExoticComponent< - ComponentType> - >, - retrievers: FileSearch as React.ForwardRefExoticComponent< - ComponentType> - >, - unknown: HelpCircle as React.ForwardRefExoticComponent< - ComponentType> - >, -}; - export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } @@ -275,12 +74,6 @@ export function roundNumber(x: number, decimals: number) { return Math.round(x * Math.pow(10, decimals)) / Math.pow(10, decimals); } -export function getConnectedNodes(edge: Edge, nodes: Array): Array { - const sourceId = edge.source; - const targetId = edge.target; - return nodes.filter((node) => node.id === targetId || node.id === sourceId); -} - export function isValidConnection( { source, target, sourceHandle, targetHandle }: Connection, reactFlowInstance: ReactFlowInstance diff --git a/src/frontend/src/utils/styleUtils.ts b/src/frontend/src/utils/styleUtils.ts index 2e96d48cd..47aa1c5ce 100644 --- a/src/frontend/src/utils/styleUtils.ts +++ b/src/frontend/src/utils/styleUtils.ts @@ -1,3 +1,49 @@ +import { + Compass, + Cpu, + FileSearch, + Fingerprint, + Gift, + Hammer, + HelpCircle, + Laptop2, + Layers, + Lightbulb, + Link, + MessageCircle, + Paperclip, + Rocket, + Scissors, + SlackIcon, + TerminalSquare, + Wand2, + Wrench, +} from "lucide-react"; +import { ComponentType, SVGProps } from "react"; +import { Edge, Node } from "reactflow"; +import { AirbyteIcon } from "../icons/Airbyte"; +import { AnthropicIcon } from "../icons/Anthropic"; +import { BingIcon } from "../icons/Bing"; +import { ChromaIcon } from "../icons/ChromaIcon"; +import { CohereIcon } from "../icons/Cohere"; +import { EvernoteIcon } from "../icons/Evernote"; +import { FBIcon } from "../icons/FacebookMessenger"; +import { GitBookIcon } from "../icons/GitBook"; +import { GoogleIcon } from "../icons/Google"; +import { HuggingFaceIcon } from "../icons/HuggingFace"; +import { IFixIcon } from "../icons/IFixIt"; +import { MetaIcon } from "../icons/Meta"; +import { MidjourneyIcon } from "../icons/Midjorney"; +import { MongoDBIcon } from "../icons/MongoDB"; +import { NotionIcon } from "../icons/Notion"; +import { OpenAiIcon } from "../icons/OpenAi"; +import { PineconeIcon } from "../icons/Pinecone"; +import { QDrantIcon } from "../icons/QDrant"; +import { SearxIcon } from "../icons/Searx"; +import { VertexAIIcon } from "../icons/VertexAI"; +import { HackerNewsIcon } from "../icons/hackerNews"; +import { SupabaseIcon } from "../icons/supabase"; + export const gradients = [ "bg-gradient-to-br from-gray-800 via-rose-700 to-violet-900", "bg-gradient-to-br from-green-200 via-green-300 to-blue-500", @@ -75,3 +121,166 @@ export const nodeNames: { [char: string]: string } = { output_parsers: "Output Parsers", unknown: "Unknown", }; + +export const nodeIconsLucide: { + [char: string]: React.ForwardRefExoticComponent< + ComponentType> + >; +} = { + Chroma: ChromaIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + AirbyteJSONLoader: AirbyteIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + Anthropic: AnthropicIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + ChatAnthropic: AnthropicIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + BingSearchAPIWrapper: BingIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + BingSearchRun: BingIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + Cohere: CohereIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + CohereEmbeddings: CohereIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + EverNoteLoader: EvernoteIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + FacebookChatLoader: FBIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + GitbookLoader: GitBookIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + GoogleSearchAPIWrapper: GoogleIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + GoogleSearchResults: GoogleIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + GoogleSearchRun: GoogleIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + HNLoader: HackerNewsIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + HuggingFaceHub: HuggingFaceIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + HuggingFaceEmbeddings: HuggingFaceIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + IFixitLoader: IFixIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + Meta: MetaIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + Midjorney: MidjourneyIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + MongoDBAtlasVectorSearch: MongoDBIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + NotionDirectoryLoader: NotionIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + ChatOpenAI: OpenAiIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + OpenAI: OpenAiIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + OpenAIEmbeddings: OpenAiIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + Pinecone: PineconeIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + Qdrant: QDrantIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + Searx: SearxIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + SlackDirectoryLoader: SlackIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + SupabaseVectorStore: SupabaseIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + VertexAI: VertexAIIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + ChatVertexAI: VertexAIIcon as React.ForwardRefExoticComponent< + ComponentType> + >, + agents: Rocket as React.ForwardRefExoticComponent< + ComponentType> + >, + chains: Link as React.ForwardRefExoticComponent< + ComponentType> + >, + memories: Cpu as React.ForwardRefExoticComponent< + ComponentType> + >, + llms: Lightbulb as React.ForwardRefExoticComponent< + ComponentType> + >, + prompts: TerminalSquare as React.ForwardRefExoticComponent< + ComponentType> + >, + tools: Wrench as React.ForwardRefExoticComponent< + ComponentType> + >, + advanced: Laptop2 as React.ForwardRefExoticComponent< + ComponentType> + >, + chat: MessageCircle as React.ForwardRefExoticComponent< + ComponentType> + >, + embeddings: Fingerprint as React.ForwardRefExoticComponent< + ComponentType> + >, + documentloaders: Paperclip as React.ForwardRefExoticComponent< + ComponentType> + >, + vectorstores: Layers as React.ForwardRefExoticComponent< + ComponentType> + >, + toolkits: Hammer as React.ForwardRefExoticComponent< + ComponentType> + >, + textsplitters: Scissors as React.ForwardRefExoticComponent< + ComponentType> + >, + wrappers: Gift as React.ForwardRefExoticComponent< + ComponentType> + >, + utilities: Wand2 as React.ForwardRefExoticComponent< + ComponentType> + >, + output_parsers: Compass as React.ForwardRefExoticComponent< + ComponentType> + >, + retrievers: FileSearch as React.ForwardRefExoticComponent< + ComponentType> + >, + unknown: HelpCircle as React.ForwardRefExoticComponent< + ComponentType> + >, +}; + +export function getConnectedNodes(edge: Edge, nodes: Array): Array { + const sourceId = edge.source; + const targetId = edge.target; + return nodes.filter((node) => node.id === targetId || node.id === sourceId); +} From 3cb25486140ffd6791434ef9ddda5e1054383351 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 18:19:26 -0300 Subject: [PATCH 09/20] refactor --- src/frontend/src/modals/EditNodeModal/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/modals/EditNodeModal/index.tsx b/src/frontend/src/modals/EditNodeModal/index.tsx index 84d85014d..18afc0df3 100644 --- a/src/frontend/src/modals/EditNodeModal/index.tsx +++ b/src/frontend/src/modals/EditNodeModal/index.tsx @@ -29,11 +29,12 @@ import { TableHeader, TableRow, } from "../../components/ui/table"; +import { limitScrollFieldsModal } from "../../constants"; import { PopUpContext } from "../../contexts/popUpContext"; import { TabsContext } from "../../contexts/tabsContext"; import { typesContext } from "../../contexts/typesContext"; import { NodeDataType } from "../../types/flow"; -import { classNames, limitScrollFieldsModal } from "../../utils"; +import { classNames } from "../../utils"; export default function EditNodeModal({ data }: { data: NodeDataType }) { const [open, setOpen] = useState(true); From 81f25662f1e657a63f80271a3343dea48456f060 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 18:25:37 -0300 Subject: [PATCH 10/20] is validConnection migration done --- .../components/parameterComponent/index.tsx | 6 ++- .../components/PageComponent/index.tsx | 2 +- src/frontend/src/utils.ts | 44 +------------------ src/frontend/src/utils/reactflowUtils.ts | 43 ++++++++++++++++++ 4 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index d63a91ea2..f50a559c7 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -21,9 +21,11 @@ import { classNames, getRandomKeyByssmm, groupByFamily, - isValidConnection, } from "../../../../utils"; -import { cleanEdges } from "../../../../utils/reactflowUtils"; +import { + cleanEdges, + isValidConnection, +} from "../../../../utils/reactflowUtils"; import { nodeColors, nodeIconsLucide, diff --git a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx index a6ac0f4df..163e3d9bc 100644 --- a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx @@ -26,7 +26,7 @@ import { typesContext } from "../../../../contexts/typesContext"; import { undoRedoContext } from "../../../../contexts/undoRedoContext"; import { APIClassType } from "../../../../types/api"; import { FlowType, NodeType } from "../../../../types/flow"; -import { isValidConnection } from "../../../../utils"; +import { isValidConnection } from "../../../../utils/reactflowUtils"; import ConnectionLineComponent from "../ConnectionLineComponent"; import ExtraSidebar from "../extraSidebarComponent"; diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index de42e7819..95890a3c8 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -1,6 +1,6 @@ import clsx, { ClassValue } from "clsx"; import _ from "lodash"; -import { Connection, ReactFlowInstance } from "reactflow"; +import { ReactFlowInstance } from "reactflow"; import { twMerge } from "tailwind-merge"; import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./flow_constants"; import { APITemplateType } from "./types/api"; @@ -74,48 +74,6 @@ export function roundNumber(x: number, decimals: number) { return Math.round(x * Math.pow(10, decimals)) / Math.pow(10, decimals); } -export function isValidConnection( - { source, target, sourceHandle, targetHandle }: Connection, - reactFlowInstance: ReactFlowInstance -) { - if ( - targetHandle - .split("|")[0] - .split(";") - .some((n) => n === sourceHandle.split("|")[0]) || - sourceHandle - .split("|") - .slice(2) - .some((t) => - targetHandle - .split("|")[0] - .split(";") - .some((n) => n === t) - ) || - targetHandle.split("|")[0] === "str" - ) { - let targetNode = reactFlowInstance?.getNode(target)?.data?.node; - if (!targetNode) { - if ( - !reactFlowInstance - .getEdges() - .find((e) => e.targetHandle === targetHandle) - ) { - return true; - } - } else if ( - (!targetNode.template[targetHandle.split("|")[1]].list && - !reactFlowInstance - .getEdges() - .find((e) => e.targetHandle === targetHandle)) || - targetNode.template[targetHandle.split("|")[1]].list - ) { - return true; - } - } - return false; -} - export function removeApiKeys(flow: FlowType): FlowType { let cleanFLow = _.cloneDeep(flow); cleanFLow.data.nodes.forEach((node) => { diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 2f9c58343..c5fe272e7 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -1,4 +1,5 @@ import _ from "lodash"; +import { Connection, ReactFlowInstance } from "reactflow"; import { cleanEdgesType } from "../types/utils/reactflowUtils"; export function cleanEdges({ @@ -44,3 +45,45 @@ export function cleanEdges({ }); updateEdge(newEdges); } + +export function isValidConnection( + { source, target, sourceHandle, targetHandle }: Connection, + reactFlowInstance: ReactFlowInstance +) { + if ( + targetHandle + .split("|")[0] + .split(";") + .some((n) => n === sourceHandle.split("|")[0]) || + sourceHandle + .split("|") + .slice(2) + .some((t) => + targetHandle + .split("|")[0] + .split(";") + .some((n) => n === t) + ) || + targetHandle.split("|")[0] === "str" + ) { + let targetNode = reactFlowInstance?.getNode(target)?.data?.node; + if (!targetNode) { + if ( + !reactFlowInstance + .getEdges() + .find((e) => e.targetHandle === targetHandle) + ) { + return true; + } + } else if ( + (!targetNode.template[targetHandle.split("|")[1]].list && + !reactFlowInstance + .getEdges() + .find((e) => e.targetHandle === targetHandle)) || + targetNode.template[targetHandle.split("|")[1]].list + ) { + return true; + } + } + return false; +} From 4c9dc55205848c24d2b8e8330e6272e146e81e89 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 18:32:47 -0300 Subject: [PATCH 11/20] removeApiKeys migration done --- src/frontend/src/modals/exportModal/index.tsx | 2 +- src/frontend/src/utils.ts | 18 +----------------- src/frontend/src/utils/reactflowUtils.ts | 13 +++++++++++++ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/frontend/src/modals/exportModal/index.tsx b/src/frontend/src/modals/exportModal/index.tsx index fb6867811..3a1d27b6f 100644 --- a/src/frontend/src/modals/exportModal/index.tsx +++ b/src/frontend/src/modals/exportModal/index.tsx @@ -16,7 +16,7 @@ import { EXPORT_DIALOG_SUBTITLE } from "../../constants"; import { alertContext } from "../../contexts/alertContext"; import { PopUpContext } from "../../contexts/popUpContext"; import { TabsContext } from "../../contexts/tabsContext"; -import { removeApiKeys } from "../../utils"; +import { removeApiKeys } from "../../utils/reactflowUtils"; export default function ExportModal() { const [open, setOpen] = useState(true); diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 95890a3c8..8e9b6cb64 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -5,7 +5,7 @@ import { twMerge } from "tailwind-merge"; import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./flow_constants"; import { APITemplateType } from "./types/api"; import { IVarHighlightType } from "./types/components"; -import { FlowType, NodeType } from "./types/flow"; +import { NodeType } from "./types/flow"; export function classNames(...classes: Array) { return classes.filter(Boolean).join(" "); @@ -70,22 +70,6 @@ export function normalCaseToSnakeCase(str: string) { .join("_"); } -export function roundNumber(x: number, decimals: number) { - return Math.round(x * Math.pow(10, decimals)) / Math.pow(10, decimals); -} - -export function removeApiKeys(flow: FlowType): FlowType { - let cleanFLow = _.cloneDeep(flow); - cleanFLow.data.nodes.forEach((node) => { - for (const key in node.data.node.template) { - if (node.data.node.template[key].password) { - node.data.node.template[key].value = ""; - } - } - }); - return cleanFLow; -} - export function updateObject>( reference: T, objectToUpdate: T diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index c5fe272e7..7bd9cc4a2 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -1,5 +1,6 @@ import _ from "lodash"; import { Connection, ReactFlowInstance } from "reactflow"; +import { FlowType } from "../types/flow"; import { cleanEdgesType } from "../types/utils/reactflowUtils"; export function cleanEdges({ @@ -87,3 +88,15 @@ export function isValidConnection( } return false; } + +export function removeApiKeys(flow: FlowType): FlowType { + let cleanFLow = _.cloneDeep(flow); + cleanFLow.data.nodes.forEach((node) => { + for (const key in node.data.node.template) { + if (node.data.node.template[key].password) { + node.data.node.template[key].value = ""; + } + } + }); + return cleanFLow; +} From db8f5a74d375b5d8fa175aef59f94a349dde3328 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 18:40:38 -0300 Subject: [PATCH 12/20] updateTemplate migration done --- src/frontend/src/utils.ts | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 8e9b6cb64..2b488d54e 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -3,7 +3,6 @@ import _ from "lodash"; import { ReactFlowInstance } from "reactflow"; import { twMerge } from "tailwind-merge"; import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./flow_constants"; -import { APITemplateType } from "./types/api"; import { IVarHighlightType } from "./types/components"; import { NodeType } from "./types/flow"; @@ -101,29 +100,6 @@ export function debounce(func, wait) { }; } -export function updateTemplate( - reference: APITemplateType, - objectToUpdate: APITemplateType -): APITemplateType { - let clonedObject: APITemplateType = _.cloneDeep(reference); - - // Loop through each key in the reference object - for (const key in clonedObject) { - // If the key is not in the object to update, add it - if (objectToUpdate[key] && objectToUpdate[key].value) { - clonedObject[key].value = objectToUpdate[key].value; - } - if ( - objectToUpdate[key] && - objectToUpdate[key].advanced !== null && - objectToUpdate[key].advanced !== undefined - ) { - clonedObject[key].advanced = objectToUpdate[key].advanced; - } - } - return clonedObject; -} - interface languageMap { [key: string]: string | undefined; } From 9a41ca9ce2eeaf6ed636bc79593d17e1227a1a32 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 18:43:57 -0300 Subject: [PATCH 13/20] updateTemplate migration done --- src/frontend/src/contexts/tabsContext.tsx | 8 ++------ src/frontend/src/utils/reactflowUtils.ts | 24 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index 479131db2..c5c4264de 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -20,12 +20,8 @@ import { import { APIClassType, APITemplateType } from "../types/api"; import { FlowType, NodeType } from "../types/flow"; import { TabsContextType, TabsState } from "../types/tabs"; -import { - getRandomDescription, - getRandomName, - updateIds, - updateTemplate, -} from "../utils"; +import { getRandomDescription, getRandomName, updateIds } from "../utils"; +import { updateTemplate } from "../utils/reactflowUtils"; import { alertContext } from "./alertContext"; import { typesContext } from "./typesContext"; diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 7bd9cc4a2..c8623cf69 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -1,5 +1,6 @@ import _ from "lodash"; import { Connection, ReactFlowInstance } from "reactflow"; +import { APITemplateType } from "../types/api"; import { FlowType } from "../types/flow"; import { cleanEdgesType } from "../types/utils/reactflowUtils"; @@ -100,3 +101,26 @@ export function removeApiKeys(flow: FlowType): FlowType { }); return cleanFLow; } + +export function updateTemplate( + reference: APITemplateType, + objectToUpdate: APITemplateType +): APITemplateType { + let clonedObject: APITemplateType = _.cloneDeep(reference); + + // Loop through each key in the reference object + for (const key in clonedObject) { + // If the key is not in the object to update, add it + if (objectToUpdate[key] && objectToUpdate[key].value) { + clonedObject[key].value = objectToUpdate[key].value; + } + if ( + objectToUpdate[key] && + objectToUpdate[key].advanced !== null && + objectToUpdate[key].advanced !== undefined + ) { + clonedObject[key].advanced = objectToUpdate[key].advanced; + } + } + return clonedObject; +} From 75c14c67a599784871e2410d38f3429917a554d7 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 18:56:16 -0300 Subject: [PATCH 14/20] remove dead code --- src/frontend/src/utils.ts | 53 --------------------------------------- 1 file changed, 53 deletions(-) diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 2b488d54e..863d907da 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -1,5 +1,4 @@ import clsx, { ClassValue } from "clsx"; -import _ from "lodash"; import { ReactFlowInstance } from "reactflow"; import { twMerge } from "tailwind-merge"; import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./flow_constants"; @@ -14,27 +13,6 @@ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } -export function toCamelCase(str: string) { - return str - .split(" ") - .map((word, index) => - index === 0 - ? word.toLowerCase() - : word[0].toUpperCase() + word.slice(1).toLowerCase() - ) - .join(""); -} -export function toFirstUpperCase(str: string) { - return str - .split(" ") - .map((word, index) => word[0].toUpperCase() + word.slice(1).toLowerCase()) - .join(""); -} - -export function snakeToSpaces(str: string) { - return str.split("_").join(" "); -} - export function toNormalCase(str: string) { let result = str .split("_") @@ -69,37 +47,6 @@ export function normalCaseToSnakeCase(str: string) { .join("_"); } -export function updateObject>( - reference: T, - objectToUpdate: T -): T { - let clonedObject = _.cloneDeep(objectToUpdate); - // Loop through each key in the object to update - for (const key in clonedObject) { - // If the key is not in the reference object, delete it - if (!(key in reference)) { - delete clonedObject[key]; - } - } - // Loop through each key in the reference object - for (const key in reference) { - // If the key is not in the object to update, add it - if (!(key in clonedObject)) { - clonedObject[key] = reference[key]; - } - } - return clonedObject; -} - -export function debounce(func, wait) { - let timeout; - return function (...args) { - const context = this; - clearTimeout(timeout); - timeout = setTimeout(() => func.apply(context, args), wait); - }; -} - interface languageMap { [key: string]: string | undefined; } From cd1d3c226a79432b25bc21cdbf8bdc09c486e8f4 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 19:11:34 -0300 Subject: [PATCH 15/20] moved programmingLanguages to constant file --- src/frontend/src/constants.ts | 35 +++++++++++++++++++ .../formModal/chatMessage/codeBlock/index.tsx | 2 +- src/frontend/src/utils.ts | 31 ---------------- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/frontend/src/constants.ts b/src/frontend/src/constants.ts index d7c8f01ae..7e1e3885e 100644 --- a/src/frontend/src/constants.ts +++ b/src/frontend/src/constants.ts @@ -5,6 +5,41 @@ import { FlowType } from "./types/flow"; import { TabsState } from "./types/tabs"; import { buildInputs, buildTweaks } from "./utils"; +/** + * constants fpr programming languages box on chat form + * @constant + */ +interface languageMap { + [key: string]: string | undefined; +} + +export const programmingLanguages: languageMap = { + javascript: ".js", + python: ".py", + java: ".java", + c: ".c", + cpp: ".cpp", + "c++": ".cpp", + "c#": ".cs", + ruby: ".rb", + php: ".php", + swift: ".swift", + "objective-c": ".m", + kotlin: ".kt", + typescript: ".ts", + go: ".go", + perl: ".pl", + rust: ".rs", + scala: ".scala", + haskell: ".hs", + lua: ".lua", + shell: ".sh", + sql: ".sql", + html: ".html", + css: ".css", + // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component +}; + /** * enum for the different types of nodes * @enum diff --git a/src/frontend/src/modals/formModal/chatMessage/codeBlock/index.tsx b/src/frontend/src/modals/formModal/chatMessage/codeBlock/index.tsx index 884215ebb..44011821d 100644 --- a/src/frontend/src/modals/formModal/chatMessage/codeBlock/index.tsx +++ b/src/frontend/src/modals/formModal/chatMessage/codeBlock/index.tsx @@ -2,7 +2,7 @@ import { IconCheck, IconClipboard, IconDownload } from "@tabler/icons-react"; import { useState } from "react"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { oneDark } from "react-syntax-highlighter/dist/cjs/styles/prism"; -import { programmingLanguages } from "../../../../utils"; +import { programmingLanguages } from "../../../../constants"; interface Props { language: string; diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 863d907da..0972d9972 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -47,37 +47,6 @@ export function normalCaseToSnakeCase(str: string) { .join("_"); } -interface languageMap { - [key: string]: string | undefined; -} - -export const programmingLanguages: languageMap = { - javascript: ".js", - python: ".py", - java: ".java", - c: ".c", - cpp: ".cpp", - "c++": ".cpp", - "c#": ".cs", - ruby: ".rb", - php: ".php", - swift: ".swift", - "objective-c": ".m", - kotlin: ".kt", - typescript: ".ts", - go: ".go", - perl: ".pl", - rust: ".rs", - scala: ".scala", - haskell: ".hs", - lua: ".lua", - shell: ".sh", - sql: ".sql", - html: ".html", - css: ".css", - // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component -}; - export function toTitleCase(str: string) { let result = str .split("_") From ffda93ee3437f6e71213b4c59f99a73b836a232e Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 19:22:18 -0300 Subject: [PATCH 16/20] updateIds migration done --- src/frontend/src/contexts/tabsContext.tsx | 4 +-- src/frontend/src/utils.ts | 35 --------------------- src/frontend/src/utils/reactflowUtils.ts | 37 ++++++++++++++++++++++- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index c5c4264de..bbd77007d 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -20,8 +20,8 @@ import { import { APIClassType, APITemplateType } from "../types/api"; import { FlowType, NodeType } from "../types/flow"; import { TabsContextType, TabsState } from "../types/tabs"; -import { getRandomDescription, getRandomName, updateIds } from "../utils"; -import { updateTemplate } from "../utils/reactflowUtils"; +import { getRandomDescription, getRandomName } from "../utils"; +import { updateIds, updateTemplate } from "../utils/reactflowUtils"; import { alertContext } from "./alertContext"; import { typesContext } from "./typesContext"; diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 0972d9972..c5f57bc5a 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -84,41 +84,6 @@ export function checkUpperWords(str: string) { return words.join(" "); } -export function updateIds(newFlow, getNodeId) { - let idsMap = {}; - - newFlow.nodes.forEach((n: NodeType) => { - // Generate a unique node ID - let newId = getNodeId(n.data.type); - idsMap[n.id] = newId; - n.id = newId; - n.data.id = newId; - // Add the new node to the list of nodes in state - }); - - newFlow.edges.forEach((e) => { - e.source = idsMap[e.source]; - e.target = idsMap[e.target]; - let sourceHandleSplitted = e.sourceHandle.split("|"); - e.sourceHandle = - sourceHandleSplitted[0] + - "|" + - e.source + - "|" + - sourceHandleSplitted.slice(2).join("|"); - let targetHandleSplitted = e.targetHandle.split("|"); - e.targetHandle = - targetHandleSplitted.slice(0, -1).join("|") + "|" + e.target; - e.id = - "reactflow__edge-" + - e.source + - e.sourceHandle + - "-" + - e.target + - e.targetHandle; - }); -} - export function groupByFamily(data, baseClasses, left, type) { let parentOutput: string; let arrOfParent: string[] = []; diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index c8623cf69..3183bd1af 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -1,7 +1,7 @@ import _ from "lodash"; import { Connection, ReactFlowInstance } from "reactflow"; import { APITemplateType } from "../types/api"; -import { FlowType } from "../types/flow"; +import { FlowType, NodeType } from "../types/flow"; import { cleanEdgesType } from "../types/utils/reactflowUtils"; export function cleanEdges({ @@ -124,3 +124,38 @@ export function updateTemplate( } return clonedObject; } + +export function updateIds(newFlow, getNodeId) { + let idsMap = {}; + + newFlow.nodes.forEach((n: NodeType) => { + // Generate a unique node ID + let newId = getNodeId(n.data.type); + idsMap[n.id] = newId; + n.id = newId; + n.data.id = newId; + // Add the new node to the list of nodes in state + }); + + newFlow.edges.forEach((e) => { + e.source = idsMap[e.source]; + e.target = idsMap[e.target]; + let sourceHandleSplitted = e.sourceHandle.split("|"); + e.sourceHandle = + sourceHandleSplitted[0] + + "|" + + e.source + + "|" + + sourceHandleSplitted.slice(2).join("|"); + let targetHandleSplitted = e.targetHandle.split("|"); + e.targetHandle = + targetHandleSplitted.slice(0, -1).join("|") + "|" + e.target; + e.id = + "reactflow__edge-" + + e.source + + e.sourceHandle + + "-" + + e.target + + e.targetHandle; + }); +} From 28c0b35fd7e5b8bbae95e65c5079f836a1b407c4 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 19:31:00 -0300 Subject: [PATCH 17/20] buildTweaks migration done --- src/frontend/src/constants.ts | 3 ++- src/frontend/src/modals/ApiModal/index.tsx | 4 ++-- src/frontend/src/utils.ts | 6 ------ src/frontend/src/utils/reactflowUtils.ts | 7 +++++++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/frontend/src/constants.ts b/src/frontend/src/constants.ts index 7e1e3885e..b3cbeedcc 100644 --- a/src/frontend/src/constants.ts +++ b/src/frontend/src/constants.ts @@ -3,7 +3,8 @@ import { MessageSquare } from "lucide-react"; import { FlowType } from "./types/flow"; import { TabsState } from "./types/tabs"; -import { buildInputs, buildTweaks } from "./utils"; +import { buildInputs } from "./utils"; +import { buildTweaks } from "./utils/reactflowUtils"; /** * constants fpr programming languages box on chat form diff --git a/src/frontend/src/modals/ApiModal/index.tsx b/src/frontend/src/modals/ApiModal/index.tsx index f3f84a9ac..f6902f663 100644 --- a/src/frontend/src/modals/ApiModal/index.tsx +++ b/src/frontend/src/modals/ApiModal/index.tsx @@ -51,8 +51,8 @@ import { import { darkContext } from "../../contexts/darkContext"; import { TabsContext } from "../../contexts/tabsContext"; import { FlowType } from "../../types/flow/index"; -import { buildTweaks, classNames } from "../../utils"; - +import { classNames } from "../../utils"; +import { buildTweaks } from "../../utils/reactflowUtils"; export default function ApiModal({ flow }: { flow: FlowType }) { const [open, setOpen] = useState(true); const { dark } = useContext(darkContext); diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index c5f57bc5a..6aed03239 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -209,12 +209,6 @@ export function buildInputs(tabsState, id) { : '{"input": "message"}'; } -export function buildTweaks(flow) { - return flow.data.nodes.reduce((acc, node) => { - acc[node.data.id] = {}; - return acc; - }, {}); -} export function validateNode( n: NodeType, reactFlowInstance: ReactFlowInstance diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 3183bd1af..515199574 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -159,3 +159,10 @@ export function updateIds(newFlow, getNodeId) { e.targetHandle; }); } + +export function buildTweaks(flow) { + return flow.data.nodes.reduce((acc, node) => { + acc[node.data.id] = {}; + return acc; + }, {}); +} From 33cfb8600a38ca65a3a26b60549a7bf249c48b35 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 19:34:32 -0300 Subject: [PATCH 18/20] validateNodes migration done --- .../chatComponent/buildTrigger/index.tsx | 2 +- src/frontend/src/modals/formModal/index.tsx | 3 +- src/frontend/src/utils.ts | 54 ------------------- src/frontend/src/utils/reactflowUtils.ts | 53 ++++++++++++++++++ 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/frontend/src/components/chatComponent/buildTrigger/index.tsx b/src/frontend/src/components/chatComponent/buildTrigger/index.tsx index 09ab90ff7..f551d6d06 100644 --- a/src/frontend/src/components/chatComponent/buildTrigger/index.tsx +++ b/src/frontend/src/components/chatComponent/buildTrigger/index.tsx @@ -7,9 +7,9 @@ import { alertContext } from "../../../contexts/alertContext"; import { typesContext } from "../../../contexts/typesContext"; import { postBuildInit } from "../../../controllers/API"; import { FlowType } from "../../../types/flow"; -import { validateNodes } from "../../../utils"; import { TabsContext } from "../../../contexts/tabsContext"; +import { validateNodes } from "../../../utils/reactflowUtils"; import RadialProgressComponent from "../../RadialProgress"; export default function BuildTrigger({ diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx index 12f7683b3..6bcd1a331 100644 --- a/src/frontend/src/modals/formModal/index.tsx +++ b/src/frontend/src/modals/formModal/index.tsx @@ -5,7 +5,7 @@ import { typesContext } from "../../contexts/typesContext"; import { sendAllProps } from "../../types/api"; import { ChatMessageType } from "../../types/chat"; import { FlowType } from "../../types/flow"; -import { classNames, validateNodes } from "../../utils"; +import { classNames } from "../../utils"; import ChatInput from "./chatInput"; import ChatMessage from "./chatMessage"; @@ -29,6 +29,7 @@ import { import { Textarea } from "../../components/ui/textarea"; import { CHAT_FORM_DIALOG_SUBTITLE, THOUGHTS_ICON } from "../../constants"; import { TabsContext } from "../../contexts/tabsContext"; +import { validateNodes } from "../../utils/reactflowUtils"; export default function FormModal({ flow, diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 6aed03239..beec2239e 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -1,9 +1,7 @@ import clsx, { ClassValue } from "clsx"; -import { ReactFlowInstance } from "reactflow"; import { twMerge } from "tailwind-merge"; import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./flow_constants"; import { IVarHighlightType } from "./types/components"; -import { NodeType } from "./types/flow"; export function classNames(...classes: Array) { return classes.filter(Boolean).join(" "); @@ -209,58 +207,6 @@ export function buildInputs(tabsState, id) { : '{"input": "message"}'; } -export function validateNode( - n: NodeType, - reactFlowInstance: ReactFlowInstance -): Array { - if (!n.data?.node?.template || !Object.keys(n.data.node.template)) { - return [ - "We've noticed a potential issue with a node in the flow. Please review it and, if necessary, submit a bug report with your exported flow file. Thank you for your help!", - ]; - } - - const { - type, - node: { template }, - } = n.data; - - return Object.keys(template).reduce( - (errors: Array, t) => - errors.concat( - template[t].required && - template[t].show && - (template[t].value === undefined || - template[t].value === null || - template[t].value === "") && - !reactFlowInstance - .getEdges() - .some( - (e) => - e.targetHandle.split("|")[1] === t && - e.targetHandle.split("|")[2] === n.id - ) - ? [ - `${type} is missing ${ - template.display_name || toNormalCase(template[t].name) - }.`, - ] - : [] - ), - [] as string[] - ); -} - -export function validateNodes(reactFlowInstance: ReactFlowInstance) { - if (reactFlowInstance.getNodes().length === 0) { - return [ - "No nodes found in the flow. Please add at least one node to the flow.", - ]; - } - return reactFlowInstance - .getNodes() - .flatMap((n: NodeType) => validateNode(n, reactFlowInstance)); -} - export function getRandomElement(array: T[]): T { return array[Math.floor(Math.random() * array.length)]; } diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 515199574..b14a24c70 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -3,6 +3,7 @@ import { Connection, ReactFlowInstance } from "reactflow"; import { APITemplateType } from "../types/api"; import { FlowType, NodeType } from "../types/flow"; import { cleanEdgesType } from "../types/utils/reactflowUtils"; +import { toNormalCase } from "../utils"; export function cleanEdges({ flow: { edges, nodes }, @@ -166,3 +167,55 @@ export function buildTweaks(flow) { return acc; }, {}); } + +export function validateNode( + n: NodeType, + reactFlowInstance: ReactFlowInstance +): Array { + if (!n.data?.node?.template || !Object.keys(n.data.node.template)) { + return [ + "We've noticed a potential issue with a node in the flow. Please review it and, if necessary, submit a bug report with your exported flow file. Thank you for your help!", + ]; + } + + const { + type, + node: { template }, + } = n.data; + + return Object.keys(template).reduce( + (errors: Array, t) => + errors.concat( + template[t].required && + template[t].show && + (template[t].value === undefined || + template[t].value === null || + template[t].value === "") && + !reactFlowInstance + .getEdges() + .some( + (e) => + e.targetHandle.split("|")[1] === t && + e.targetHandle.split("|")[2] === n.id + ) + ? [ + `${type} is missing ${ + template.display_name || toNormalCase(template[t].name) + }.`, + ] + : [] + ), + [] as string[] + ); +} + +export function validateNodes(reactFlowInstance: ReactFlowInstance) { + if (reactFlowInstance.getNodes().length === 0) { + return [ + "No nodes found in the flow. Please add at least one node to the flow.", + ]; + } + return reactFlowInstance + .getNodes() + .flatMap((n: NodeType) => validateNode(n, reactFlowInstance)); +} From 62dde544c17422be58c002e2335558afc7328dc1 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 19:45:04 -0300 Subject: [PATCH 19/20] moved some constants to constant file --- src/frontend/src/constants.ts | 33 +++++++++++++++++++ .../src/modals/genericModal/index.tsx | 11 +++---- src/frontend/src/utils.ts | 25 -------------- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/frontend/src/constants.ts b/src/frontend/src/constants.ts index b3cbeedcc..c642f09f7 100644 --- a/src/frontend/src/constants.ts +++ b/src/frontend/src/constants.ts @@ -1,6 +1,7 @@ // src/constants.tsx import { MessageSquare } from "lucide-react"; +import { IVarHighlightType } from "./types/components"; import { FlowType } from "./types/flow"; import { TabsState } from "./types/tabs"; import { buildInputs } from "./utils"; @@ -13,6 +14,38 @@ import { buildTweaks } from "./utils/reactflowUtils"; interface languageMap { [key: string]: string | undefined; } +/** + * invalid characters for flow name + * @constant + */ +export const INVALID_CHARACTERS = [ + " ", + ",", + ".", + ":", + ";", + "!", + "?", + "/", + "\\", + "(", + ")", + "[", + "]", + "\n", +]; + +/** + * regex to highlight the variables in the text + * @constant + */ + +export const regexHighlight = /\{([^}]+)\}/g; + +export const varHighlightHTML = ({ name }: IVarHighlightType) => { + const html = `{${name}}`; + return html; +}; export const programmingLanguages: languageMap = { javascript: ".js", diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index 9de3b1b73..a53ce1218 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -7,23 +7,20 @@ import { Button } from "../../components/ui/button"; import { DialogTitle } from "../../components/ui/dialog"; import { Textarea } from "../../components/ui/textarea"; import { + INVALID_CHARACTERS, MAX_WORDS_HIGHLIGHT, PROMPT_DIALOG_SUBTITLE, TEXT_DIALOG_SUBTITLE, TypeModal, + regexHighlight, + varHighlightHTML, } from "../../constants"; import { alertContext } from "../../contexts/alertContext"; import { darkContext } from "../../contexts/darkContext"; import { PopUpContext } from "../../contexts/popUpContext"; import { postValidatePrompt } from "../../controllers/API"; import { APIClassType } from "../../types/api"; -import { - INVALID_CHARACTERS, - classNames, - getRandomKeyByssmm, - regexHighlight, - varHighlightHTML, -} from "../../utils"; +import { classNames, getRandomKeyByssmm } from "../../utils"; import BaseModal from "../baseModal"; export default function GenericModal({ diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index beec2239e..af83e83ff 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -1,7 +1,6 @@ import clsx, { ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./flow_constants"; -import { IVarHighlightType } from "./types/components"; export function classNames(...classes: Array) { return classes.filter(Boolean).join(" "); @@ -252,27 +251,3 @@ export function getRandomKeyByssmm(): string { const milliseconds = String(now.getMilliseconds()).padStart(3, "0"); return seconds + milliseconds + Math.abs(Math.floor(Math.random() * 10001)); } - -export const INVALID_CHARACTERS = [ - " ", - ",", - ".", - ":", - ";", - "!", - "?", - "/", - "\\", - "(", - ")", - "[", - "]", - "\n", -]; - -export const regexHighlight = /\{([^}]+)\}/g; - -export const varHighlightHTML = ({ name }: IVarHighlightType) => { - const html = `{${name}}`; - return html; -}; From c3bdc2c0a49832d43d0b8364cfdea44da347f767 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 13 Jul 2023 19:48:41 -0300 Subject: [PATCH 20/20] moved utils file to utils folder --- .../components/parameterComponent/index.tsx | 10 +++++----- src/frontend/src/CustomNodes/GenericNode/index.tsx | 2 +- .../src/components/ExtraSidebarComponent/index.tsx | 2 +- .../src/components/ReactTooltipComponent/index.tsx | 2 +- .../src/components/dropdownComponent/index.tsx | 2 +- src/frontend/src/components/inputComponent/index.tsx | 2 +- src/frontend/src/components/toggleComponent/index.tsx | 2 +- src/frontend/src/components/ui/accordion.tsx | 2 +- src/frontend/src/components/ui/badge.tsx | 2 +- src/frontend/src/components/ui/button.tsx | 2 +- src/frontend/src/components/ui/card.tsx | 2 +- src/frontend/src/components/ui/checkbox.tsx | 2 +- src/frontend/src/components/ui/dialog.tsx | 2 +- src/frontend/src/components/ui/dropdown-menu.tsx | 2 +- src/frontend/src/components/ui/input.tsx | 2 +- src/frontend/src/components/ui/label.tsx | 2 +- src/frontend/src/components/ui/menubar.tsx | 2 +- src/frontend/src/components/ui/progress.tsx | 2 +- src/frontend/src/components/ui/rename-label.tsx | 2 +- src/frontend/src/components/ui/separator.tsx | 2 +- src/frontend/src/components/ui/switch.tsx | 2 +- src/frontend/src/components/ui/table.tsx | 2 +- src/frontend/src/components/ui/tabs.tsx | 2 +- src/frontend/src/components/ui/textarea.tsx | 2 +- src/frontend/src/components/ui/tooltip.tsx | 2 +- src/frontend/src/constants.ts | 2 +- src/frontend/src/contexts/tabsContext.tsx | 2 +- src/frontend/src/modals/ApiModal/index.tsx | 2 +- src/frontend/src/modals/EditNodeModal/index.tsx | 2 +- .../modals/NodeModal/components/ModalField/index.tsx | 2 +- src/frontend/src/modals/NodeModal/index.tsx | 2 +- src/frontend/src/modals/formModal/chatInput/index.tsx | 2 +- .../src/modals/formModal/chatMessage/index.tsx | 2 +- src/frontend/src/modals/formModal/index.tsx | 2 +- src/frontend/src/modals/genericModal/index.tsx | 2 +- .../src/modals/importModal/buttonBox/index.tsx | 2 +- src/frontend/src/modals/importModal/index.tsx | 2 +- .../components/extraSidebarComponent/index.tsx | 2 +- .../FlowPage/components/nodeToolbarComponent/index.tsx | 2 +- src/frontend/src/utils/reactflowUtils.ts | 2 +- src/frontend/src/{ => utils}/utils.ts | 2 +- 41 files changed, 45 insertions(+), 45 deletions(-) rename src/frontend/src/{ => utils}/utils.ts (98%) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index f50a559c7..0e8705f60 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -17,11 +17,6 @@ import { PopUpContext } from "../../../../contexts/popUpContext"; import { TabsContext } from "../../../../contexts/tabsContext"; import { typesContext } from "../../../../contexts/typesContext"; import { ParameterComponentType } from "../../../../types/components"; -import { - classNames, - getRandomKeyByssmm, - groupByFamily, -} from "../../../../utils"; import { cleanEdges, isValidConnection, @@ -31,6 +26,11 @@ import { nodeIconsLucide, nodeNames, } from "../../../../utils/styleUtils"; +import { + classNames, + getRandomKeyByssmm, + groupByFamily, +} from "../../../../utils/utils"; export default function ParameterComponent({ left, diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index f53c0bb97..34d02a9fa 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -10,8 +10,8 @@ import { typesContext } from "../../contexts/typesContext"; import NodeModal from "../../modals/NodeModal"; import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent"; import { NodeDataType } from "../../types/flow"; -import { classNames, toTitleCase } from "../../utils"; import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils"; +import { classNames, toTitleCase } from "../../utils/utils"; import ParameterComponent from "./components/parameterComponent"; export default function GenericNode({ diff --git a/src/frontend/src/components/ExtraSidebarComponent/index.tsx b/src/frontend/src/components/ExtraSidebarComponent/index.tsx index e307e5234..06f62b3af 100644 --- a/src/frontend/src/components/ExtraSidebarComponent/index.tsx +++ b/src/frontend/src/components/ExtraSidebarComponent/index.tsx @@ -2,7 +2,7 @@ import { Disclosure } from "@headlessui/react"; import { useContext } from "react"; import { Link } from "react-router-dom"; import { locationContext } from "../../contexts/locationContext"; -import { classNames } from "../../utils"; +import { classNames } from "../../utils/utils"; export default function ExtraSidebar() { const { diff --git a/src/frontend/src/components/ReactTooltipComponent/index.tsx b/src/frontend/src/components/ReactTooltipComponent/index.tsx index f49e252a6..0f0c64b89 100644 --- a/src/frontend/src/components/ReactTooltipComponent/index.tsx +++ b/src/frontend/src/components/ReactTooltipComponent/index.tsx @@ -3,7 +3,7 @@ import type { FC } from "react"; import React from "react"; import { Tooltip as ReactTooltip } from "react-tooltip"; import "react-tooltip/dist/react-tooltip.css"; -import { classNames } from "../../utils"; +import { classNames } from "../../utils/utils"; type TooltipProps = { selector: string; diff --git a/src/frontend/src/components/dropdownComponent/index.tsx b/src/frontend/src/components/dropdownComponent/index.tsx index 53489a2ee..657de23d1 100644 --- a/src/frontend/src/components/dropdownComponent/index.tsx +++ b/src/frontend/src/components/dropdownComponent/index.tsx @@ -3,7 +3,7 @@ import { Check, ChevronsUpDown } from "lucide-react"; import { Fragment, useContext, useEffect, useState } from "react"; import { PopUpContext } from "../../contexts/popUpContext"; import { DropDownComponentType } from "../../types/components"; -import { classNames } from "../../utils"; +import { classNames } from "../../utils/utils"; export default function Dropdown({ value, diff --git a/src/frontend/src/components/inputComponent/index.tsx b/src/frontend/src/components/inputComponent/index.tsx index 8da5c428e..8d564bdcd 100644 --- a/src/frontend/src/components/inputComponent/index.tsx +++ b/src/frontend/src/components/inputComponent/index.tsx @@ -2,7 +2,7 @@ import { useContext, useEffect, useState } from "react"; import { PopUpContext } from "../../contexts/popUpContext"; import { TabsContext } from "../../contexts/tabsContext"; import { InputComponentType } from "../../types/components"; -import { classNames } from "../../utils"; +import { classNames } from "../../utils/utils"; export default function InputComponent({ value, diff --git a/src/frontend/src/components/toggleComponent/index.tsx b/src/frontend/src/components/toggleComponent/index.tsx index 81a2b2d8b..107e65b20 100644 --- a/src/frontend/src/components/toggleComponent/index.tsx +++ b/src/frontend/src/components/toggleComponent/index.tsx @@ -1,7 +1,7 @@ import { Switch } from "@headlessui/react"; import { useEffect } from "react"; import { ToggleComponentType } from "../../types/components"; -import { classNames } from "../../utils"; +import { classNames } from "../../utils/utils"; export default function ToggleComponent({ enabled, diff --git a/src/frontend/src/components/ui/accordion.tsx b/src/frontend/src/components/ui/accordion.tsx index 4b5a12384..ced816cfc 100644 --- a/src/frontend/src/components/ui/accordion.tsx +++ b/src/frontend/src/components/ui/accordion.tsx @@ -3,7 +3,7 @@ import * as AccordionPrimitive from "@radix-ui/react-accordion"; import { ChevronDownIcon } from "@radix-ui/react-icons"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const Accordion = AccordionPrimitive.Root; diff --git a/src/frontend/src/components/ui/badge.tsx b/src/frontend/src/components/ui/badge.tsx index 5464f382e..c101e3114 100644 --- a/src/frontend/src/components/ui/badge.tsx +++ b/src/frontend/src/components/ui/badge.tsx @@ -1,6 +1,6 @@ import { cva, type VariantProps } from "class-variance-authority"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const badgeVariants = cva( "inline-flex items-center border rounded-full px-2.5 font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", diff --git a/src/frontend/src/components/ui/button.tsx b/src/frontend/src/components/ui/button.tsx index 170494927..becc8d5f1 100644 --- a/src/frontend/src/components/ui/button.tsx +++ b/src/frontend/src/components/ui/button.tsx @@ -1,7 +1,7 @@ import { Slot } from "@radix-ui/react-slot"; import { cva, type VariantProps } from "class-variance-authority"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const buttonVariants = cva( "inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-background", diff --git a/src/frontend/src/components/ui/card.tsx b/src/frontend/src/components/ui/card.tsx index 0c5863871..585a81a76 100644 --- a/src/frontend/src/components/ui/card.tsx +++ b/src/frontend/src/components/ui/card.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const Card = React.forwardRef< HTMLDivElement, diff --git a/src/frontend/src/components/ui/checkbox.tsx b/src/frontend/src/components/ui/checkbox.tsx index 18332b073..d2d42c1fc 100644 --- a/src/frontend/src/components/ui/checkbox.tsx +++ b/src/frontend/src/components/ui/checkbox.tsx @@ -3,7 +3,7 @@ import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; import { Check } from "lucide-react"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const Checkbox = React.forwardRef< React.ElementRef, diff --git a/src/frontend/src/components/ui/dialog.tsx b/src/frontend/src/components/ui/dialog.tsx index 2ad709f48..068d3a3bd 100644 --- a/src/frontend/src/components/ui/dialog.tsx +++ b/src/frontend/src/components/ui/dialog.tsx @@ -1,7 +1,7 @@ import * as DialogPrimitive from "@radix-ui/react-dialog"; import { X } from "lucide-react"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const Dialog = DialogPrimitive.Root; diff --git a/src/frontend/src/components/ui/dropdown-menu.tsx b/src/frontend/src/components/ui/dropdown-menu.tsx index 0e5468e6e..4d96cba70 100644 --- a/src/frontend/src/components/ui/dropdown-menu.tsx +++ b/src/frontend/src/components/ui/dropdown-menu.tsx @@ -3,7 +3,7 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; import { Check, ChevronRight, Circle } from "lucide-react"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const DropdownMenu = DropdownMenuPrimitive.Root; diff --git a/src/frontend/src/components/ui/input.tsx b/src/frontend/src/components/ui/input.tsx index f3a8757e8..a59b419f3 100644 --- a/src/frontend/src/components/ui/input.tsx +++ b/src/frontend/src/components/ui/input.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; export interface InputProps extends React.InputHTMLAttributes {} diff --git a/src/frontend/src/components/ui/label.tsx b/src/frontend/src/components/ui/label.tsx index 57fbc9d8a..f8d45c11d 100644 --- a/src/frontend/src/components/ui/label.tsx +++ b/src/frontend/src/components/ui/label.tsx @@ -3,7 +3,7 @@ import * as LabelPrimitive from "@radix-ui/react-label"; import { cva, type VariantProps } from "class-variance-authority"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const labelVariants = cva( "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" diff --git a/src/frontend/src/components/ui/menubar.tsx b/src/frontend/src/components/ui/menubar.tsx index 0a3362ca6..7ae83d576 100644 --- a/src/frontend/src/components/ui/menubar.tsx +++ b/src/frontend/src/components/ui/menubar.tsx @@ -4,7 +4,7 @@ import * as MenubarPrimitive from "@radix-ui/react-menubar"; import { Check, ChevronRight, Circle } from "lucide-react"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const MenubarMenu = MenubarPrimitive.Menu; diff --git a/src/frontend/src/components/ui/progress.tsx b/src/frontend/src/components/ui/progress.tsx index a08efeb52..c2afa8a4c 100644 --- a/src/frontend/src/components/ui/progress.tsx +++ b/src/frontend/src/components/ui/progress.tsx @@ -2,7 +2,7 @@ import * as ProgressPrimitive from "@radix-ui/react-progress"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const Progress = React.forwardRef< React.ElementRef, diff --git a/src/frontend/src/components/ui/rename-label.tsx b/src/frontend/src/components/ui/rename-label.tsx index e5fef11bf..81d3ce446 100644 --- a/src/frontend/src/components/ui/rename-label.tsx +++ b/src/frontend/src/components/ui/rename-label.tsx @@ -1,5 +1,5 @@ import { useEffect, useRef, useState } from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; export default function RenameLabel(props) { const [internalState, setInternalState] = useState(false); diff --git a/src/frontend/src/components/ui/separator.tsx b/src/frontend/src/components/ui/separator.tsx index 1fa0287d8..1fec6d2ca 100644 --- a/src/frontend/src/components/ui/separator.tsx +++ b/src/frontend/src/components/ui/separator.tsx @@ -2,7 +2,7 @@ import * as SeparatorPrimitive from "@radix-ui/react-separator"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const Separator = React.forwardRef< React.ElementRef, diff --git a/src/frontend/src/components/ui/switch.tsx b/src/frontend/src/components/ui/switch.tsx index 8ec7c3c80..0d4bc8224 100644 --- a/src/frontend/src/components/ui/switch.tsx +++ b/src/frontend/src/components/ui/switch.tsx @@ -2,7 +2,7 @@ import * as SwitchPrimitives from "@radix-ui/react-switch"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const Switch = React.forwardRef< React.ElementRef, diff --git a/src/frontend/src/components/ui/table.tsx b/src/frontend/src/components/ui/table.tsx index 9b7bdd8ce..80a74f378 100644 --- a/src/frontend/src/components/ui/table.tsx +++ b/src/frontend/src/components/ui/table.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const Table = React.forwardRef< HTMLTableElement, diff --git a/src/frontend/src/components/ui/tabs.tsx b/src/frontend/src/components/ui/tabs.tsx index 8c382e35e..1a5d42254 100644 --- a/src/frontend/src/components/ui/tabs.tsx +++ b/src/frontend/src/components/ui/tabs.tsx @@ -2,7 +2,7 @@ import * as TabsPrimitive from "@radix-ui/react-tabs"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const Tabs = TabsPrimitive.Root; diff --git a/src/frontend/src/components/ui/textarea.tsx b/src/frontend/src/components/ui/textarea.tsx index fc0cda2ff..64aec41a1 100644 --- a/src/frontend/src/components/ui/textarea.tsx +++ b/src/frontend/src/components/ui/textarea.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; export interface TextareaProps extends React.TextareaHTMLAttributes {} diff --git a/src/frontend/src/components/ui/tooltip.tsx b/src/frontend/src/components/ui/tooltip.tsx index 6bb983652..c54245a53 100644 --- a/src/frontend/src/components/ui/tooltip.tsx +++ b/src/frontend/src/components/ui/tooltip.tsx @@ -2,7 +2,7 @@ import * as TooltipPrimitive from "@radix-ui/react-tooltip"; import * as React from "react"; -import { cn } from "../../utils"; +import { cn } from "../../utils/utils"; const TooltipProvider = TooltipPrimitive.Provider; diff --git a/src/frontend/src/constants.ts b/src/frontend/src/constants.ts index c642f09f7..a814c6efb 100644 --- a/src/frontend/src/constants.ts +++ b/src/frontend/src/constants.ts @@ -4,8 +4,8 @@ import { MessageSquare } from "lucide-react"; import { IVarHighlightType } from "./types/components"; import { FlowType } from "./types/flow"; import { TabsState } from "./types/tabs"; -import { buildInputs } from "./utils"; import { buildTweaks } from "./utils/reactflowUtils"; +import { buildInputs } from "./utils/utils"; /** * constants fpr programming languages box on chat form diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index bbd77007d..dc87ab3aa 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -20,8 +20,8 @@ import { import { APIClassType, APITemplateType } from "../types/api"; import { FlowType, NodeType } from "../types/flow"; import { TabsContextType, TabsState } from "../types/tabs"; -import { getRandomDescription, getRandomName } from "../utils"; import { updateIds, updateTemplate } from "../utils/reactflowUtils"; +import { getRandomDescription, getRandomName } from "../utils/utils"; import { alertContext } from "./alertContext"; import { typesContext } from "./typesContext"; diff --git a/src/frontend/src/modals/ApiModal/index.tsx b/src/frontend/src/modals/ApiModal/index.tsx index f6902f663..e5338ca16 100644 --- a/src/frontend/src/modals/ApiModal/index.tsx +++ b/src/frontend/src/modals/ApiModal/index.tsx @@ -51,8 +51,8 @@ import { import { darkContext } from "../../contexts/darkContext"; import { TabsContext } from "../../contexts/tabsContext"; import { FlowType } from "../../types/flow/index"; -import { classNames } from "../../utils"; import { buildTweaks } from "../../utils/reactflowUtils"; +import { classNames } from "../../utils/utils"; export default function ApiModal({ flow }: { flow: FlowType }) { const [open, setOpen] = useState(true); const { dark } = useContext(darkContext); diff --git a/src/frontend/src/modals/EditNodeModal/index.tsx b/src/frontend/src/modals/EditNodeModal/index.tsx index 18afc0df3..6606f3483 100644 --- a/src/frontend/src/modals/EditNodeModal/index.tsx +++ b/src/frontend/src/modals/EditNodeModal/index.tsx @@ -34,7 +34,7 @@ import { PopUpContext } from "../../contexts/popUpContext"; import { TabsContext } from "../../contexts/tabsContext"; import { typesContext } from "../../contexts/typesContext"; import { NodeDataType } from "../../types/flow"; -import { classNames } from "../../utils"; +import { classNames } from "../../utils/utils"; export default function EditNodeModal({ data }: { data: NodeDataType }) { const [open, setOpen] = useState(true); diff --git a/src/frontend/src/modals/NodeModal/components/ModalField/index.tsx b/src/frontend/src/modals/NodeModal/components/ModalField/index.tsx index ad82d0c0d..15c0984ea 100644 --- a/src/frontend/src/modals/NodeModal/components/ModalField/index.tsx +++ b/src/frontend/src/modals/NodeModal/components/ModalField/index.tsx @@ -9,7 +9,7 @@ import IntComponent from "../../../../components/intComponent"; import PromptAreaComponent from "../../../../components/promptComponent"; import TextAreaComponent from "../../../../components/textAreaComponent"; import ToggleComponent from "../../../../components/toggleComponent"; -import { classNames } from "../../../../utils"; +import { classNames } from "../../../../utils/utils"; export default function ModalField({ data, diff --git a/src/frontend/src/modals/NodeModal/index.tsx b/src/frontend/src/modals/NodeModal/index.tsx index 2446f1148..a686cf338 100644 --- a/src/frontend/src/modals/NodeModal/index.tsx +++ b/src/frontend/src/modals/NodeModal/index.tsx @@ -5,8 +5,8 @@ import { limitScrollFieldsModal } from "../../constants"; import { PopUpContext } from "../../contexts/popUpContext"; import { typesContext } from "../../contexts/typesContext"; import { NodeDataType } from "../../types/flow"; -import { classNames, toTitleCase } from "../../utils"; import { nodeColors, nodeIconsLucide } from "../../utils/styleUtils"; +import { classNames, toTitleCase } from "../../utils/utils"; import ModalField from "./components/ModalField"; export default function NodeModal({ data }: { data: NodeDataType }) { diff --git a/src/frontend/src/modals/formModal/chatInput/index.tsx b/src/frontend/src/modals/formModal/chatInput/index.tsx index ec62c0505..0340c1cfd 100644 --- a/src/frontend/src/modals/formModal/chatInput/index.tsx +++ b/src/frontend/src/modals/formModal/chatInput/index.tsx @@ -1,6 +1,6 @@ import { Lock, LucideSend, Sparkles } from "lucide-react"; import { useEffect } from "react"; -import { classNames } from "../../../utils"; +import { classNames } from "../../../utils/utils"; export default function ChatInput({ lockChat, diff --git a/src/frontend/src/modals/formModal/chatMessage/index.tsx b/src/frontend/src/modals/formModal/chatMessage/index.tsx index 953aed530..a460fec93 100644 --- a/src/frontend/src/modals/formModal/chatMessage/index.tsx +++ b/src/frontend/src/modals/formModal/chatMessage/index.tsx @@ -10,7 +10,7 @@ import Robot from "../../../assets/robot.png"; import SanitizedHTMLWrapper from "../../../components/SanitizedHTMLWrapper"; import { THOUGHTS_ICON } from "../../../constants"; import { ChatMessageType } from "../../../types/chat"; -import { classNames } from "../../../utils"; +import { classNames } from "../../../utils/utils"; import FileCard from "../fileComponent"; import { CodeBlock } from "./codeBlock"; export default function ChatMessage({ diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx index 6bcd1a331..4dc78e376 100644 --- a/src/frontend/src/modals/formModal/index.tsx +++ b/src/frontend/src/modals/formModal/index.tsx @@ -5,7 +5,7 @@ import { typesContext } from "../../contexts/typesContext"; import { sendAllProps } from "../../types/api"; import { ChatMessageType } from "../../types/chat"; import { FlowType } from "../../types/flow"; -import { classNames } from "../../utils"; +import { classNames } from "../../utils/utils"; import ChatInput from "./chatInput"; import ChatMessage from "./chatMessage"; diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index a53ce1218..e73d5d3a0 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -20,7 +20,7 @@ import { darkContext } from "../../contexts/darkContext"; import { PopUpContext } from "../../contexts/popUpContext"; import { postValidatePrompt } from "../../controllers/API"; import { APIClassType } from "../../types/api"; -import { classNames, getRandomKeyByssmm } from "../../utils"; +import { classNames, getRandomKeyByssmm } from "../../utils/utils"; import BaseModal from "../baseModal"; export default function GenericModal({ diff --git a/src/frontend/src/modals/importModal/buttonBox/index.tsx b/src/frontend/src/modals/importModal/buttonBox/index.tsx index a1116a8d4..0a998d56e 100644 --- a/src/frontend/src/modals/importModal/buttonBox/index.tsx +++ b/src/frontend/src/modals/importModal/buttonBox/index.tsx @@ -1,5 +1,5 @@ import { ReactNode } from "react"; -import { classNames } from "../../../utils"; +import { classNames } from "../../../utils/utils"; export default function ButtonBox({ onClick, diff --git a/src/frontend/src/modals/importModal/index.tsx b/src/frontend/src/modals/importModal/index.tsx index 4302fd9d8..ded17f5d9 100644 --- a/src/frontend/src/modals/importModal/index.tsx +++ b/src/frontend/src/modals/importModal/index.tsx @@ -21,7 +21,7 @@ import { PopUpContext } from "../../contexts/popUpContext"; import { TabsContext } from "../../contexts/tabsContext"; import { getExamples } from "../../controllers/API"; import { FlowType } from "../../types/flow"; -import { classNames } from "../../utils"; +import { classNames } from "../../utils/utils"; import ButtonBox from "./buttonBox"; export default function ImportModal() { diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index 883777f29..0fcf7d0fa 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -9,12 +9,12 @@ import { typesContext } from "../../../../contexts/typesContext"; import ApiModal from "../../../../modals/ApiModal"; import ExportModal from "../../../../modals/exportModal"; import { APIClassType, APIObjectType } from "../../../../types/api"; -import { classNames } from "../../../../utils"; import { nodeColors, nodeIconsLucide, nodeNames, } from "../../../../utils/styleUtils"; +import { classNames } from "../../../../utils/utils"; import DisclosureComponent from "../DisclosureComponent"; export default function ExtraSidebar() { diff --git a/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx index 0183dcb16..5fc250928 100644 --- a/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/nodeToolbarComponent/index.tsx @@ -4,7 +4,7 @@ import { useReactFlow } from "reactflow"; import ShadTooltip from "../../../../components/ShadTooltipComponent"; import { TabsContext } from "../../../../contexts/tabsContext"; import EditNodeModal from "../../../../modals/EditNodeModal"; -import { classNames } from "../../../../utils"; +import { classNames } from "../../../../utils/utils"; const NodeToolbarComponent = (props) => { const [nodeLength, setNodeLength] = useState( diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index b14a24c70..c4bec22c9 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -3,7 +3,7 @@ import { Connection, ReactFlowInstance } from "reactflow"; import { APITemplateType } from "../types/api"; import { FlowType, NodeType } from "../types/flow"; import { cleanEdgesType } from "../types/utils/reactflowUtils"; -import { toNormalCase } from "../utils"; +import { toNormalCase } from "./utils"; export function cleanEdges({ flow: { edges, nodes }, diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils/utils.ts similarity index 98% rename from src/frontend/src/utils.ts rename to src/frontend/src/utils/utils.ts index af83e83ff..37e35b643 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils/utils.ts @@ -1,6 +1,6 @@ import clsx, { ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; -import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./flow_constants"; +import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "../flow_constants"; export function classNames(...classes: Array) { return classes.filter(Boolean).join(" ");