feat: Add inputs and outputs to CustomComponent

This commit adds the `inputs` and `outputs` fields to the `CustomComponent` class in the `custom_component.py` file. The `inputs` field is of type `List[Input]` and the `outputs` field is of type `List[Output]`. This change allows for better organization and management of the component's input and output fields.
This commit is contained in:
ogabrielluiz 2024-05-30 18:29:40 -03:00
commit 82fcdfb67a

View file

@ -7,6 +7,7 @@ import yaml
from cachetools import TTLCache, cachedmethod
from langchain_core.documents import Document
from pydantic import BaseModel
from langflow.custom.code_parser.utils import (
extract_inner_type_from_generic_alias,
extract_union_types_from_generic_alias,
@ -17,6 +18,7 @@ from langflow.schema import Record
from langflow.schema.dotdict import dotdict
from langflow.services.deps import get_storage_service, get_variable_service, session_scope
from langflow.services.storage.service import StorageService
from langflow.template.field.base import Input, Output
from langflow.utils import validate
if TYPE_CHECKING:
@ -78,6 +80,9 @@ class CustomComponent(Component):
"""The status of the component. This is displayed on the frontend. Defaults to None."""
_flows_records: Optional[List[Record]] = None
inputs: Optional[List[Input]] = None
outputs: Optional[List[Output]] = None
def update_state(self, name: str, value: Any):
if not self.vertex:
raise ValueError("Vertex is not set")
@ -464,3 +469,4 @@ class CustomComponent(Component):
Any: The result of the build process.
"""
raise NotImplementedError
raise NotImplementedError