From 2b55b0c3b3b5939f111c08c0e60057c79fe01cfa Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 27 Jul 2023 09:39:27 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20refactor(custom=5Fcomponent.py):?= =?UTF-8?q?=20rename=20`load=5Fflow`=20method=20parameter=20`flow=5Fid`=20?= =?UTF-8?q?to=20`graph=5Fid`=20for=20clarity=20=F0=9F=94=80=20refactor(cus?= =?UTF-8?q?tom=5Fcomponent.py):=20add=20optional=20`tweaks`=20parameter=20?= =?UTF-8?q?to=20`load=5Fflow`=20method=20to=20allow=20for=20processing=20t?= =?UTF-8?q?weaks=20on=20the=20graph=20data=20=F0=9F=94=80=20refactor(custo?= =?UTF-8?q?m=5Fcomponent.py):=20rename=20`data=5Fgraph`=20variable=20to=20?= =?UTF-8?q?`graph=5Fdata`=20for=20consistency=20and=20clarity=20?= =?UTF-8?q?=F0=9F=94=80=20refactor(custom=5Fcomponent.py):=20add=20logic?= =?UTF-8?q?=20to=20process=20tweaks=20on=20the=20`graph=5Fdata`=20if=20`tw?= =?UTF-8?q?eaks`=20parameter=20is=20provided?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/interface/custom/custom_component.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/backend/langflow/interface/custom/custom_component.py b/src/backend/langflow/interface/custom/custom_component.py index f58c9db19..9ade781c8 100644 --- a/src/backend/langflow/interface/custom/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component.py @@ -141,14 +141,17 @@ class CustomComponent(Component, extra=Extra.allow): def get_function(self): return validate.create_function(self.code, self.function_entrypoint_name) - def load_flow(self, flow_id: str): + def load_flow(self, flow_id: str, tweaks: Optional[dict] = None): from langflow.processing.process import build_sorted_vertices_with_caching + from langflow.processing.process import process_tweaks with session_getter() as session: - data_graph = flow.data if (flow := session.get(Flow, flow_id)) else None - if not data_graph: + graph_data = flow.data if (flow := session.get(Flow, flow_id)) else None + if not graph_data: raise ValueError(f"Flow {flow_id} not found") - return build_sorted_vertices_with_caching(data_graph) + if tweaks: + graph_data = process_tweaks(graph_data=graph_data, tweaks=tweaks) + return build_sorted_vertices_with_caching(graph_data) def list_flows(self): with session_getter() as session: