From fc2e6c112eb8a6a5390ced06d6bebcae7585af96 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 23 Jun 2023 09:28:25 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(chat.py):=20delete=20flow=20?= =?UTF-8?q?from=20cache=20if=20it=20already=20exists=20before=20initializi?= =?UTF-8?q?ng=20build=20The=20code=20now=20checks=20if=20the=20flow=20alre?= =?UTF-8?q?ady=20exists=20in=20the=20cache=20and=20deletes=20it=20before?= =?UTF-8?q?=20initializing=20the=20build.=20This=20ensures=20that=20the=20?= =?UTF-8?q?cache=20is=20always=20up=20to=20date=20and=20avoids=20any=20inc?= =?UTF-8?q?onsistencies=20that=20may=20arise=20from=20having=20outdated=20?= =?UTF-8?q?data=20in=20the=20cache.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/chat.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/langflow/api/v1/chat.py b/src/backend/langflow/api/v1/chat.py index 262defed6..ae9fb8b30 100644 --- a/src/backend/langflow/api/v1/chat.py +++ b/src/backend/langflow/api/v1/chat.py @@ -39,6 +39,11 @@ async def init_build(graph_data: dict): try: flow_id = graph_data.get("id") + # Delete from cache if already exists + if flow_id in chat_manager.in_memory_cache: + with chat_manager.in_memory_cache._lock: + chat_manager.in_memory_cache.delete(flow_id) + logger.debug(f"Deleted flow {flow_id} from cache") if flow_id is None: raise ValueError("No ID provided") flow_data_store[flow_id] = graph_data