Skip to content

Commit

Permalink
fix: make provider switching work by setting attributes on SecretStrI…
Browse files Browse the repository at this point in the history
…nput 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>
  • Loading branch information
edwinjosechittilappilly and autofix-ci[bot] authored Nov 18, 2024
1 parent a0cd179 commit 3d768ea
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/backend/base/langflow/base/models/model_input_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@
from langflow.components.models.groq import GroqModel
from langflow.components.models.nvidia import NVIDIAModelComponent
from langflow.components.models.openai import OpenAIModelComponent
from langflow.inputs.inputs import SecretStrInput


def get_filtered_inputs(component_class):
base_input_names = {field.name for field in LCModelComponent._base_inputs}
return [
set_advanced_true(input_) if input_.name == "temperature" else input_
for input_ in component_class().inputs
if input_.name not in base_input_names
]
component_instance = component_class()

return [process_inputs(input_) for input_ in component_instance.inputs 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):
Expand Down

0 comments on commit 3d768ea

Please sign in to comment.