From 70f98f91508221ddddbfb07e2589b783e0f7df03 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 22 Aug 2023 16:12:30 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(custom=5Fcomponent.py):=20ex?= =?UTF-8?q?tract=20inner=20type=20from=20return=20type=20if=20it=20starts?= =?UTF-8?q?=20with=20'list'=20or=20'List'=20to=20handle=20list=20types=20c?= =?UTF-8?q?orrectly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/custom/custom_component.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/langflow/interface/custom/custom_component.py b/src/backend/langflow/interface/custom/custom_component.py index 4151f056d..e8747eac3 100644 --- a/src/backend/langflow/interface/custom/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component.py @@ -3,6 +3,7 @@ from fastapi import HTTPException from langflow.interface.custom.constants import CUSTOM_COMPONENT_SUPPORTED_TYPES from langflow.interface.custom.component import Component from langflow.interface.custom.directory_reader import DirectoryReader +from langflow.interface.custom.utils import extract_inner_type from langflow.utils import validate @@ -122,6 +123,10 @@ class CustomComponent(Component, extra=Extra.allow): return_type = build_method["return_type"] if not return_type: return [] + # If list or List is in the return type, then we remove it and return the inner type + if return_type.startswith("list") or return_type.startswith("List"): + return_type = extract_inner_type(return_type) + # If the return type is not a Union, then we just return it as a list if "Union" not in return_type: return [return_type] if return_type in self.return_type_valid_list else []