Fix logging level and version display
This commit is contained in:
parent
66123b3217
commit
d98410f90c
6 changed files with 27 additions and 19 deletions
|
|
@ -149,13 +149,13 @@ def run(
|
||||||
Run the Langflow.
|
Run the Langflow.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
configure(log_level=log_level, log_file=log_file)
|
||||||
set_var_for_macos_issue()
|
set_var_for_macos_issue()
|
||||||
# override env variables with .env file
|
# override env variables with .env file
|
||||||
|
|
||||||
if env_file:
|
if env_file:
|
||||||
load_dotenv(env_file, override=True)
|
load_dotenv(env_file, override=True)
|
||||||
|
|
||||||
configure(log_level=log_level, log_file=log_file)
|
|
||||||
update_settings(
|
update_settings(
|
||||||
config,
|
config,
|
||||||
dev=dev,
|
dev=dev,
|
||||||
|
|
@ -246,10 +246,10 @@ def get_free_port(port):
|
||||||
|
|
||||||
|
|
||||||
def print_banner(host, port):
|
def print_banner(host, port):
|
||||||
# console = Console()
|
from langflow.version import __version__
|
||||||
|
|
||||||
word = "Langflow"
|
word = "Langflow"
|
||||||
colors = ["#3300cc"]
|
colors = ["#6e42f5"]
|
||||||
|
|
||||||
styled_word = ""
|
styled_word = ""
|
||||||
|
|
||||||
|
|
@ -259,7 +259,7 @@ def print_banner(host, port):
|
||||||
|
|
||||||
# Title with emojis and gradient text
|
# Title with emojis and gradient text
|
||||||
title = (
|
title = (
|
||||||
f"[bold]Welcome to :chains: {styled_word} [/bold]\n\n"
|
f"[bold]Welcome to :chains: {styled_word} v{__version__}[/bold]\n"
|
||||||
f"Access [link=http://{host}:{port}]http://{host}:{port}[/link]"
|
f"Access [link=http://{host}:{port}]http://{host}:{port}[/link]"
|
||||||
)
|
)
|
||||||
info_text = (
|
info_text = (
|
||||||
|
|
@ -307,7 +307,7 @@ def run_langflow(host, port, log_level, options, app):
|
||||||
def superuser(
|
def superuser(
|
||||||
username: str = typer.Option(..., prompt=True, help="Username for the superuser."),
|
username: str = typer.Option(..., prompt=True, help="Username for the superuser."),
|
||||||
password: str = typer.Option(..., prompt=True, hide_input=True, help="Password for the superuser."),
|
password: str = typer.Option(..., prompt=True, hide_input=True, help="Password for the superuser."),
|
||||||
log_level: str = typer.Option("critical", help="Logging level.", envvar="LANGFLOW_LOG_LEVEL"),
|
log_level: str = typer.Option("error", help="Logging level.", envvar="LANGFLOW_LOG_LEVEL"),
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Create a superuser.
|
Create a superuser.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
import warnings
|
||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
|
|
||||||
from alembic import context
|
from alembic import context
|
||||||
|
|
@ -82,11 +83,12 @@ def run_migrations_online() -> None:
|
||||||
prefix="sqlalchemy.",
|
prefix="sqlalchemy.",
|
||||||
poolclass=pool.NullPool,
|
poolclass=pool.NullPool,
|
||||||
)
|
)
|
||||||
with connectable.connect() as connection:
|
with warnings.catch_warnings():
|
||||||
context.configure(connection=connection, target_metadata=target_metadata, render_as_batch=True)
|
warnings.simplefilter("ignore")
|
||||||
|
with connectable.connect() as connection:
|
||||||
with context.begin_transaction():
|
context.configure(connection=connection, target_metadata=target_metadata, render_as_batch=True)
|
||||||
context.run_migrations()
|
with context.begin_transaction():
|
||||||
|
context.run_migrations()
|
||||||
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
if context.is_offline_mode():
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import warnings
|
||||||
from typing import Callable, Dict, List, Optional
|
from typing import Callable, Dict, List, Optional
|
||||||
|
|
||||||
from langchain.agents import agent_toolkits
|
from langchain.agents import agent_toolkits
|
||||||
|
|
@ -29,13 +30,15 @@ class ToolkitCreator(LangChainTypeCreator):
|
||||||
@property
|
@property
|
||||||
def type_to_loader_dict(self) -> Dict:
|
def type_to_loader_dict(self) -> Dict:
|
||||||
if self.type_dict is None:
|
if self.type_dict is None:
|
||||||
settings_service = get_settings_service()
|
with warnings.catch_warnings():
|
||||||
self.type_dict = {
|
warnings.simplefilter("ignore")
|
||||||
toolkit_name: import_class(f"langchain.agents.agent_toolkits.{toolkit_name}")
|
settings_service = get_settings_service()
|
||||||
# if toolkit_name is not lower case it is a class
|
self.type_dict = {
|
||||||
for toolkit_name in agent_toolkits.__all__
|
toolkit_name: import_class(f"langchain.agents.agent_toolkits.{toolkit_name}")
|
||||||
if not toolkit_name.islower() and toolkit_name in settings_service.settings.TOOLKITS
|
# if toolkit_name is not lower case it is a class
|
||||||
}
|
for toolkit_name in agent_toolkits.__all__
|
||||||
|
if not toolkit_name.islower() and toolkit_name in settings_service.settings.TOOLKITS
|
||||||
|
}
|
||||||
|
|
||||||
return self.type_dict
|
return self.type_dict
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ if __name__ == "__main__":
|
||||||
host="127.0.0.1",
|
host="127.0.0.1",
|
||||||
port=7860,
|
port=7860,
|
||||||
workers=get_number_of_workers(),
|
workers=get_number_of_workers(),
|
||||||
log_level="debug",
|
log_level="error",
|
||||||
reload=True,
|
reload=True,
|
||||||
loop="asyncio",
|
loop="asyncio",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import os
|
||||||
|
|
||||||
from gunicorn.app.base import BaseApplication # type: ignore
|
from gunicorn.app.base import BaseApplication # type: ignore
|
||||||
from uvicorn.workers import UvicornWorker
|
from uvicorn.workers import UvicornWorker
|
||||||
|
|
||||||
|
|
@ -11,6 +13,7 @@ class LangflowApplication(BaseApplication):
|
||||||
self.options = options or {}
|
self.options = options or {}
|
||||||
|
|
||||||
self.options["worker_class"] = "langflow.server.LangflowUvicornWorker"
|
self.options["worker_class"] = "langflow.server.LangflowUvicornWorker"
|
||||||
|
self.options["loglevel"] = os.getenv("LANGFLOW_LOG_LEVEL", "error").lower()
|
||||||
self.application = app
|
self.application = app
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ def configure(log_level: Optional[str] = None, log_file: Optional[Path] = None):
|
||||||
if os.getenv("LANGFLOW_LOG_LEVEL", "").upper() in VALID_LOG_LEVELS and log_level is None:
|
if os.getenv("LANGFLOW_LOG_LEVEL", "").upper() in VALID_LOG_LEVELS and log_level is None:
|
||||||
log_level = os.getenv("LANGFLOW_LOG_LEVEL")
|
log_level = os.getenv("LANGFLOW_LOG_LEVEL")
|
||||||
if log_level is None:
|
if log_level is None:
|
||||||
log_level = "INFO"
|
log_level = "ERROR"
|
||||||
# Human-readable
|
# Human-readable
|
||||||
log_format = (
|
log_format = (
|
||||||
"<green>{time:YYYY-MM-DD HH:mm:ss}</green> - <level>"
|
"<green>{time:YYYY-MM-DD HH:mm:ss}</green> - <level>"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue