From e7e364be38a7512441f74c689bb1650c27cd7803 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 14 Dec 2023 09:32:45 -0300 Subject: [PATCH] Add custom component classes and methods --- .../interface/custom/custom_component/__init__.py | 3 +++ .../custom/{ => custom_component}/component.py | 0 .../{ => custom_component}/custom_component.py | 14 +++++++------- 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 src/backend/langflow/interface/custom/custom_component/__init__.py rename src/backend/langflow/interface/custom/{ => custom_component}/component.py (100%) rename src/backend/langflow/interface/custom/{ => custom_component}/custom_component.py (97%) diff --git a/src/backend/langflow/interface/custom/custom_component/__init__.py b/src/backend/langflow/interface/custom/custom_component/__init__.py new file mode 100644 index 000000000..295992f60 --- /dev/null +++ b/src/backend/langflow/interface/custom/custom_component/__init__.py @@ -0,0 +1,3 @@ +from .custom_component import CustomComponent + +__all__ = ["CustomComponent"] diff --git a/src/backend/langflow/interface/custom/component.py b/src/backend/langflow/interface/custom/custom_component/component.py similarity index 100% rename from src/backend/langflow/interface/custom/component.py rename to src/backend/langflow/interface/custom/custom_component/component.py diff --git a/src/backend/langflow/interface/custom/custom_component.py b/src/backend/langflow/interface/custom/custom_component/custom_component.py similarity index 97% rename from src/backend/langflow/interface/custom/custom_component.py rename to src/backend/langflow/interface/custom/custom_component/custom_component.py index 948618d66..b60ced196 100644 --- a/src/backend/langflow/interface/custom/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component/custom_component.py @@ -1,22 +1,21 @@ import operator from typing import Any, Callable, ClassVar, List, Optional, Union from uuid import UUID -from langflow.interface.custom.code_parser.utils import extract_inner_type_from_generic_alias import yaml from cachetools import TTLCache, cachedmethod from fastapi import HTTPException - -from langflow.interface.custom.component import Component -from langflow.interface.custom.directory_reader import DirectoryReader from langflow.interface.custom.code_parser.utils import ( - extract_union_types_from_generic_alias, -) + extract_inner_type_from_generic_alias, + extract_union_types_from_generic_alias) +from langflow.interface.custom.directory_reader import DirectoryReader from langflow.services.database.models.flow import Flow from langflow.services.database.utils import session_getter from langflow.services.deps import get_credential_service, get_db_service from langflow.utils import validate +from .component import Component + class CustomComponent(Component): display_name: Optional[str] = None @@ -218,7 +217,8 @@ class CustomComponent(Component): return validate.create_function(self.code, self.function_entrypoint_name) async def load_flow(self, flow_id: str, tweaks: Optional[dict] = None) -> Any: - from langflow.processing.process import build_sorted_vertices, process_tweaks + from langflow.processing.process import (build_sorted_vertices, + process_tweaks) db_service = get_db_service() with session_getter(db_service) as session: