From aebdfad63cf422167cb3b9377706b720eca7edef Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 25 Jul 2023 12:03:28 -0300 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=80=20chore(config.yaml):=20rename?= =?UTF-8?q?=20'custom'=20section=20to=20'custom=5Fcomponents'=20for=20bett?= =?UTF-8?q?er=20clarity=20and=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/langflow/config.yaml b/src/backend/langflow/config.yaml index 8934ff92f6..38d466c349 100644 --- a/src/backend/langflow/config.yaml +++ b/src/backend/langflow/config.yaml @@ -290,6 +290,6 @@ output_parsers: documentation: "https://python.langchain.com/docs/modules/model_io/output_parsers/structured" ResponseSchema: documentation: "https://python.langchain.com/docs/modules/model_io/output_parsers/structured" -custom: +custom_components: CustomComponent: documentation: "" From 0095fc4753f679401b31182b141e1c05cde35d90 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 25 Jul 2023 12:16:06 -0300 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A7=20chore(settings.py):=20add=20?= =?UTF-8?q?BASE=5FCOMPONENTS=5FPATH=20constant=20to=20improve=20code=20rea?= =?UTF-8?q?dability=20and=20maintainability=20=F0=9F=94=A7=20chore(setting?= =?UTF-8?q?s.py):=20add=20support=20for=20LANGFLOW=5FCOMPONENT=5FPATH=20en?= =?UTF-8?q?vironment=20variable=20to=20allow=20custom=20component=20paths?= =?UTF-8?q?=20to=20be=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/settings.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/settings.py b/src/backend/langflow/settings.py index 037f88149f..4743fae12d 100644 --- a/src/backend/langflow/settings.py +++ b/src/backend/langflow/settings.py @@ -6,6 +6,8 @@ import yaml from pydantic import BaseSettings, root_validator from langflow.utils.logger import logger +BASE_COMPONENTS_PATH = Path(__file__).parent / "components" + class Settings(BaseSettings): chains: dict = {} @@ -43,11 +45,18 @@ class Settings(BaseSettings): logger.debug("No DATABASE_URL env variable, using sqlite database") values["database_url"] = "sqlite:///./langflow.db" - values["component_path"] = [Path(__file__).parent / "components"] + if not values.get("component_path"): + values["component_path"] = [BASE_COMPONENTS_PATH] + elif BASE_COMPONENTS_PATH not in values["component_path"]: + values["component_path"].append(BASE_COMPONENTS_PATH) if os.getenv("LANGFLOW_COMPONENT_PATH"): - values["component_path"].append(Path(os.getenv("LANGFLOW_COMPONENT_PATH"))) - + langflow_component_path = Path(os.getenv("LANGFLOW_COMPONENT_PATH")) + if ( + langflow_component_path.exists() + and langflow_component_path not in values["component_path"] + ): + values["component_path"].append(langflow_component_path) return values class Config: