feat(template): add advanced flag to TemplateFieldCreator and FrontendNode classes

Add an advanced flag to the TemplateFieldCreator and FrontendNode classes to allow for fields to be hidden from the user interface. In the TemplateFieldCreator class, the advanced flag is set to False by default. In the FrontendNode class, the advanced flag is set to False for all fields except for "model_type" and "model_kwargs", which are set to True.
This commit is contained in:
Gabriel Almeida 2023-04-19 14:52:05 -03:00
commit f1ef859374
2 changed files with 9 additions and 1 deletions

View file

@ -23,6 +23,7 @@ class TemplateFieldCreator(BaseModel, ABC):
options: list[str] = []
name: str = ""
display_name: Optional[str] = None
advanced: bool = False
def to_dict(self):
result = self.dict()
@ -228,3 +229,8 @@ class FrontendNode(BaseModel):
field.required = True
if field.value is None:
field.value = ""
if "kwargs" in field.name.lower():
field.advanced = True
field.required = False
field.show = False

View file

@ -415,7 +415,7 @@ class LLMFrontendNode(FrontendNode):
"huggingfacehub_api_token": "HuggingFace Hub API Token",
}
FrontendNode.format_field(field, name)
SHOW_FIELDS = ["repo_id", "task", "model_kwargs"]
SHOW_FIELDS = ["repo_id"]
if field.name in SHOW_FIELDS:
field.show = True
@ -429,8 +429,10 @@ class LLMFrontendNode(FrontendNode):
field.show = True
field.is_list = True
field.options = ["text-generation", "text2text-generation"]
field.advanced = True
if display_name := display_names_dict.get(field.name):
field.display_name = display_name
if field.name == "model_kwargs":
field.field_type = "code"
field.advanced = True