From eb7158ad26cf330c599f0d1ece185ab7077ede9e Mon Sep 17 00:00:00 2001 From: gustavoschaedler Date: Thu, 20 Jul 2023 18:56:46 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20refactor(custom=5Fcomponent.py):?= =?UTF-8?q?=20remove=20unused=20imports=20and=20unused=20load=5Fflow=20met?= =?UTF-8?q?hod=20parameters=20for=20better=20code=20cleanliness=20?= =?UTF-8?q?=F0=9F=94=A8=20refactor(custom=5Fcomponent.py):=20update=20load?= =?UTF-8?q?=5Fflow=20method=20to=20use=20the=20process=5Fflow=20function?= =?UTF-8?q?=20from=20the=20api=20endpoints=20module=20for=20improved=20mod?= =?UTF-8?q?ularity=20and=20separation=20of=20concerns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/interface/custom/custom_component.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/backend/langflow/interface/custom/custom_component.py b/src/backend/langflow/interface/custom/custom_component.py index 144f9a60a..0501d5570 100644 --- a/src/backend/langflow/interface/custom/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component.py @@ -5,11 +5,7 @@ from langflow.interface.custom.component import Component from langflow.utils import validate -from uuid import UUID -from sqlmodel import Session -from fastapi import Depends, HTTPException -from langflow.database.base import get_session -from langflow.database.models.flow import Flow +from langflow.api.v1.endpoints import process_flow class CustomComponent(Component): @@ -132,8 +128,10 @@ class CustomComponent(Component): def get_function(self): return validate.create_function(self.code, self.function_entrypoint_name) - def load_flow(self, session: Session = Depends(get_session), flow_id: UUID = None): - return flow if (flow := session.get(Flow, flow_id)) else "Flow not found" + def load_flow( + self, flow_id: str, inputs: Optional[dict] = None, tweaks: Optional[dict] = None + ): + return process_flow(flow_id, inputs, tweaks) def build(self): raise NotImplementedError