feat: Add New Link Parameter Type for External Links in Node UI (#3806)
* ✨ (inputs/__init__.py): Add LinkInput class to support linking functionality in inputs 📝 (inputs/input_mixin.py): Add Link field type to support linking functionality in inputs 📝 (inputs/inputs.py): Add LinkInput class to support linking functionality in inputs 📝 (io/__init__.py): Import and export LinkInput class for linking functionality in inputs 📝 (frontend/src/components/linkComponent/index.tsx): Create LinkComponent to display and handle links in frontend components 📝 (frontend/src/components/parameterRenderComponent/index.tsx): Add support for rendering LinkComponent in parameter rendering based on template type 📝 (frontend/src/constants/constants.ts): Add "link" as a supported type for LANGFLOW_SUPPORTED_TYPES 📝 (frontend/src/types/api/index.ts): Add icon and text fields to InputFieldType for link component 📝 (frontend/src/types/components/index.ts): Define LinkComponentType for passing link data to LinkComponent ✨ (linkComponent.spec.ts): Add unit test for link component interaction to ensure proper functionality and behavior 📝 (unit-test-components.spec.ts): Add template for a unit test file to be used for testing components in the frontend application * style: apply make format * Update input_mixin.py --------- Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
This commit is contained in:
parent
d4bed03f9c
commit
3e617acf2f
11 changed files with 221 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ from .inputs import (
|
|||
SecretStrInput,
|
||||
StrInput,
|
||||
TableInput,
|
||||
LinkInput,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
|
|
@ -44,4 +45,5 @@ __all__ = [
|
|||
"TableInput",
|
||||
"Input",
|
||||
"DefaultPromptField",
|
||||
"LinkInput",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class FieldTypes(str, Enum):
|
|||
CODE = "code"
|
||||
OTHER = "other"
|
||||
TABLE = "table"
|
||||
LINK = "link"
|
||||
|
||||
|
||||
SerializableFieldTypes = Annotated[FieldTypes, PlainSerializer(lambda v: v.value, return_type=str)]
|
||||
|
|
@ -156,6 +157,13 @@ class MultilineMixin(BaseModel):
|
|||
multiline: CoalesceBool = True
|
||||
|
||||
|
||||
class LinkMixin(BaseModel):
|
||||
icon: str | None = None
|
||||
"""Icon to be displayed in the link."""
|
||||
text: str | None = None
|
||||
"""Text to be displayed in the link."""
|
||||
|
||||
|
||||
class TableMixin(BaseModel):
|
||||
table_schema: TableSchema | list[Column] | None = None
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ from .input_mixin import (
|
|||
RangeMixin,
|
||||
SerializableFieldTypes,
|
||||
TableMixin,
|
||||
LinkMixin,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -467,6 +468,10 @@ class FileInput(BaseInputMixin, ListableInputMixin, FileMixin, MetadataTraceMixi
|
|||
field_type: SerializableFieldTypes = FieldTypes.FILE
|
||||
|
||||
|
||||
class LinkInput(BaseInputMixin, LinkMixin):
|
||||
field_type: SerializableFieldTypes = FieldTypes.LINK
|
||||
|
||||
|
||||
DEFAULT_PROMPT_INTUT_TYPES = ["Message", "Text"]
|
||||
|
||||
|
||||
|
|
@ -474,7 +479,6 @@ class DefaultPromptField(Input):
|
|||
name: str
|
||||
display_name: str | None = None
|
||||
field_type: str = "str"
|
||||
|
||||
advanced: bool = False
|
||||
multiline: bool = True
|
||||
input_types: list[str] = DEFAULT_PROMPT_INTUT_TYPES
|
||||
|
|
@ -503,6 +507,7 @@ InputTypes = Union[
|
|||
MessageTextInput,
|
||||
MessageInput,
|
||||
TableInput,
|
||||
LinkInput,
|
||||
]
|
||||
|
||||
InputTypesMap: dict[str, type[InputTypes]] = {t.__name__: t for t in get_args(InputTypes)}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ from langflow.inputs import (
|
|||
StrInput,
|
||||
TableInput,
|
||||
DefaultPromptField,
|
||||
LinkInput,
|
||||
)
|
||||
from langflow.template import Output
|
||||
|
||||
|
|
@ -44,4 +45,5 @@ __all__ = [
|
|||
"Output",
|
||||
"TableInput",
|
||||
"DefaultPromptField",
|
||||
"LinkInput",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue