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 1/2] =?UTF-8?q?=F0=9F=94=80=20refactor(custom=5Fcomponent.?= =?UTF-8?q?py):=20rename=20`load=5Fflow`=20method=20parameter=20`flow=5Fid?= =?UTF-8?q?`=20to=20`graph=5Fid`=20for=20clarity=20=F0=9F=94=80=20refactor?= =?UTF-8?q?(custom=5Fcomponent.py):=20add=20optional=20`tweaks`=20paramete?= =?UTF-8?q?r=20to=20`load=5Fflow`=20method=20to=20allow=20for=20processing?= =?UTF-8?q?=20tweaks=20on=20the=20graph=20data=20=F0=9F=94=80=20refactor(c?= =?UTF-8?q?ustom=5Fcomponent.py):=20rename=20`data=5Fgraph`=20variable=20t?= =?UTF-8?q?o=20`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: From 4a0fe950936432bc3ccb37f274b69dc0d3fa8d8c Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 27 Jul 2023 09:44:01 -0300 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A7=20chore(types.py):=20add=20sup?= =?UTF-8?q?port=20for=20custom=20field=20value=20in=20add=5Fnew=5Fcustom?= =?UTF-8?q?=5Ffield=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 chore(types.py): add support for custom field value in add_new_custom_field function to allow specifying a default value for the field --- src/backend/langflow/interface/types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/langflow/interface/types.py b/src/backend/langflow/interface/types.py index 35ecd558b..e68a07b44 100644 --- a/src/backend/langflow/interface/types.py +++ b/src/backend/langflow/interface/types.py @@ -98,6 +98,7 @@ def add_new_custom_field( display_name = field_config.pop("display_name", field_name) field_type = field_config.pop("field_type", field_type) field_type = process_type(field_type) + field_value = field_config.pop("value", field_value) if "name" in field_config: warnings.warn(