diff --git a/src/backend/langflow/interface/types.py b/src/backend/langflow/interface/types.py index 6708c11c9..5f29dbf2e 100644 --- a/src/backend/langflow/interface/types.py +++ b/src/backend/langflow/interface/types.py @@ -288,6 +288,24 @@ def add_base_classes(frontend_node, return_types: List[str]): frontend_node.get("base_classes").append(base_class) +def add_output_types(frontend_node, return_types: List[str]): + """Add output types to the frontend node""" + for return_type in return_types: + if return_type not in CUSTOM_COMPONENT_SUPPORTED_TYPES or return_type is None: + raise HTTPException( + status_code=400, + detail={ + "error": ( + "Invalid return type should be one of: " + f"{list(CUSTOM_COMPONENT_SUPPORTED_TYPES.keys())}" + ), + "traceback": traceback.format_exc(), + }, + ) + + frontend_node.get("output_types").append(return_type) + + def build_langchain_template_custom_component(custom_component: CustomComponent): """Build a custom component template for the langchain""" try: @@ -314,6 +332,9 @@ def build_langchain_template_custom_component(custom_component: CustomComponent) add_base_classes( frontend_node, custom_component.get_function_entrypoint_return_type ) + add_output_types( + frontend_node, custom_component.get_function_entrypoint_return_type + ) logger.debug("Added base classes") return frontend_node except Exception as exc: