From 2183f167cd83cb73a6d829a50257c5d121d11bc5 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 18 Aug 2023 08:57:24 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(manager.py):=20add=20cache?= =?UTF-8?q?=5Fmanager.set()=20to=20store=20langchain=5Fobject=20in=20cache?= =?UTF-8?q?=20after=20successful=20initialization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 fix(celeryconfig.py): fix condition to check if BROKER_URL and RESULT_BACKEND are present in os.environ before using them, fallback to langflow_redis_host and langflow_redis_port if not present --- src/backend/langflow/chat/manager.py | 1 + src/backend/langflow/core/celeryconfig.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/langflow/chat/manager.py b/src/backend/langflow/chat/manager.py index b4ccd931e..17968e32a 100644 --- a/src/backend/langflow/chat/manager.py +++ b/src/backend/langflow/chat/manager.py @@ -135,6 +135,7 @@ class ChatManager: chat_inputs=chat_inputs, websocket=self.active_connections[client_id], ) + self.cache_manager.set(client_id, langchain_object) except Exception as e: # Log stack trace logger.exception(e) diff --git a/src/backend/langflow/core/celeryconfig.py b/src/backend/langflow/core/celeryconfig.py index d7827b713..6747135ae 100644 --- a/src/backend/langflow/core/celeryconfig.py +++ b/src/backend/langflow/core/celeryconfig.py @@ -3,11 +3,11 @@ import os langflow_redis_host = os.environ.get("LANGFLOW_REDIS_HOST") langflow_redis_port = os.environ.get("LANGFLOW_REDIS_PORT") -if langflow_redis_host and langflow_redis_port: - broker_url = f"redis://{langflow_redis_host}:{langflow_redis_port}/0" - result_backend = f"redis://{langflow_redis_host}:{langflow_redis_port}/0" -else: +if "BROKER_URL" in os.environ and "RESULT_BACKEND" in os.environ: broker_url = os.environ.get("BROKER_URL", "redis://localhost:6379/0") result_backend = os.environ.get("RESULT_BACKEND", "redis://localhost:6379/0") +elif langflow_redis_host and langflow_redis_port: + broker_url = f"redis://{langflow_redis_host}:{langflow_redis_port}/0" + result_backend = f"redis://{langflow_redis_host}:{langflow_redis_port}/0" # tasks should be json or pickle accept_content = ["json", "pickle"]