refactor: Update field input classes and module structure
This commit is contained in:
parent
e7be07ebec
commit
8b87c0ef92
5 changed files with 40 additions and 12 deletions
25
src/backend/base/langflow/inputs/__init__.py
Normal file
25
src/backend/base/langflow/inputs/__init__.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from .inputs import (
|
||||
BoolInput,
|
||||
DictInput,
|
||||
DropdownInput,
|
||||
FileInput,
|
||||
FloatInput,
|
||||
IntInput,
|
||||
NestedDictInput,
|
||||
PromptInput,
|
||||
SecretStrInput,
|
||||
StrInput,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"SecretStrInput",
|
||||
"StrInput",
|
||||
"IntInput",
|
||||
"FloatInput",
|
||||
"BoolInput",
|
||||
"NestedDictInput",
|
||||
"DictInput",
|
||||
"DropdownInput",
|
||||
"FileInput",
|
||||
"PromptInput",
|
||||
]
|
||||
|
|
@ -2,7 +2,7 @@ from typing import Callable, Optional, Union
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from langflow.template.field.input_mixin import (
|
||||
from .input_mixin import (
|
||||
BaseInputMixin,
|
||||
DatabaseLoadMixin,
|
||||
DropDownMixin,
|
||||
|
|
@ -10,50 +10,51 @@ from langflow.template.field.input_mixin import (
|
|||
FileMixin,
|
||||
ListableInputMixin,
|
||||
RangeMixin,
|
||||
SerializableFieldTypes,
|
||||
)
|
||||
|
||||
|
||||
class PromptInput(BaseInputMixin, ListableInputMixin):
|
||||
field_type = FieldTypes.PROMPT
|
||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.PROMPT
|
||||
|
||||
|
||||
# Applying mixins to a specific input type
|
||||
class StrInput(BaseInputMixin, ListableInputMixin): # noqa: F821
|
||||
field_type = FieldTypes.TEXT
|
||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.TEXT
|
||||
multiline: bool = Field(default=False)
|
||||
"""Defines if the field will allow the user to open a text editor. Default is False."""
|
||||
|
||||
|
||||
class SecretStrInput(BaseInputMixin, DatabaseLoadMixin):
|
||||
field_type = FieldTypes.PASSWORD
|
||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.PASSWORD
|
||||
password: bool = Field(default=True)
|
||||
|
||||
|
||||
class IntInput(BaseInputMixin, ListableInputMixin, RangeMixin):
|
||||
field_type = FieldTypes.INTEGER
|
||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.INTEGER
|
||||
|
||||
|
||||
class FloatInput(BaseInputMixin, ListableInputMixin, RangeMixin):
|
||||
field_type = FieldTypes.FLOAT
|
||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.FLOAT
|
||||
|
||||
|
||||
class BoolInput(BaseInputMixin, ListableInputMixin):
|
||||
field_type = FieldTypes.BOOLEAN
|
||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.BOOLEAN
|
||||
|
||||
|
||||
class NestedDictInput(BaseInputMixin, ListableInputMixin):
|
||||
field_type = FieldTypes.NESTED_DICT
|
||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.NESTED_DICT
|
||||
|
||||
|
||||
class DictInput(BaseInputMixin, ListableInputMixin):
|
||||
field_type = FieldTypes.DICT
|
||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.DICT
|
||||
|
||||
|
||||
class DropdownInput(BaseInputMixin, DropDownMixin):
|
||||
field_type = FieldTypes.TEXT
|
||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.TEXT
|
||||
options: Optional[Union[list[str], Callable]] = None
|
||||
"""List of options for the field. Only used when is_list=True. Default is an empty list."""
|
||||
|
||||
|
||||
class FileInput(BaseInputMixin, ListableInputMixin, FileMixin):
|
||||
field_type = FieldTypes.FILE
|
||||
field_type: Optional[SerializableFieldTypes] = FieldTypes.FILE
|
||||
|
|
@ -2,6 +2,7 @@ from langflow.template.field.base import Input, Output
|
|||
from langflow.template.frontend_node.base import FrontendNode
|
||||
from langflow.template.template.base import Template
|
||||
|
||||
|
||||
__all__ = [
|
||||
"Input",
|
||||
"Output",
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ from typing import Callable, Union
|
|||
|
||||
from pydantic import BaseModel, model_serializer
|
||||
|
||||
from langflow.inputs.input_mixin import BaseInputMixin
|
||||
from langflow.template.field.base import Input
|
||||
from langflow.utils.constants import DIRECT_TYPES
|
||||
|
||||
|
||||
class Template(BaseModel):
|
||||
type_name: str
|
||||
fields: list[Input]
|
||||
fields: list[Input | BaseInputMixin]
|
||||
|
||||
def process_fields(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue