From 70b634cbcff2eae3de50fbb9069ce9d2034cd95b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 5 Jul 2023 13:07:02 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(=5F=5Fmain=5F=5F.py):=20re?= =?UTF-8?q?factor=20serve=20function=20to=20use=20environment=20variables?= =?UTF-8?q?=20for=20configuration=20options=20=F0=9F=8C=9F=20feat(=5F=5Fma?= =?UTF-8?q?in=5F=5F.py):=20add=20support=20for=20environment=20variables?= =?UTF-8?q?=20to=20configure=20serve=20function=20The=20serve=20function?= =?UTF-8?q?=20in=20=5F=5Fmain=5F=5F.py=20has=20been=20refactored=20to=20us?= =?UTF-8?q?e=20environment=20variables=20for=20configuration=20options.=20?= =?UTF-8?q?The=20following=20configuration=20options=20now=20support=20env?= =?UTF-8?q?ironment=20variables:=20host,=20workers,=20port,=20log=5Flevel,?= =?UTF-8?q?=20log=5Ffile,=20path,=20open=5Fbrowser,=20and=20remove=5Fapi?= =?UTF-8?q?=5Fkeys.=20This=20change=20allows=20for=20greater=20flexibility?= =?UTF-8?q?=20and=20easier=20configuration=20of=20the=20serve=20function?= =?UTF-8?q?=20by=20using=20environment=20variables=20instead=20of=20comman?= =?UTF-8?q?d=20line=20options.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/__main__.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/backend/langflow/__main__.py b/src/backend/langflow/__main__.py index 2780ff09e..15005585c 100644 --- a/src/backend/langflow/__main__.py +++ b/src/backend/langflow/__main__.py @@ -96,17 +96,25 @@ def serve_on_jcloud(): @app.command() def serve( - host: str = typer.Option("127.0.0.1", help="Host to bind the server to."), - workers: int = typer.Option(1, help="Number of worker processes."), + host: str = typer.Option( + "127.0.0.1", help="Host to bind the server to.", envvar="LANGFLOW_HOST" + ), + workers: int = typer.Option( + 1, help="Number of worker processes.", envvar="LANGFLOW_WORKERS" + ), timeout: int = typer.Option(60, help="Worker timeout in seconds."), - port: int = typer.Option(7860, help="Port to listen on."), + port: int = typer.Option(7860, help="Port to listen on.", envvar="LANGFLOW_PORT"), config: str = typer.Option("config.yaml", help="Path to the configuration file."), # .env file param env_file: Path = typer.Option( ".env", help="Path to the .env file containing environment variables." ), - log_level: str = typer.Option("critical", help="Logging level."), - log_file: Path = typer.Option("logs/langflow.log", help="Path to the log file."), + log_level: str = typer.Option( + "critical", help="Logging level.", envvar="LANGFLOW_LOG_LEVEL" + ), + log_file: Path = typer.Option( + "logs/langflow.log", help="Path to the log file.", envvar="LANGFLOW_LOG_FILE" + ), cache: str = typer.Option( envvar="LANGFLOW_LANGCHAIN_CACHE", help="Type of cache to use. (InMemoryCache, SQLiteCache)", @@ -122,12 +130,17 @@ def serve( path: str = typer.Option( None, help="Path to the frontend directory containing build files. This is for development purposes only.", + envvar="LANGFLOW_FRONTEND_PATH", ), open_browser: bool = typer.Option( - True, help="Open the browser after starting the server." + True, + help="Open the browser after starting the server.", + envvar="LANGFLOW_OPEN_BROWSER", ), remove_api_keys: bool = typer.Option( - False, help="Remove API keys from the projects saved in the database." + False, + help="Remove API keys from the projects saved in the database.", + envvar="LANGFLOW_REMOVE_API_KEYS", ), ): """