🐛 fix(endpoints.py): skip processing empty custom_component_dict to prevent errors
🐛 fix(schemas.py): import field_validator from pydantic instead of Field 🐛 fix(base.py): return None if fields only contain _type key 🐛 fix(flow.py): set default value of description field to an empty string 🐛 fix(base.py): import validator from pydantic instead of field_validator 🐛 fix(conftest.py): change scope of client fixture to function and add autouse=True to ensure it runs for every test
This commit is contained in:
parent
2fe4b2ac44
commit
4345293a0a
6 changed files with 14 additions and 6 deletions
|
|
@ -59,6 +59,8 @@ def get_all():
|
|||
logger.info(f"Loading {len(custom_component_dicts)} category(ies)")
|
||||
for custom_component_dict in custom_component_dicts:
|
||||
# custom_component_dict is a dict of dicts
|
||||
if not custom_component_dict:
|
||||
continue
|
||||
category = list(custom_component_dict.keys())[0]
|
||||
logger.info(
|
||||
f"Loading {len(custom_component_dict[category])} component(s) from category {category}"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from enum import Enum
|
|||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from langflow.services.database.models.flow import FlowCreate, FlowRead
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
import json
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -136,10 +136,15 @@ class ToolCreator(LangChainTypeCreator):
|
|||
tool_dict = build_template_from_class(tool_type, OTHER_TOOLS)
|
||||
fields = tool_dict["template"]
|
||||
|
||||
# _type is the only key in fields
|
||||
# return None
|
||||
if len(fields) == 1 and "_type" in fields:
|
||||
return None
|
||||
|
||||
# Pop unnecessary fields and add name
|
||||
fields.pop("_type") # type: ignore
|
||||
fields.pop("return_direct") # type: ignore
|
||||
fields.pop("verbose") # type: ignore
|
||||
fields.pop("return_direct", None) # type: ignore
|
||||
fields.pop("verbose", None) # type: ignore
|
||||
|
||||
tool_params = {
|
||||
"name": fields.pop("name")["value"], # type: ignore
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@ from langflow.services.database.models.base import SQLModelSerializable
|
|||
from sqlmodel import Field, JSON, Column
|
||||
from uuid import UUID, uuid4
|
||||
from typing import Dict, Optional
|
||||
from pydantic import field_validator
|
||||
|
||||
# if TYPE_CHECKING:
|
||||
|
||||
|
||||
class FlowBase(SQLModelSerializable):
|
||||
name: str = Field(index=True)
|
||||
description: Optional[str] = Field(index=True)
|
||||
description: Optional[str] = Field(index=True, default="")
|
||||
data: Optional[Dict] = Field(default=None)
|
||||
|
||||
@field_validator("data")
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from pathlib import Path
|
|||
|
||||
import yaml
|
||||
from pydantic_settings import SettingsConfigDict, BaseSettings
|
||||
from pydantic import field_validator
|
||||
from pydantic import field_validator, validator
|
||||
from langflow.utils.logger import logger
|
||||
|
||||
# BASE_COMPONENTS_PATH = str(Path(__file__).parent / "components")
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ def session_fixture():
|
|||
yield session
|
||||
|
||||
|
||||
@pytest.fixture(name="client")
|
||||
@pytest.fixture(name="client", scope="function", autouse=True)
|
||||
def client_fixture(session: Session):
|
||||
def get_session_override():
|
||||
return session
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue