🐛 fix(manager.py): add cache_manager.set() to store langchain_object in cache after successful initialization

🐛 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
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-18 08:57:24 -03:00
commit 2183f167cd
2 changed files with 5 additions and 4 deletions

View file

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

View file

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