Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multiselect dropdown not visible #3044

Merged
merged 10 commits into from
Jul 29, 2024
7 changes: 2 additions & 5 deletions src/backend/base/langflow/inputs/input_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,14 @@ class RangeMixin(BaseModel):
class DropDownMixin(BaseModel):
options: Optional[list[str]] = None
"""List of options for the field. Only used when is_list=True. Default is an empty list."""
combobox: CoalesceBool = False
"""Variable that defines if the user can insert custom values in the dropdown."""


class MultilineMixin(BaseModel):
multiline: CoalesceBool = True


class ComboboxMixin(BaseModel):
combobox: CoalesceBool = False
"""Variable that defines if the user can insert custom values in the dropdown."""


class TableMixin(BaseModel):
table_schema: Optional[TableSchema | list[Column]] = None

Expand Down
17 changes: 14 additions & 3 deletions src/backend/base/langflow/inputs/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
BaseInputMixin,
DatabaseLoadMixin,
DropDownMixin,
ComboboxMixin,
FieldTypes,
FileMixin,
InputTraceMixin,
Expand Down Expand Up @@ -307,7 +306,7 @@ class DictInput(BaseInputMixin, ListableInputMixin, InputTraceMixin):
value: Optional[dict] = {}


class DropdownInput(BaseInputMixin, DropDownMixin, MetadataTraceMixin, ComboboxMixin):
class DropdownInput(BaseInputMixin, DropDownMixin, MetadataTraceMixin):
"""
Represents a dropdown input field.

Expand All @@ -316,7 +315,7 @@ class DropdownInput(BaseInputMixin, DropDownMixin, MetadataTraceMixin, ComboboxM

Attributes:
field_type (Optional[SerializableFieldTypes]): The field type of the input. Defaults to FieldTypes.TEXT.
options (Optional[Union[list[str], Callable]]): List of options for the field. Only used when is_list=True.
options (Optional[Union[list[str], Callable]]): List of options for the field.
Default is None.
"""

Expand All @@ -341,6 +340,18 @@ class MultiselectInput(BaseInputMixin, ListableInputMixin, DropDownMixin, Metada
field_type: Optional[SerializableFieldTypes] = FieldTypes.TEXT
options: list[str] = Field(default_factory=list)
is_list: bool = Field(default=True, serialization_alias="list")
combobox: CoalesceBool = False

@field_validator("value")
@classmethod
def validate_value(cls, v: Any, _info):
# Check if value is a list of dicts
if not isinstance(v, list):
raise ValueError(f"MultiselectInput value must be a list. Value: '{v}'")
for item in v:
if not isinstance(item, str):
raise ValueError(f"MultiselectInput value must be a list of strings. Item: '{item}' is not a string")
return v


class FileInput(BaseInputMixin, ListableInputMixin, FileMixin, MetadataTraceMixin):
Expand Down
Loading