From 2513cbcdd94632b036ab0cc360a83b9d1e8d8d9a Mon Sep 17 00:00:00 2001 From: gustavoschaedler Date: Thu, 20 Jul 2023 18:35:53 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(custom=5Fcomponent.py):=20?= =?UTF-8?q?reformat=20code=20for=20better=20readability=20and=20maintainab?= =?UTF-8?q?ility=20=F0=9F=9A=80=20feat(custom=5Fcomponent.py):=20add=20`lo?= =?UTF-8?q?ad=5Fflow`=20method=20to=20load=20a=20flow=20from=20the=20datab?= =?UTF-8?q?ase=20using=20session=20and=20flow=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/interface/custom/custom_component.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/backend/langflow/interface/custom/custom_component.py b/src/backend/langflow/interface/custom/custom_component.py index 70036a0b2..144f9a60a 100644 --- a/src/backend/langflow/interface/custom/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component.py @@ -5,6 +5,12 @@ 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 + class CustomComponent(Component): code: Optional[str] @@ -126,5 +132,8 @@ 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 build(self): raise NotImplementedError