From 5f56384dce10d327ea29c6ea35ed7417a8c7d028 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 25 Jun 2023 18:20:21 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20feat(=5F=5Fmain=5F=5F.py):=20add?= =?UTF-8?q?=20support=20for=20cache=20configuration=20The=20`update=5Fsett?= =?UTF-8?q?ings`=20function=20now=20accepts=20a=20`cache`=20parameter=20th?= =?UTF-8?q?at=20allows=20the=20user=20to=20specify=20the=20type=20of=20cac?= =?UTF-8?q?he=20to=20use.=20The=20`cache`=20parameter=20is=20set=20to=20a?= =?UTF-8?q?=20default=20value=20of=20`SQLiteCache`=20and=20can=20be=20over?= =?UTF-8?q?ridden=20by=20setting=20the=20`LANGCHAIN=5FCACHE`=20environment?= =?UTF-8?q?=20variable.=20This=20feature=20improves=20the=20flexibility=20?= =?UTF-8?q?of=20the=20application=20as=20it=20allows=20the=20user=20to=20c?= =?UTF-8?q?hoose=20the=20type=20of=20cache=20that=20best=20suits=20their?= =?UTF-8?q?=20needs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/__main__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index 29f60ed23..a3841ec93 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -30,6 +30,7 @@ def get_number_of_workers(workers=None): def update_settings( config: str, + cache: str, dev: bool = False, database_url: Optional[str] = None, remove_api_keys: bool = False, @@ -41,6 +42,8 @@ def update_settings( settings.update_settings(database_url=database_url) if remove_api_keys: settings.update_settings(remove_api_keys=remove_api_keys) + if cache: + settings.update_settings(cache=cache) def serve_on_jcloud(): @@ -102,6 +105,11 @@ def serve( ), log_level: str = typer.Option("critical", help="Logging level."), log_file: Path = typer.Option("logs/langflow.log", help="Path to the log file."), + cache: str = typer.Argument( + envvar="LANGCHAIN_CACHE", + help="Type of cache to use. (InMemoryCache, SQLiteCache)", + default="SQLiteCache", + ), jcloud: bool = typer.Option(False, help="Deploy on Jina AI Cloud"), dev: bool = typer.Option(False, help="Run in development mode (may contain bugs)"), database_url: str = typer.Option( @@ -130,7 +138,11 @@ def serve( configure(log_level=log_level, log_file=log_file) update_settings( - config, dev=dev, database_url=database_url, remove_api_keys=remove_api_keys + config, + dev=dev, + database_url=database_url, + remove_api_keys=remove_api_keys, + cache=cache, ) # get the directory of the current file if not path: