🐛 fix(__main__.py): rename component_path to components_path for consistency and clarity
✨ feat(__main__.py): add support for components_path command line option to specify the directory containing custom components 🐛 fix(endpoints.py): rename settings.component_path to settings.components_path to match the updated attribute name in Settings class 🐛 fix(settings.py): rename component_path attribute to components_path for consistency and clarity
This commit is contained in:
parent
af083f24d3
commit
a2ce598e08
3 changed files with 16 additions and 16 deletions
|
|
@ -27,7 +27,7 @@ def update_settings(
|
|||
dev: bool = False,
|
||||
database_url: Optional[str] = None,
|
||||
remove_api_keys: bool = False,
|
||||
component_path: Optional[Path] = None,
|
||||
components_path: Optional[Path] = None,
|
||||
):
|
||||
"""Update the settings from a config file."""
|
||||
|
||||
|
|
@ -45,9 +45,9 @@ def update_settings(
|
|||
if cache:
|
||||
logger.debug(f"Setting cache to {cache}")
|
||||
settings.update_settings(cache=cache)
|
||||
if component_path:
|
||||
logger.debug(f"Adding component path {component_path}")
|
||||
settings.update_settings(component_path=component_path)
|
||||
if components_path:
|
||||
logger.debug(f"Adding component path {components_path}")
|
||||
settings.update_settings(components_path=components_path)
|
||||
|
||||
|
||||
def load_params():
|
||||
|
|
@ -126,7 +126,7 @@ def serve(
|
|||
),
|
||||
timeout: int = typer.Option(300, help="Worker timeout in seconds."),
|
||||
port: int = typer.Option(7860, help="Port to listen on.", envvar="LANGFLOW_PORT"),
|
||||
component_path: Optional[Path] = typer.Option(
|
||||
components_path: Optional[Path] = typer.Option(
|
||||
Path(__file__).parent,
|
||||
help="Path to the directory containing custom components.",
|
||||
envvar="LANGFLOW_COMPONENT_PATH",
|
||||
|
|
@ -188,7 +188,7 @@ def serve(
|
|||
database_url=database_url,
|
||||
remove_api_keys=remove_api_keys,
|
||||
cache=cache,
|
||||
component_path=component_path,
|
||||
components_path=components_path,
|
||||
)
|
||||
# create path object if path is provided
|
||||
static_files_dir: Optional[Path] = Path(path) if path else None
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ def get_all():
|
|||
# custom_components is a list of dicts
|
||||
# need to merge all the keys into one dict
|
||||
custom_components_from_file = {}
|
||||
if settings.component_path:
|
||||
if settings.components_path:
|
||||
custom_component_dicts = [
|
||||
build_langchain_custom_component_list_from_path(str(path))
|
||||
for path in settings.component_path
|
||||
for path in settings.components_path
|
||||
]
|
||||
for custom_component_dict in custom_component_dicts:
|
||||
custom_components_from_file = merge_nested_dicts(
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class Settings(BaseSettings):
|
|||
database_url: Optional[str] = None
|
||||
cache: str = "InMemoryCache"
|
||||
remove_api_keys: bool = False
|
||||
component_path: List[Path]
|
||||
components_path: List[Path]
|
||||
|
||||
@root_validator(pre=True)
|
||||
def set_env_variables(cls, values):
|
||||
|
|
@ -45,18 +45,18 @@ class Settings(BaseSettings):
|
|||
logger.debug("No DATABASE_URL env variable, using sqlite database")
|
||||
values["database_url"] = "sqlite:///./langflow.db"
|
||||
|
||||
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 not values.get("components_path"):
|
||||
values["components_path"] = [BASE_COMPONENTS_PATH]
|
||||
elif BASE_COMPONENTS_PATH not in values["components_path"]:
|
||||
values["components_path"].append(BASE_COMPONENTS_PATH)
|
||||
|
||||
if 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"]
|
||||
and langflow_component_path not in values["components_path"]
|
||||
):
|
||||
values["component_path"].append(langflow_component_path)
|
||||
values["components_path"].append(langflow_component_path)
|
||||
return values
|
||||
|
||||
class Config:
|
||||
|
|
@ -88,7 +88,7 @@ class Settings(BaseSettings):
|
|||
self.retrievers = new_settings.retrievers or {}
|
||||
self.output_parsers = new_settings.output_parsers or {}
|
||||
self.custom_components = new_settings.custom_components or {}
|
||||
self.component_path = new_settings.component_path or []
|
||||
self.components_path = new_settings.components_path or []
|
||||
self.dev = dev
|
||||
|
||||
def update_settings(self, **kwargs):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue