From ede745c1ddc36b27e8298e3ce598467369b63f50 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 27 Sep 2023 08:54:11 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(custom=5Fcomponent.py):=20im?= =?UTF-8?q?prove=20error=20message=20formatting=20for=20type=20hint=20erro?= =?UTF-8?q?r=20in=20build=20method=20=F0=9F=90=9B=20fix(logger.py):=20fix?= =?UTF-8?q?=20conditional=20statement=20for=20log=5Flevel=20configuration?= =?UTF-8?q?=20to=20properly=20handle=20None=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/interface/custom/custom_component.py | 5 ++++- src/backend/langflow/utils/logger.py | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/backend/langflow/interface/custom/custom_component.py b/src/backend/langflow/interface/custom/custom_component.py index b0c4f8752..ccc0b08b2 100644 --- a/src/backend/langflow/interface/custom/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component.py @@ -102,7 +102,10 @@ class CustomComponent(Component, extra=Extra.allow): status_code=400, detail={ "error": "Type hint Error", - "traceback": "Prompt type is not supported in the build method. Try using PromptTemplate instead.", + "traceback": ( + "Prompt type is not supported in the build method." + " Try using PromptTemplate instead." + ), }, ) return args diff --git a/src/backend/langflow/utils/logger.py b/src/backend/langflow/utils/logger.py index e49fa4bfd..ebc468e7e 100644 --- a/src/backend/langflow/utils/logger.py +++ b/src/backend/langflow/utils/logger.py @@ -1,3 +1,4 @@ +from math import log from typing import Optional from loguru import logger from pathlib import Path @@ -25,12 +26,15 @@ def patching(record): def configure(log_level: Optional[str] = None, log_file: Optional[Path] = None): - if os.getenv("LANGFLOW_LOG_LEVEL") in VALID_LOG_LEVELS and not log_level: + if os.getenv("LANGFLOW_LOG_LEVEL") in VALID_LOG_LEVELS and log_level is None: log_level = os.getenv("LANGFLOW_LOG_LEVEL") - elif not log_level: + if log_level is None: log_level = "INFO" # Human-readable - log_format = "{time:YYYY-MM-DD HH:mm:ss} - {level: <8} - {module} - {message}" + log_format = ( + "{time:YYYY-MM-DD HH:mm:ss} - " + "{level: <8} - {module} - {message}" + ) # log_format = log_format_dev if log_level.upper() == "DEBUG" else log_format_prod logger.remove() # Remove default handlers