🔀 refactor(textsplitters.py): extract options list into a variable for reusability and sorting

The options list for the separator_type field in the TextSplittersFrontendNode class has been extracted into a variable called options. This improves code readability and allows for easier modification and sorting of the options list.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-28 18:16:04 -03:00
commit 3485893be0

View file

@ -21,6 +21,8 @@ class TextSplittersFrontendNode(FrontendNode):
# Add a field for type of separator
# which will have Text or any value from the
# Language enum
options = [x.value for x in Language] + ["Text"]
options.sort()
self.template.add_field(
TemplateField(
field_type="str",
@ -29,7 +31,7 @@ class TextSplittersFrontendNode(FrontendNode):
name="separator_type",
advanced=False,
is_list=True,
options=[x.value for x in Language],
options=options,
value="Text",
display_name="Separator Type",
)