refactor: Add HandleInput to inputs module
This commit is contained in:
parent
88f03f0408
commit
ffae471c7b
3 changed files with 17 additions and 3 deletions
|
|
@ -5,11 +5,12 @@ from .inputs import (
|
||||||
FileInput,
|
FileInput,
|
||||||
FloatInput,
|
FloatInput,
|
||||||
IntInput,
|
IntInput,
|
||||||
|
MultilineInput,
|
||||||
NestedDictInput,
|
NestedDictInput,
|
||||||
PromptInput,
|
PromptInput,
|
||||||
SecretStrInput,
|
SecretStrInput,
|
||||||
StrInput,
|
StrInput,
|
||||||
MultilineInput,
|
HandleInput,
|
||||||
)
|
)
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|
@ -24,4 +25,5 @@ __all__ = [
|
||||||
"FileInput",
|
"FileInput",
|
||||||
"PromptInput",
|
"PromptInput",
|
||||||
"MultilineInput",
|
"MultilineInput",
|
||||||
|
"HandleInput",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ SerializableFieldTypes = Annotated[FieldTypes, PlainSerializer(lambda v: v.value
|
||||||
class BaseInputMixin(BaseModel):
|
class BaseInputMixin(BaseModel):
|
||||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||||
|
|
||||||
field_type: Optional[SerializableFieldTypes] = Field(default=FieldTypes.TEXT)
|
field_type: Optional[SerializableFieldTypes | str] = Field(default=FieldTypes.TEXT)
|
||||||
|
|
||||||
required: bool = False
|
required: bool = False
|
||||||
"""Specifies if the field is required. Defaults to False."""
|
"""Specifies if the field is required. Defaults to False."""
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from typing import Callable, Optional, Union
|
from typing import Callable, Optional, Union
|
||||||
|
|
||||||
from pydantic import Field
|
from pydantic import Field, model_validator
|
||||||
|
|
||||||
from langflow.inputs.validators import StrictBoolean
|
from langflow.inputs.validators import StrictBoolean
|
||||||
|
|
||||||
|
|
@ -16,6 +16,17 @@ from .input_mixin import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class HandleInput(BaseInputMixin):
|
||||||
|
input_types: list[str] = Field(default_factory=list)
|
||||||
|
field_type: Optional[str] = ""
|
||||||
|
|
||||||
|
@model_validator(mode="after")
|
||||||
|
def validate_model_type(self):
|
||||||
|
# FieldType should be a string
|
||||||
|
self.field_type = " | ".join(self.input_types)
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
class PromptInput(BaseInputMixin, ListableInputMixin):
|
class PromptInput(BaseInputMixin, ListableInputMixin):
|
||||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.PROMPT
|
field_type: Optional[SerializableFieldTypes] = FieldTypes.PROMPT
|
||||||
|
|
||||||
|
|
@ -83,4 +94,5 @@ InputTypes = Union[
|
||||||
FileInput,
|
FileInput,
|
||||||
PromptInput,
|
PromptInput,
|
||||||
MultilineInput,
|
MultilineInput,
|
||||||
|
HandleInput,
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue