🔧 fix(base.py): update debug log message to provide more meaningful information about the number of vertices in the graph

🔧 fix(run.py): comment out the caching functionality for building sorted vertices to prevent caching issues
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-18 08:56:58 -03:00
commit c195456c49
2 changed files with 20 additions and 3 deletions

View file

@ -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]:

View file

@ -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):
"""