fixed combobox and formatting

This commit is contained in:
Lucas Oliveira 2023-11-16 10:47:58 -03:00
commit 4d0baef491
7 changed files with 16 additions and 35 deletions

View file

@ -122,9 +122,7 @@ class FileLoaderComponent(CustomComponent):
beta = True beta = True
def build_config(self): def build_config(self):
loader_options = ["Automatic"] + [ loader_options = ["Automatic"] + [loader_info["name"] for loader_info in loaders_info]
loader_info["name"] for loader_info in loaders_info
]
file_types = [] file_types = []
suffixes = [] suffixes = []
@ -214,9 +212,7 @@ class FileLoaderComponent(CustomComponent):
if isinstance(selected_loader_info, dict): if isinstance(selected_loader_info, dict):
loader_import: str = selected_loader_info["import"] loader_import: str = selected_loader_info["import"]
else: else:
raise ValueError( raise ValueError(f"Loader info for {loader} is not a dict\nLoader info:\n{selected_loader_info}")
f"Loader info for {loader} is not a dict\nLoader info:\n{selected_loader_info}"
)
module_name, class_name = loader_import.rsplit(".", 1) module_name, class_name = loader_import.rsplit(".", 1)
try: try:
@ -224,9 +220,7 @@ class FileLoaderComponent(CustomComponent):
loader_module = __import__(module_name, fromlist=[class_name]) loader_module = __import__(module_name, fromlist=[class_name])
loader_instance = getattr(loader_module, class_name) loader_instance = getattr(loader_module, class_name)
except ImportError as e: except ImportError as e:
raise ValueError( raise ValueError(f"Loader {loader} could not be imported\nLoader info:\n{selected_loader_info}") from e
f"Loader {loader} could not be imported\nLoader info:\n{selected_loader_info}"
) from e
result = loader_instance(file_path=file_path) result = loader_instance(file_path=file_path)
return result.load() return result.load()

View file

@ -14,9 +14,7 @@ class PostgresqlVectorComponent(CustomComponent):
display_name: str = "PGVector" display_name: str = "PGVector"
description: str = "Implementation of Vector Store using PostgreSQL" description: str = "Implementation of Vector Store using PostgreSQL"
documentation = ( documentation = "https://python.langchain.com/docs/integrations/vectorstores/pgvector"
"https://python.langchain.com/docs/integrations/vectorstores/pgvector"
)
beta = True beta = True
def build_config(self): def build_config(self):

View file

@ -4,9 +4,7 @@ from loguru import logger
from uuid import UUID from uuid import UUID
def build_sorted_vertices( def build_sorted_vertices(data_graph, user_id: Optional[Union[str, UUID]] = None) -> Tuple[Graph, Dict]:
data_graph, user_id: Optional[Union[str, UUID]] = None
) -> Tuple[Graph, Dict]:
""" """
Build langchain object from data_graph. Build langchain object from data_graph.
""" """

View file

@ -203,9 +203,7 @@ def update_attributes(frontend_node, template_config):
frontend_node[attribute] = template_config[attribute] frontend_node[attribute] = template_config[attribute]
def build_field_config( def build_field_config(custom_component: CustomComponent, user_id: Optional[Union[str, UUID]] = None):
custom_component: CustomComponent, user_id: Optional[Union[str, UUID]] = None
):
"""Build the field configuration for a custom component""" """Build the field configuration for a custom component"""
try: try:

View file

@ -138,9 +138,7 @@ class Settings(BaseSettings):
logger.debug(f"Components path: {value}") logger.debug(f"Components path: {value}")
return value return value
model_config = SettingsConfigDict( model_config = SettingsConfigDict(validate_assignment=True, extra="ignore", env_prefix="LANGFLOW_")
validate_assignment=True, extra="ignore", env_prefix="LANGFLOW_"
)
# @model_validator() # @model_validator()
# @classmethod # @classmethod

View file

@ -39,9 +39,7 @@ class Settings(BaseSettings):
@validator("DATABASE_URL", pre=True) @validator("DATABASE_URL", pre=True)
def set_database_url(cls, value): def set_database_url(cls, value):
if not value: if not value:
logger.debug( logger.debug("No database_url provided, trying LANGFLOW_DATABASE_URL env variable")
"No database_url provided, trying LANGFLOW_DATABASE_URL env variable"
)
if langflow_database_url := os.getenv("LANGFLOW_DATABASE_URL"): if langflow_database_url := os.getenv("LANGFLOW_DATABASE_URL"):
value = langflow_database_url value = langflow_database_url
logger.debug("Using LANGFLOW_DATABASE_URL env variable.") logger.debug("Using LANGFLOW_DATABASE_URL env variable.")
@ -56,22 +54,15 @@ class Settings(BaseSettings):
if os.getenv("LANGFLOW_COMPONENTS_PATH"): if os.getenv("LANGFLOW_COMPONENTS_PATH"):
logger.debug("Adding LANGFLOW_COMPONENTS_PATH to components_path") logger.debug("Adding LANGFLOW_COMPONENTS_PATH to components_path")
langflow_component_path = os.getenv("LANGFLOW_COMPONENTS_PATH") langflow_component_path = os.getenv("LANGFLOW_COMPONENTS_PATH")
if ( if Path(langflow_component_path).exists() and langflow_component_path not in value:
Path(langflow_component_path).exists()
and langflow_component_path not in value
):
if isinstance(langflow_component_path, list): if isinstance(langflow_component_path, list):
for path in langflow_component_path: for path in langflow_component_path:
if path not in value: if path not in value:
value.append(path) value.append(path)
logger.debug( logger.debug(f"Extending {langflow_component_path} to components_path")
f"Extending {langflow_component_path} to components_path"
)
elif langflow_component_path not in value: elif langflow_component_path not in value:
value.append(langflow_component_path) value.append(langflow_component_path)
logger.debug( logger.debug(f"Appending {langflow_component_path} to components_path")
f"Appending {langflow_component_path} to components_path"
)
if not value: if not value:
value = [BASE_COMPONENTS_PATH] value = [BASE_COMPONENTS_PATH]

View file

@ -18,11 +18,15 @@ export function Combobox({
onChange, onChange,
}: { }: {
items: { value: string; label: string }[]; items: { value: string; label: string }[];
onChange: (value: string) => void; onChange: (value: string[]) => void;
}) { }) {
const [open, setOpen] = React.useState(false); const [open, setOpen] = React.useState(false);
const [value, setValue] = React.useState<string[]>([]); const [value, setValue] = React.useState<string[]>([]);
React.useEffect(() => {
onChange(value);
}, [value]);
return ( return (
<Popover open={open} onOpenChange={setOpen}> <Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild> <PopoverTrigger asChild>