From 6c872bf4aca1c4e24f308193422875285c48d329 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 1 Aug 2023 15:44:23 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(custom=5Fcomponent.py):=20re?= =?UTF-8?q?move=20unnecessary=20return=20type=20annotation=20from=20=5Fcla?= =?UTF-8?q?ss=5Ftemplate=5Fvalidation=20method=20=F0=9F=90=9B=20fix(custom?= =?UTF-8?q?=5Fcomponent.py):=20handle=20case=20when=20code=20is=20empty=20?= =?UTF-8?q?in=20is=5Fcheck=5Fvalid=20method=20to=20avoid=20potential=20err?= =?UTF-8?q?or=20=F0=9F=90=9B=20fix(types.py):=20change=20field=5Fvalue=20p?= =?UTF-8?q?arameter=20type=20from=20str=20to=20Any=20in=20add=5Fnew=5Fcust?= =?UTF-8?q?om=5Ffield=20function=20to=20allow=20any=20value=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/custom/custom_component.py | 4 ++-- src/backend/langflow/interface/types.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/interface/custom/custom_component.py b/src/backend/langflow/interface/custom/custom_component.py index 353298cbd..4d65070bf 100644 --- a/src/backend/langflow/interface/custom/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component.py @@ -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) diff --git a/src/backend/langflow/interface/types.py b/src/backend/langflow/interface/types.py index 1420479a4..46fa781d6 100644 --- a/src/backend/langflow/interface/types.py +++ b/src/backend/langflow/interface/types.py @@ -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, ):