fix: make provider switching work by setting attributes on SecretStrInput for Agent Component Inputs (#4643)

* Refactor `process_inputs` function to handle `SecretStrInput`

- Reset `value` and disable `load_from_db` for `SecretStrInput` instances.

* [autofix.ci] apply automated fixes

* Update model_input_constants.py

Optimize input processing for speed improvements

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Edwin Jose 2024-11-18 16:18:33 -05:00 • committed by GitHub
commit 3d768ea041
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,15 +5,23 @@ from langflow.components.models.azure_openai import AzureChatOpenAIComponent
from langflow.components.models.groq import GroqModel from langflow.components.models.groq import GroqModel
from langflow.components.models.nvidia import NVIDIAModelComponent from langflow.components.models.nvidia import NVIDIAModelComponent
from langflow.components.models.openai import OpenAIModelComponent from langflow.components.models.openai import OpenAIModelComponent
from langflow.inputs.inputs import SecretStrInput
def get_filtered_inputs(component_class): def get_filtered_inputs(component_class):
base_input_names = {field.name for field in LCModelComponent._base_inputs} base_input_names = {field.name for field in LCModelComponent._base_inputs}
return [ component_instance = component_class()
set_advanced_true(input_) if input_.name == "temperature" else input_
for input_ in component_class().inputs return [process_inputs(input_) for input_ in component_instance.inputs if input_.name not in base_input_names]
if input_.name not in base_input_names
]
def process_inputs(component_data):
if isinstance(component_data, SecretStrInput):
component_data.value = ""
component_data.load_from_db = False
elif component_data.name == "temperature":
component_data = set_advanced_true(component_data)
return component_data
def set_advanced_true(component_input): def set_advanced_true(component_input):