fix: Optimize Setting of Output Required Inputs (#4389)

Update component.py

Fix required inputs not updated if its already defined
This commit is contained in:
Edwin Jose 2024-11-05 00:31:13 -05:00 • committed by GitHub
commit 7cc497aa52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 40 additions and 20 deletions

View file

@ -1,3 +1,4 @@
from .agent import AgentComponent
from .crewai import CrewAIAgentComponent
from .csv import CSVAgentComponent
from .hierarchical_crew import HierarchicalCrewComponent
@ -26,4 +27,5 @@ __all__ = [
"VectorStoreAgentComponent",
"VectorStoreRouterAgentComponent",
"XMLAgentComponent",
"AgentComponent",
]

View file

@ -10,6 +10,7 @@ from langflow.field_typing import LanguageModel
from langflow.field_typing.range_spec import RangeSpec
from langflow.inputs import BoolInput, DictInput, DropdownInput, FloatInput, IntInput, SecretStrInput, StrInput
from langflow.inputs.inputs import HandleInput
from langflow.io import Output
class OpenAIModelComponent(LCModelComponent):
@ -81,6 +82,10 @@ class OpenAIModelComponent(LCModelComponent):
input_types=["OutputParser"],
),
]
outputs = [
Output(display_name="Text", name="text_output", method="text_response"),
Output(display_name="Language Model", name="model_output", method="build_model"),
]
def build_model(self) -> LanguageModel: # type: ignore[type-var]
# self.output_schema is a list of dictionaries

View file

@ -369,6 +369,8 @@ class Component(CustomComponent):
def _set_output_required_inputs(self) -> None:
for output in self.outputs:
if output.required_inputs:
continue
if not output.method:
continue
method = getattr(self, output.method, None)