feat: add new input type - SliderComponent + tests (#4144)
This commit is contained in:
parent
ab77ca752b
commit
51b3909d60
13 changed files with 589 additions and 0 deletions
|
|
@ -19,6 +19,7 @@ from .inputs import (
|
|||
NestedDictInput,
|
||||
PromptInput,
|
||||
SecretStrInput,
|
||||
SliderInput,
|
||||
StrInput,
|
||||
TableInput,
|
||||
)
|
||||
|
|
@ -46,4 +47,8 @@ __all__ = [
|
|||
"SecretStrInput",
|
||||
"StrInput",
|
||||
"TableInput",
|
||||
"Input",
|
||||
"DefaultPromptField",
|
||||
"LinkInput",
|
||||
"SliderInput",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class FieldTypes(str, Enum):
|
|||
OTHER = "other"
|
||||
TABLE = "table"
|
||||
LINK = "link"
|
||||
SLIDER = "slider"
|
||||
|
||||
|
||||
SerializableFieldTypes = Annotated[FieldTypes, PlainSerializer(lambda v: v.value, return_type=str)]
|
||||
|
|
@ -167,6 +168,16 @@ class LinkMixin(BaseModel):
|
|||
"""Text to be displayed in the link."""
|
||||
|
||||
|
||||
class SliderMixin(BaseModel):
|
||||
min_label: str = Field(default="")
|
||||
max_label: str = Field(default="")
|
||||
min_label_icon: str = Field(default="")
|
||||
max_label_icon: str = Field(default="")
|
||||
slider_buttons: bool = Field(default=False)
|
||||
slider_buttons_options: list[str] = Field(default=[])
|
||||
slider_input: bool = Field(default=False)
|
||||
|
||||
|
||||
class TableMixin(BaseModel):
|
||||
table_schema: TableSchema | list[Column] | None = None
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ from .input_mixin import (
|
|||
MultilineMixin,
|
||||
RangeMixin,
|
||||
SerializableFieldTypes,
|
||||
SliderMixin,
|
||||
TableMixin,
|
||||
)
|
||||
|
||||
|
|
@ -470,6 +471,10 @@ class LinkInput(BaseInputMixin, LinkMixin):
|
|||
field_type: SerializableFieldTypes = FieldTypes.LINK
|
||||
|
||||
|
||||
class SliderInput(BaseInputMixin, RangeMixin, SliderMixin):
|
||||
field_type: SerializableFieldTypes = FieldTypes.SLIDER
|
||||
|
||||
|
||||
DEFAULT_PROMPT_INTUT_TYPES = ["Message", "Text"]
|
||||
|
||||
|
||||
|
|
@ -506,6 +511,7 @@ InputTypes = (
|
|||
| MessageInput
|
||||
| TableInput
|
||||
| LinkInput
|
||||
| SliderInput
|
||||
)
|
||||
|
||||
InputTypesMap: dict[str, type[InputTypes]] = {t.__name__: t for t in get_args(InputTypes)}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ from langflow.inputs import (
|
|||
NestedDictInput,
|
||||
PromptInput,
|
||||
SecretStrInput,
|
||||
SliderInput,
|
||||
StrInput,
|
||||
TableInput,
|
||||
)
|
||||
|
|
@ -46,4 +47,7 @@ __all__ = [
|
|||
"SecretStrInput",
|
||||
"StrInput",
|
||||
"TableInput",
|
||||
"DefaultPromptField",
|
||||
"LinkInput",
|
||||
"SliderInput",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue