From 80eb0028be259f587799a537e222a5e074406b5b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 31 Mar 2024 21:40:49 -0300 Subject: [PATCH] Remove unnecessary field_type key from CustomComponent class --- docs/docs/components/custom.mdx | 4 ++-- docs/docs/guidelines/custom-component.mdx | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/docs/components/custom.mdx b/docs/docs/components/custom.mdx index 43eb336fc..0aefe0b23 100644 --- a/docs/docs/components/custom.mdx +++ b/docs/docs/components/custom.mdx @@ -70,7 +70,6 @@ The CustomComponent class serves as the foundation for creating custom component | Key | Description | | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - | _`field_type: str`_ | The type of the field (can be any of the types supported by the _`build`_ method). | | _`is_list: bool`_ | If the field can be a list of values, meaning that the user can manually add more inputs to the same field. | | _`options: List[str]`_ | When defined, the field becomes a dropdown menu where a list of strings defines the options to be displayed. If the _`value`_ attribute is set to one of the options, that option becomes default. For this parameter to work, _`field_type`_ should invariably be _`str`_. | | _`multiline: bool`_ | Defines if a string field opens a text editor. Useful for longer texts. | @@ -78,13 +77,14 @@ The CustomComponent class serves as the foundation for creating custom component | _`display_name: str`_ | Defines the name of the field. | | _`advanced: bool`_ | Hide the field in the canvas view (displayed component settings only). Useful when a field is for advanced users. | | _`password: bool`_ | To mask the input text. Useful to hide sensitive text (e.g. API keys). | - | _`required: bool`_ | Makes the field required. | + | _`required: bool`_ | Forces the field to be required. Only use this if type hints are not enough to indicate that the field is required. | | _`info: str`_ | Adds a tooltip to the field. | | _`file_types: List[str]`_ | This is a requirement if the _`field_type`_ is _file_. Defines which file types will be accepted. For example, _json_, _yaml_ or _yml_. | | _`range_spec: langflow.field_typing.RangeSpec`_ | This is a requirement if the _`field_type`_ is _`float`_. Defines the range of values accepted and the step size. If none is defined, the default is _`[-1, 1, 0.1]`_. | | _`title_case: bool`_ | Formats the name of the field when _`display_name`_ is not defined. Set it to False to keep the name as you set it in the _`build`_ method. | | _`refresh_button: bool`_ | If set to True a button will appear to the right of the field, and when clicked, it will call the _`update_build_config`_ method which takes in the _`build_config`_, the name of the field (_`field_name`_) and the latest value of the field (_`field_value`_). This is useful when you want to update the _`build_config`_ based on the value of the field. | | _`real_time_refresh: bool`_ | If set to True, the _`update_build_config`_ method will be called every time the field value changes. | + | _`field_type: str`_ | You should never define this key. It is automatically set based on the type hint of the _`build`_ method. | diff --git a/docs/docs/guidelines/custom-component.mdx b/docs/docs/guidelines/custom-component.mdx index 65e505d2e..77a1c5aaa 100644 --- a/docs/docs/guidelines/custom-component.mdx +++ b/docs/docs/guidelines/custom-component.mdx @@ -283,7 +283,7 @@ The return type is _`Document`_. The _`build_config`_ method is here defined to customize the component fields. - _`options`_ determines that the field will be a dropdown menu. The list values and field type must be _`str`_. -- _`value`_ is the default option of the dropdown menu. +- _`value`_ is the default value of the field. - _`display_name`_ is the name of the field to be displayed. ```python @@ -408,4 +408,6 @@ Once your custom components have been loaded successfully, they will appear in L Remember, creating custom components allows you to extend the functionality of Langflow to better suit your unique needs. Happy coding!import ZoomableImage from "/src/theme/ZoomableImage.js"; import Admonition from "@theme/Admonition"; +import ZoomableImage from "/src/theme/ZoomableImage.js"; +import Admonition from "@theme/Admonition";