diff --git a/src/backend/base/langflow/api/v1/chat.py b/src/backend/base/langflow/api/v1/chat.py index 27e8191d6..9dd911ca4 100644 --- a/src/backend/base/langflow/api/v1/chat.py +++ b/src/backend/base/langflow/api/v1/chat.py @@ -295,18 +295,12 @@ async def build_vertex_stream( async def stream_vertex(): try: - if not session_id: - cache = await chat_service.get_cache(flow_id_str) - if not cache: - # If there's no cache - raise ValueError(f"No cache found for {flow_id_str}.") - else: - graph = cache.get("result") + cache = await chat_service.get_cache(flow_id_str) + if not cache: + # If there's no cache + raise ValueError(f"No cache found for {flow_id_str}.") else: - session_data = await session_service.load_session(session_id, flow_id=flow_id_str) - graph, artifacts = session_data if session_data else (None, None) - if not graph: - raise ValueError(f"No graph found for {flow_id_str}.") + graph = cache.get("result") vertex: "InterfaceVertex" = graph.get_vertex(vertex_id) if not hasattr(vertex, "stream"): diff --git a/src/backend/base/langflow/graph/graph/base.py b/src/backend/base/langflow/graph/graph/base.py index 7ddfcafae..16dee5d95 100644 --- a/src/backend/base/langflow/graph/graph/base.py +++ b/src/backend/base/langflow/graph/graph/base.py @@ -290,6 +290,12 @@ class Graph: raise ValueError(f"Vertex {vertex_id} not found") vertex.update_raw_params({"session_id": session_id}) # Process the graph + try: + cache_service = get_chat_service() + await cache_service.set_cache(self.flow_id, self) + except Exception as exc: + logger.exception(exc) + try: start_component_id = next( (vertex_id for vertex_id in self._is_input_vertices if "chat" in vertex_id.lower()), None