🐛 fix(custom_component.py): remove unnecessary return type annotation from _class_template_validation method

🐛 fix(custom_component.py): handle case when code is empty in is_check_valid method to avoid potential error
🐛 fix(types.py): change field_value parameter type from str to Any in add_new_custom_field function to allow any value type
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-01 15:44:23 -03:00
commit 6c872bf4ac
2 changed files with 4 additions and 3 deletions

View file

@ -29,7 +29,7 @@ class CustomComponent(Component, extra=Extra.allow):
def build_config(self):
return self.field_config
def _class_template_validation(self, code: str) -> bool:
def _class_template_validation(self, code: str):
TYPE_HINT_LIST = ["Optional", "Prompt", "PromptTemplate", "LLMChain"]
if not code:
@ -52,7 +52,7 @@ class CustomComponent(Component, extra=Extra.allow):
raise HTTPException(status_code=400, detail=error_detail)
def is_check_valid(self) -> bool:
return self._class_template_validation(self.code)
return self._class_template_validation(self.code) if self.code else False
def get_code_tree(self, code: str):
return super().get_code_tree(code)

View file

@ -1,3 +1,4 @@
from typing import Any
from langflow.interface.agents.base import agent_creator
from langflow.interface.chains.base import chain_creator
from langflow.interface.custom.constants import CUSTOM_COMPONENT_SUPPORTED_TYPES
@ -89,7 +90,7 @@ def add_new_custom_field(
template,
field_name: str,
field_type: str,
field_value: str,
field_value: Any,
field_required: bool,
field_config: dict,
):