From 912683009faf3bcbe3adab441bdd7cb0864fea0c Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 22 Jul 2024 14:23:29 -0300 Subject: [PATCH] fix: add correct id to vertices_being_run and change condition to end traces (#2872) * fix: add correct vertex id to vertices_being_run * fix: update condition for ending all traces in build_vertex function --- src/backend/base/langflow/api/v1/chat.py | 2 +- src/backend/base/langflow/graph/graph/base.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/base/langflow/api/v1/chat.py b/src/backend/base/langflow/api/v1/chat.py index 285321658..bdff3d88d 100644 --- a/src/backend/base/langflow/api/v1/chat.py +++ b/src/backend/base/langflow/api/v1/chat.py @@ -258,7 +258,7 @@ async def build_vertex( if graph.stop_vertex and graph.stop_vertex in next_runnable_vertices: next_runnable_vertices = [graph.stop_vertex] - if not graph.run_manager.vertices_to_run and not next_runnable_vertices: + if not graph.run_manager.vertices_being_run and not next_runnable_vertices: background_tasks.add_task(graph.end_all_traces) build_response = VertexBuildResponse( diff --git a/src/backend/base/langflow/graph/graph/base.py b/src/backend/base/langflow/graph/graph/base.py index 043088392..8a42f1cbb 100644 --- a/src/backend/base/langflow/graph/graph/base.py +++ b/src/backend/base/langflow/graph/graph/base.py @@ -998,11 +998,11 @@ class Graph: self.run_manager.remove_vertex_from_runnables(v_id) next_runnable_vertices = self.find_next_runnable_vertices(v_id, v_successors_ids) - for i in set(next_runnable_vertices): # Use set to avoid duplicates - if i == v_id: + for next_v_id in set(next_runnable_vertices): # Use set to avoid duplicates + if next_v_id == v_id: next_runnable_vertices.remove(v_id) else: - self.run_manager.add_to_vertices_being_run(v_id) + self.run_manager.add_to_vertices_being_run(next_v_id) if cache: set_cache_coro = partial(get_chat_service().set_cache, key=self.flow_id) await set_cache_coro(self, lock)