🔧 chore(settings.py): change save_api_keys to remove_api_keys to improve semantics

The `save_api_keys` variable has been renamed to `remove_api_keys` to improve the semantics of the code. The new variable name better reflects the functionality of the code, which is to remove API keys from the projects saved in the database.
🔧 chore(__main__.py): change save_api_keys to remove_api_keys to improve semantics
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-15 19:29:29 -03:00
commit 2addbf2e0c
3 changed files with 9 additions and 10 deletions

View file

@ -31,15 +31,15 @@ def update_settings(
config: str,
dev: bool = False,
database_url: Optional[str] = None,
save_api_keys: bool = True,
remove_api_keys: bool = False,
):
"""Update the settings from a config file."""
if config:
settings.update_from_yaml(config, dev=dev)
if database_url:
settings.update_settings(database_url=database_url)
if save_api_keys:
settings.update_settings(save_api_keys=save_api_keys)
if remove_api_keys:
settings.update_settings(remove_api_keys=remove_api_keys)
def serve_on_jcloud():
@ -114,8 +114,8 @@ def serve(
open_browser: bool = typer.Option(
True, help="Open the browser after starting the server."
),
save_api_keys: bool = typer.Option(
True, help="Save API keys in your projects for future use."
remove_api_keys: bool = typer.Option(
False, help="Remove API keys from the projects saved in the database."
),
):
"""
@ -143,7 +143,7 @@ def serve(
configure(log_level=log_level, log_file=log_file)
update_settings(
config, dev=dev, database_url=database_url, save_api_keys=save_api_keys
config, dev=dev, database_url=database_url, remove_api_keys=remove_api_keys
)
app = create_app()
# get the directory of the current file

View file

@ -1,6 +1,6 @@
from typing import List
from uuid import UUID
from langflow import settings
from langflow.settings import settings
from langflow.api.utils import remove_api_keys
from langflow.api.v1.schemas import FlowListCreate, FlowListRead
from langflow.database.models.flow import (
@ -61,7 +61,7 @@ def update_flow(
if not db_flow:
raise HTTPException(status_code=404, detail="Flow not found")
flow_data = flow.dict(exclude_unset=True)
if settings.save_api_keys:
if not settings.remove_api_keys:
flow_data = remove_api_keys(flow_data)
for key, value in flow_data.items():
setattr(db_flow, key, value)

View file

@ -21,7 +21,7 @@ class Settings(BaseSettings):
utilities: List[str] = []
dev: bool = False
database_url: str = "sqlite:///./langflow.db"
save_api_keys: bool = True
remove_api_keys: bool = False
class Config:
validate_assignment = True
@ -48,7 +48,6 @@ class Settings(BaseSettings):
self.textsplitters = new_settings.textsplitters or []
self.utilities = new_settings.utilities or []
self.dev = dev
self.save_api_keys = new_settings.save_api_keys
def update_settings(self, **kwargs):
for key, value in kwargs.items():