📝 (component.py): update variable name from display_name to name for consistency and clarity
📝 (component.py): improve variable naming for better readability and maintainability 📝 (__init__.py): refactor function name _import_template_field to _import_input_class for better naming clarity 📝 (__init__.py): refactor function name _import_template_field to _import_input_class for better naming clarity 📝 (__init__.py): add function _import_output_class to import Output class from langflow.template.field.base
This commit is contained in:
parent
834570df8b
commit
52323eae4a
2 changed files with 12 additions and 4 deletions
|
|
@ -71,13 +71,13 @@ class Component(CustomComponent):
|
||||||
for output in self.outputs:
|
for output in self.outputs:
|
||||||
# Build the output if it's connected to some other vertex
|
# Build the output if it's connected to some other vertex
|
||||||
# or if it's not connected to any vertex
|
# or if it's not connected to any vertex
|
||||||
if not vertex.outgoing_edges or output.display_name in vertex.edges_source_names:
|
if not vertex.outgoing_edges or output.name in vertex.edges_source_names:
|
||||||
method: Callable | Awaitable = getattr(self, output.method)
|
method: Callable | Awaitable = getattr(self, output.method)
|
||||||
result = method()
|
result = method()
|
||||||
# If the method is asynchronous, we need to await it
|
# If the method is asynchronous, we need to await it
|
||||||
if inspect.iscoroutinefunction(method):
|
if inspect.iscoroutinefunction(method):
|
||||||
result = await result
|
result = await result
|
||||||
_results[output.display_name] = result
|
_results[output.name] = result
|
||||||
self._results = _results
|
self._results = _results
|
||||||
return _results
|
return _results
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,18 +29,26 @@ from .constants import (
|
||||||
from .range_spec import RangeSpec
|
from .range_spec import RangeSpec
|
||||||
|
|
||||||
|
|
||||||
def _import_template_field():
|
def _import_input_class():
|
||||||
from langflow.template.field.base import Input
|
from langflow.template.field.base import Input
|
||||||
|
|
||||||
return Input
|
return Input
|
||||||
|
|
||||||
|
|
||||||
|
def _import_output_class():
|
||||||
|
from langflow.template.field.base import Output
|
||||||
|
|
||||||
|
return Output
|
||||||
|
|
||||||
|
|
||||||
def __getattr__(name: str) -> Any:
|
def __getattr__(name: str) -> Any:
|
||||||
# This is to avoid circular imports
|
# This is to avoid circular imports
|
||||||
if name == "Input":
|
if name == "Input":
|
||||||
return _import_template_field()
|
return _import_input_class()
|
||||||
elif name == "RangeSpec":
|
elif name == "RangeSpec":
|
||||||
return RangeSpec
|
return RangeSpec
|
||||||
|
elif name == "Output":
|
||||||
|
return _import_output_class()
|
||||||
# The other names should work as if they were imported from constants
|
# The other names should work as if they were imported from constants
|
||||||
# Import the constants module langflow.field_typing.constants
|
# Import the constants module langflow.field_typing.constants
|
||||||
from . import constants
|
from . import constants
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue