From bd9d90786a06c374e700ef82c33528d1243dfde1 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Fri, 26 May 2023 22:29:52 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20chore(base.py):=20remove=20unuse?= =?UTF-8?q?d=20process=5Ffield=20method=20from=20TemplateFieldCreator=20Th?= =?UTF-8?q?e=20process=5Ffield=20method=20in=20the=20TemplateFieldCreator?= =?UTF-8?q?=20class=20is=20not=20used=20anywhere=20in=20the=20codebase=20a?= =?UTF-8?q?nd=20is=20therefore=20removed=20to=20improve=20code=20readabili?= =?UTF-8?q?ty=20and=20maintainability.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/template/base.py | 70 --------------------------- 1 file changed, 70 deletions(-) diff --git a/src/backend/langflow/template/base.py b/src/backend/langflow/template/base.py index c944ec8d1..74e180356 100644 --- a/src/backend/langflow/template/base.py +++ b/src/backend/langflow/template/base.py @@ -42,76 +42,6 @@ class TemplateFieldCreator(BaseModel, ABC): result["content"] = self.content return result - def process_field( - self, key: str, value: Dict[str, Any], name: Optional[str] = None - ) -> None: - _type = value["type"] - - # Remove 'Optional' wrapper - if "Optional" in _type: - _type = _type.replace("Optional[", "")[:-1] - - # Check for list type - if "List" in _type: - _type = _type.replace("List[", "")[:-1] - self.is_list = True - - # Replace 'Mapping' with 'dict' - if "Mapping" in _type: - _type = _type.replace("Mapping", "dict") - - # Change type from str to Tool - self.field_type = "Tool" if key in {"allowed_tools"} else self.field_type - - self.field_type = "int" if key in {"max_value_length"} else self.field_type - - # Show or not field - self.show = bool( - (self.required and key not in ["input_variables"]) - or key in FORCE_SHOW_FIELDS - or "api_key" in key - ) - - # Add password field - self.password = any( - text in key.lower() for text in {"password", "token", "api", "key"} - ) - - # Add multline - self.multiline = key in { - "suffix", - "prefix", - "template", - "examples", - "code", - "headers", - } - - # Replace dict type with str - if "dict" in self.field_type.lower(): - self.field_type = "code" - - if key == "dict_": - self.field_type = "file" - self.suffixes = [".json", ".yaml", ".yml"] - self.file_types = ["json", "yaml", "yml"] - - # Replace default value with actual value - if "default" in value: - self.value = value["default"] - - if key == "headers": - self.value = """{'Authorization': - 'Bearer '}""" - - # Add options to openai - if name == "OpenAI" and key == "model_name": - self.options = constants.OPENAI_MODELS - self.is_list = True - elif name == "ChatOpenAI" and key == "model_name": - self.options = constants.CHAT_OPENAI_MODELS - self.is_list = True - class TemplateField(TemplateFieldCreator): pass