diff --git a/src/backend/langflow/api/v1/chat.py b/src/backend/langflow/api/v1/chat.py index fff0ff221..206d591fa 100644 --- a/src/backend/langflow/api/v1/chat.py +++ b/src/backend/langflow/api/v1/chat.py @@ -124,7 +124,7 @@ async def build_vertex( artifacts = vertex.artifacts else: raise ValueError(f"No result found for vertex {vertex_id}") - + next_vertices_ids = vertex.successors_ids result_data_response = ResultDataResponse(**result_dict.model_dump()) except Exception as exc: @@ -160,6 +160,13 @@ async def build_vertex( graph.reset_inactive_vertices() chat_service.set_cache(flow_id, graph) + # graph.stop_vertex tells us if the user asked + # to stop the build of the graph at a certain vertex + # if it is in next_vertices_ids, we need to remove other + # vertices from next_vertices_ids + if graph.stop_vertex and graph.stop_vertex in next_vertices_ids: + next_vertices_ids = [graph.stop_vertex] + build_response = VertexBuildResponse( next_vertices_ids=next_vertices_ids, inactive_vertices=inactive_vertices,