From 887d1d8f7983ba32fad1c68ef8b769b9c9446af5 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Mon, 18 Sep 2023 09:28:24 -0300 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix(types.py):=20handle=20ex?= =?UTF-8?q?ceptions=20and=20raise=20HTTPException=20with=20detailed=20erro?= =?UTF-8?q?r=20message=20and=20traceback=20=F0=9F=90=9B=20fix(index.tsx):?= =?UTF-8?q?=20fix=20error=20detail=20access=20in=20className=20condition?= =?UTF-8?q?=20=F0=9F=90=9B=20fix(classes.css):=20adjust=20scrollbar=20styl?= =?UTF-8?q?es=20for=20Ace=20editor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/types.py | 59 +++++++++++-------- .../src/modals/codeAreaModal/index.tsx | 10 ++-- src/frontend/src/style/classes.css | 20 ++++++- 3 files changed, 59 insertions(+), 30 deletions(-) diff --git a/src/backend/langflow/interface/types.py b/src/backend/langflow/interface/types.py index e558a3e0c..30f56b46e 100644 --- a/src/backend/langflow/interface/types.py +++ b/src/backend/langflow/interface/types.py @@ -289,32 +289,43 @@ def add_base_classes(frontend_node, return_types: List[str]): def build_langchain_template_custom_component(custom_component: CustomComponent): - """Build a custom component template for the langchain""" - logger.debug("Building custom component template") - frontend_node = build_frontend_node(custom_component) + try: + """Build a custom component template for the langchain""" + logger.debug("Building custom component template") + frontend_node = build_frontend_node(custom_component) - if frontend_node is None: - return None - logger.debug("Built base frontend node") - template_config = custom_component.build_template_config + if frontend_node is None: + return None + logger.debug("Built base frontend node") + template_config = custom_component.build_template_config - update_attributes(frontend_node, template_config) - logger.debug("Updated attributes") - field_config = build_field_config(custom_component) - logger.debug("Built field config") - add_extra_fields( - frontend_node, field_config, custom_component.get_function_entrypoint_args - ) - logger.debug("Added extra fields") - frontend_node = add_code_field( - frontend_node, custom_component.code, field_config.get("code", {}) - ) - logger.debug("Added code field") - add_base_classes( - frontend_node, custom_component.get_function_entrypoint_return_type - ) - logger.debug("Added base classes") - return frontend_node + update_attributes(frontend_node, template_config) + logger.debug("Updated attributes") + field_config = build_field_config(custom_component) + logger.debug("Built field config") + add_extra_fields( + frontend_node, field_config, custom_component.get_function_entrypoint_args + ) + logger.debug("Added extra fields") + frontend_node = add_code_field( + frontend_node, custom_component.code, field_config.get("code", {}) + ) + logger.debug("Added code field") + add_base_classes( + frontend_node, custom_component.get_function_entrypoint_return_type + ) + logger.debug("Added base classes") + return frontend_node + except Exception as e: + raise HTTPException( + status_code=400, + detail={ + "error": ( + "Invalid type convertion. Please check your code and try again." + ), + "traceback": traceback.format_exc(), + }, + ) def load_files_from_path(path: str): diff --git a/src/frontend/src/modals/codeAreaModal/index.tsx b/src/frontend/src/modals/codeAreaModal/index.tsx index 935ae2964..d44d1e2df 100644 --- a/src/frontend/src/modals/codeAreaModal/index.tsx +++ b/src/frontend/src/modals/codeAreaModal/index.tsx @@ -172,18 +172,18 @@ export default function CodeAreaModal({
-
+

{error?.detail?.error}

-
+                
                   {error?.detail?.traceback}
-                
+
diff --git a/src/frontend/src/style/classes.css b/src/frontend/src/style/classes.css index b6662e7bf..d5508f81c 100644 --- a/src/frontend/src/style/classes.css +++ b/src/frontend/src/style/classes.css @@ -29,10 +29,28 @@ pre { animation: slideUp 300ms ease-out; } - .gradient-end { animation: gradient-motion-end 3s infinite forwards; } .gradient-start { animation: gradient-motion-start 4s infinite forwards; } + +.ace_scrollbar::-webkit-scrollbar { + height: 8px; + width: 8px; +} + +.ace_scrollbar::-webkit-scrollbar-track { + background-color: #f1f1f1; +} + +.ace_scrollbar::-webkit-scrollbar-thumb { + background-color: #ccc; + border-radius: 999px; +} + +.ace_scrollbar::-webkit-scrollbar-thumb:hover { + background-color: #bbb; + border-radius: 999px; +} From 6500d793d15fe8d043c64146d7b35d52f06d9038 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 18 Sep 2023 10:39:29 -0300 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix(types.py):=20fix=20inden?= =?UTF-8?q?tation=20and=20remove=20duplicate=20docstring=20to=20improve=20?= =?UTF-8?q?code=20readability=20=F0=9F=94=A5=20chore(types.py):=20remove?= =?UTF-8?q?=20unused=20variable=20'e'=20and=20improve=20exception=20handli?= =?UTF-8?q?ng=20by=20adding=20'from=20exc'=20to=20preserve=20original=20tr?= =?UTF-8?q?aceback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/types.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/interface/types.py b/src/backend/langflow/interface/types.py index 30f56b46e..c43a22e01 100644 --- a/src/backend/langflow/interface/types.py +++ b/src/backend/langflow/interface/types.py @@ -289,8 +289,8 @@ def add_base_classes(frontend_node, return_types: List[str]): def build_langchain_template_custom_component(custom_component: CustomComponent): + """Build a custom component template for the langchain""" try: - """Build a custom component template for the langchain""" logger.debug("Building custom component template") frontend_node = build_frontend_node(custom_component) @@ -316,7 +316,7 @@ def build_langchain_template_custom_component(custom_component: CustomComponent) ) logger.debug("Added base classes") return frontend_node - except Exception as e: + except Exception as exc: raise HTTPException( status_code=400, detail={ @@ -325,7 +325,7 @@ def build_langchain_template_custom_component(custom_component: CustomComponent) ), "traceback": traceback.format_exc(), }, - ) + ) from exc def load_files_from_path(path: str):