Skip to content

Commit

Permalink
fix: multiselect dropdown not visible (langflow-ai#3044)
Browse files Browse the repository at this point in the history
* Fixed refresh button and refresh parameter

* Refactored Multiselect component and implemented custom values on it

* Fixed default values

* Made Backend support combobox on Dropdown and Multiselect

(cherry picked from commit 7fa3d33)
  • Loading branch information
lucaseduoli authored and nicoloboschi committed Jul 30, 2024
1 parent 7212a06 commit 89af760
Show file tree
Hide file tree
Showing 9 changed files with 259 additions and 323 deletions.
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

0 comments on commit 89af760

Please sign in to comment.