From eb94b957b5075260bb5aaa50d8b903e87df270c3 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 25 Jul 2023 11:46:57 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(endpoints.py):=20fix=20mergi?= =?UTF-8?q?ng=20of=20custom=20component=20dictionaries=20from=20multiple?= =?UTF-8?q?=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✨ feat(endpoints.py): add support for merging custom component dictionaries from multiple paths to build the final dictionary of all components --- src/backend/langflow/api/v1/endpoints.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/backend/langflow/api/v1/endpoints.py b/src/backend/langflow/api/v1/endpoints.py index 2c5a486b5..af8772757 100644 --- a/src/backend/langflow/api/v1/endpoints.py +++ b/src/backend/langflow/api/v1/endpoints.py @@ -48,14 +48,18 @@ def merge_nested_dicts(dict1, dict2): def get_all(): native_components = build_langchain_types_dict() + # custom_components is a list of dicts + # need to merge all the keys into one dict + custom_components_from_file = {} 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 = {} - + custom_component_dicts = [ + build_langchain_custom_component_list_from_path(str(path)) + for path in settings.component_path + ] + for custom_component_dict in custom_component_dicts: + custom_components_from_file = merge_nested_dicts( + custom_components_from_file, custom_component_dict + ) return merge_nested_dicts(native_components, custom_components_from_file)