From c51e311aa513e600334ad8381232f7b701dd99d8 Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Tue, 18 Jun 2024 19:17:16 -0300 Subject: [PATCH] feat: Initialize component inputs with default values The code changes in `component.py` initialize component inputs with default values if they are not provided. This ensures that the inputs are always set, even if they are not explicitly passed. Additionally, the commit message follows the established convention of using a prefix to indicate the type of change. --- .../base/langflow/custom/custom_component/component.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/base/langflow/custom/custom_component/component.py b/src/backend/base/langflow/custom/custom_component/component.py index 3d6bcef42..3cf8b9e7d 100644 --- a/src/backend/base/langflow/custom/custom_component/component.py +++ b/src/backend/base/langflow/custom/custom_component/component.py @@ -80,6 +80,11 @@ class Component(CustomComponent): if key in self.__dict__: raise ValueError(f"Key {key} already exists in {self.__class__.__name__}") setattr(self, key, value) + for key, input_obj in self._inputs.items(): + if not hasattr(self, key): + setattr(self, key, input_obj.value or None) + if key not in params: + params[key] = input_obj.value or None self._arguments = params def _set_outputs(self, outputs: List[dict]):