From 5cfc78489b5b8c8e0f4f10c4bce8c945cb72e8b6 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 17 Sep 2024 12:22:29 -0300 Subject: [PATCH 1/4] Add run_id parameter to set run ID in graph within load_and_run_flow function --- src/backend/base/langflow/helpers/flow.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend/base/langflow/helpers/flow.py b/src/backend/base/langflow/helpers/flow.py index b753620c5de..f18886be494 100644 --- a/src/backend/base/langflow/helpers/flow.py +++ b/src/backend/base/langflow/helpers/flow.py @@ -74,10 +74,13 @@ async def run_flow( flow_name: Optional[str] = None, output_type: Optional[str] = "chat", user_id: Optional[str] = None, + run_id: Optional[str] = None, ) -> List[RunOutputs]: if user_id is None: raise ValueError("Session is invalid") graph = await load_flow(user_id, flow_id, flow_name, tweaks) + if run_id: + graph.set_run_id(run_id) if inputs is None: inputs = [] From 7134fe5fa1d8d205c9c6aa9b87aed7f1a4ff5469 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 17 Sep 2024 12:22:35 -0300 Subject: [PATCH 2/4] Add run_id parameter to run_flow call in FlowTool for tracking runs --- src/backend/base/langflow/base/tools/flow_tool.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/base/langflow/base/tools/flow_tool.py b/src/backend/base/langflow/base/tools/flow_tool.py index 03936ac5839..298228b9c4e 100644 --- a/src/backend/base/langflow/base/tools/flow_tool.py +++ b/src/backend/base/langflow/base/tools/flow_tool.py @@ -95,10 +95,12 @@ async def _arun( ) -> str: """Use the tool asynchronously.""" tweaks = self.build_tweaks_dict(args, kwargs) + run_id = self.graph.run_id if self.graph else None run_outputs = await run_flow( tweaks={key: {"input_value": value} for key, value in tweaks.items()}, flow_id=self.flow_id, user_id=self.user_id, + run_id=run_id, ) if not run_outputs: return "No output" From c79af189e5788c00e010959e5d8669696b71f341 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 17 Sep 2024 12:23:16 -0300 Subject: [PATCH 3/4] Add run_id parameter to CustomComponent's run_flow method --- .../base/langflow/custom/custom_component/custom_component.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/base/langflow/custom/custom_component/custom_component.py b/src/backend/base/langflow/custom/custom_component/custom_component.py index a6c5836b1cb..781e24a0a2f 100644 --- a/src/backend/base/langflow/custom/custom_component/custom_component.py +++ b/src/backend/base/langflow/custom/custom_component/custom_component.py @@ -484,6 +484,7 @@ async def run_flow( flow_name=flow_name, tweaks=tweaks, user_id=str(self._user_id), + run_id=self.graph.run_id, ) def list_flows(self) -> list[Data]: From 4b34174988f9e5dbf6d0e1597e8aeffd03f41952 Mon Sep 17 00:00:00 2001 From: italojohnny Date: Tue, 17 Sep 2024 13:11:31 -0300 Subject: [PATCH 4/4] fix: mypy error arg-type --- src/backend/base/langflow/helpers/flow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/base/langflow/helpers/flow.py b/src/backend/base/langflow/helpers/flow.py index f18886be494..89530504d26 100644 --- a/src/backend/base/langflow/helpers/flow.py +++ b/src/backend/base/langflow/helpers/flow.py @@ -80,7 +80,7 @@ async def run_flow( raise ValueError("Session is invalid") graph = await load_flow(user_id, flow_id, flow_name, tweaks) if run_id: - graph.set_run_id(run_id) + graph.set_run_id(UUID(run_id)) if inputs is None: inputs = []