From c195456c49a3b7f48af4c8f8cb9315ae516f1f79 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 18 Aug 2023 08:56:58 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(base.py):=20update=20debug?= =?UTF-8?q?=20log=20message=20to=20provide=20more=20meaningful=20informati?= =?UTF-8?q?on=20about=20the=20number=20of=20vertices=20in=20the=20graph=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(run.py):=20comment=20out=20the=20caching=20f?= =?UTF-8?q?unctionality=20for=20building=20sorted=20vertices=20to=20preven?= =?UTF-8?q?t=20caching=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/graph/graph/base.py | 2 +- src/backend/langflow/interface/run.py | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/graph/graph/base.py b/src/backend/langflow/graph/graph/base.py index f0d3986cf..d5225c489 100644 --- a/src/backend/langflow/graph/graph/base.py +++ b/src/backend/langflow/graph/graph/base.py @@ -147,7 +147,7 @@ class Graph: def generator_build(self) -> Generator: """Builds each vertex in the graph and yields it.""" sorted_vertices = self.topological_sort() - logger.debug("Sorted vertices: %s", sorted_vertices) + logger.debug("There are %s vertices in the graph", len(sorted_vertices)) yield from sorted_vertices def get_node_neighbors(self, node: Vertex) -> Dict[Vertex, int]: diff --git a/src/backend/langflow/interface/run.py b/src/backend/langflow/interface/run.py index 7b7a16b69..04e5df046 100644 --- a/src/backend/langflow/interface/run.py +++ b/src/backend/langflow/interface/run.py @@ -16,8 +16,8 @@ def build_langchain_object_with_caching(data_graph): return graph.build() -@Memoize(get_cache_manager=get_cache_manager) -def build_sorted_vertices_with_caching(data_graph) -> Tuple[Any, Dict]: +# @Memoize(get_cache_manager=get_cache_manager) +def build_sorted_vertices(data_graph) -> Tuple[Any, Dict]: """ Build langchain object from data_graph. """ @@ -32,6 +32,23 @@ def build_sorted_vertices_with_caching(data_graph) -> Tuple[Any, Dict]: artifacts.update(vertex.artifacts) return graph.build(), artifacts + # def build_sorted_vertices_with_caching(data_graph): + # # Build the result if not in cache + # logger.debug("Building langchain object") + # graph = Graph.from_payload(data_graph) + # sorted_vertices = graph.topological_sort() + # artifacts = {} + # for vertex in sorted_vertices: + # vertex.build() + # if vertex.artifacts: + # artifacts.update(vertex.artifacts) + # result = (graph.build(), artifacts) + + # Save to cache + # cache_manager.set(session_id, result) + + # return result + def build_langchain_object(data_graph): """