From 2b454dc645d3a49f119409c87265890c404ac25c Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 19 Sep 2023 15:27:12 -0300 Subject: [PATCH] Formatting --- src/backend/langflow/interface/run.py | 5 ++-- src/frontend/src/constants/constants.ts | 1 - src/frontend/src/types/components/index.ts | 24 ++++++++--------- src/frontend/src/utils/reactflowUtils.ts | 30 +++++++++++++++------- src/frontend/src/utils/styleUtils.ts | 4 +-- 5 files changed, 37 insertions(+), 27 deletions(-) diff --git a/src/backend/langflow/interface/run.py b/src/backend/langflow/interface/run.py index 1aff2f0e2..eb012e182 100644 --- a/src/backend/langflow/interface/run.py +++ b/src/backend/langflow/interface/run.py @@ -59,7 +59,7 @@ def get_memory_key(langchain_object): "history": "chat_history", } # Check if memory_key attribute exists - if hasattr(langchain_object.memory, 'memory_key'): + if hasattr(langchain_object.memory, "memory_key"): memory_key = langchain_object.memory.memory_key return mem_key_dict.get(memory_key) else: @@ -90,5 +90,4 @@ def update_memory_keys(langchain_object, possible_new_mem_key): try: setattr(langchain_object.memory, attr, key) except ValueError as exc: - logger.debug( - f"{langchain_object.memory} has no attribute {attr} ({exc})") + logger.debug(f"{langchain_object.memory} has no attribute {attr} ({exc})") diff --git a/src/frontend/src/constants/constants.ts b/src/frontend/src/constants/constants.ts index cd0eaac06..d6ba802ee 100644 --- a/src/frontend/src/constants/constants.ts +++ b/src/frontend/src/constants/constants.ts @@ -115,7 +115,6 @@ export const EDIT_DIALOG_SUBTITLE = export const CODE_PROMPT_DIALOG_SUBTITLE = "Edit your Python code. This code snippet accepts module import and a single function definition. Make sure that your function returns a string."; - export const CODE_DICT_DIALOG_SUBTITLE = "Edit your dictionary. This dialog allows you to create your own customized dictionary. You can add as many key-value pairs as you want. While in edit mode, you can enter ({}) or ([]), and this will result in adding a new object or array."; diff --git a/src/frontend/src/types/components/index.ts b/src/frontend/src/types/components/index.ts index e4339a041..1d0825f7f 100644 --- a/src/frontend/src/types/components/index.ts +++ b/src/frontend/src/types/components/index.ts @@ -123,18 +123,18 @@ export type TooltipComponentType = { children: ReactElement; title: string | ReactElement; placement?: - | "bottom-end" - | "bottom-start" - | "bottom" - | "left-end" - | "left-start" - | "left" - | "right-end" - | "right-start" - | "right" - | "top-end" - | "top-start" - | "top"; + | "bottom-end" + | "bottom-start" + | "bottom" + | "left-end" + | "left-start" + | "left" + | "right-end" + | "right-start" + | "right" + | "top-end" + | "top-start" + | "top"; }; export type ProgressBarType = { diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 108871bb1..df8c784c4 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -219,21 +219,34 @@ export function validateNode( edge.targetHandle.split("|")[2] === node.id ) ) { - errors.push(`${type} is missing ${template.display_name || toNormalCase(template[t].name)}.`); + errors.push( + `${type} is missing ${ + template.display_name || toNormalCase(template[t].name) + }.` + ); } else if ( - (template[t].type === "dict") && + template[t].type === "dict" && template[t].required && template[t].show && (template[t].value !== undefined || template[t].value !== null || template[t].value !== "") ) { - if (hasDuplicateKeys(template[t].value)) errors.push(`${type} (${template.display_name || template[t].name}) contains duplicate keys with the same values.`); - if (hasEmptyKey(template[t].value)) errors.push(`${type} (${template.display_name || template[t].name}) field must not be empty.`); + if (hasDuplicateKeys(template[t].value)) + errors.push( + `${type} (${ + template.display_name || template[t].name + }) contains duplicate keys with the same values.` + ); + if (hasEmptyKey(template[t].value)) + errors.push( + `${type} (${ + template.display_name || template[t].name + }) field must not be empty.` + ); } return errors; }, [] as string[]); - } export function validateNodes(reactFlowInstance: ReactFlowInstance) { @@ -299,7 +312,6 @@ export function getConnectedNodes( } export function convertObjToArray(singleObject) { - if (Array.isArray(singleObject)) return singleObject; let arrConverted: any = []; @@ -329,7 +341,7 @@ export function hasDuplicateKeys(array) { export function hasEmptyKey(objArray) { for (const obj of objArray) { for (const key in obj) { - if (obj.hasOwnProperty(key) && key === '') { + if (obj.hasOwnProperty(key) && key === "") { return true; // Found an empty key } } @@ -346,10 +358,10 @@ export function convertValuesToNumbers(arr) { if (/\s/g.test(value)) { value = value.trim(); } - newObj[key] = value === "" || isNaN(value) ? value.toString() : Number(value); + newObj[key] = + value === "" || isNaN(value) ? value.toString() : Number(value); } } return newObj; }); } - diff --git a/src/frontend/src/utils/styleUtils.ts b/src/frontend/src/utils/styleUtils.ts index f04e02df9..158ab9b36 100644 --- a/src/frontend/src/utils/styleUtils.ts +++ b/src/frontend/src/utils/styleUtils.ts @@ -1,6 +1,7 @@ import { ArrowUpToLine, Bell, + BookMarked, Check, CheckCircle2, ChevronDown, @@ -78,7 +79,6 @@ import { X, XCircle, Zap, - BookMarked } from "lucide-react"; import { FaApple, FaGithub } from "react-icons/fa"; import { AirbyteIcon } from "../icons/Airbyte"; @@ -309,5 +309,5 @@ export const nodeIconsLucide: iconsType = { Key, Unplug, BookMarked, - ChevronUp + ChevronUp, };