From 98f739db990981c00099ddc52086bf713d7a820b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 9 Feb 2024 09:06:15 -0300 Subject: [PATCH] Refactor getattr_return_str method in Component class --- .../interface/custom/custom_component/component.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/langflow/interface/custom/custom_component/component.py b/src/backend/langflow/interface/custom/custom_component/component.py index 2cb99e99a..ff957ed7d 100644 --- a/src/backend/langflow/interface/custom/custom_component/component.py +++ b/src/backend/langflow/interface/custom/custom_component/component.py @@ -68,9 +68,9 @@ class Component: return validate.create_function(self.code, self._function_entrypoint_name) - def getattr_return_str(self, component, attribute): - attribute = getattr(component, attribute) - return str(attribute) if attribute else "" + def getattr_return_str(self, component, value): + value = getattr(component, value) + return str(value) if value else "" def build_template_config(self) -> dict: if not self.code: @@ -89,11 +89,11 @@ class Component: for attribute, func in attributes_func_mapping.items(): if hasattr(component_instance, attribute): - template_config[attribute] = func(component_instance, attribute) + template_config[attribute] = func(component=component_instance, value=attribute) return template_config - def validate_icon(self, _, value: str): + def validate_icon(self, value: str, *args, **kwargs): # we are going to use the emoji library to validate the emoji # emojis can be defined using the :emoji_name: syntax if not value.startswith(":") or not value.endswith(":"):