From e84aca717b356f1c4d780dced1c94a675be4bd75 Mon Sep 17 00:00:00 2001 From: gustavoschaedler Date: Fri, 21 Jul 2023 22:32:54 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20chore(endpoints.py):=20move=20me?= =?UTF-8?q?rge=5Fnested=5Fdicts=20function=20to=20correct=20local=20scope?= =?UTF-8?q?=20=F0=9F=90=9B=20fix(endpoints.py):=20fix=20get=5Fall=20endpoi?= =?UTF-8?q?nt=20to=20correctly=20merge=20native=5Fcomponents=20and=20custo?= =?UTF-8?q?m=5Fcomponents=5Ffrom=5Ffile=20dictionaries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/endpoints.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/api/v1/endpoints.py b/src/backend/langflow/api/v1/endpoints.py index 79eb90ac3..618c9777b 100644 --- a/src/backend/langflow/api/v1/endpoints.py +++ b/src/backend/langflow/api/v1/endpoints.py @@ -34,18 +34,29 @@ from sqlmodel import Session router = APIRouter(tags=["Base"]) +# TODO: Move to correct local +def merge_nested_dicts(dict1, dict2): + for key, value in dict2.items(): + if isinstance(value, dict) and isinstance(dict1.get(key), dict): + dict1[key] = merge_nested_dicts(dict1[key], value) + else: + dict1[key] = value + return dict1 + + @router.get("/all") def get_all(): native_components = build_langchain_types_dict() if settings.component_path: + # TODO: Iterate in a list of component_path custom_components_from_file = build_langchain_custom_component_list_from_path( str(settings.component_path[0]) ) else: custom_components_from_file = {} - return {**native_components, **custom_components_from_file} + return merge_nested_dicts(native_components, custom_components_from_file) @router.get("/load_custom_component_from_path")