diff --git a/src/backend/base/langflow/schema/__init__.py b/src/backend/base/langflow/schema/__init__.py index 14230578c..9c374a730 100644 --- a/src/backend/base/langflow/schema/__init__.py +++ b/src/backend/base/langflow/schema/__init__.py @@ -1,4 +1,5 @@ from .dotdict import dotdict from .schema import Record +from .decision import Decision -__all__ = ["Record", "dotdict"] +__all__ = ["Record", "dotdict", "Decision"] diff --git a/src/backend/base/langflow/schema/decision.py b/src/backend/base/langflow/schema/decision.py new file mode 100644 index 000000000..bb4f0206b --- /dev/null +++ b/src/backend/base/langflow/schema/decision.py @@ -0,0 +1,30 @@ +from pydantic import field_validator, BaseModel +from typing import Any + + +class Decision(BaseModel): + """ + Represents a decision made in the Graph. + + Attributes: + path (str): The path to take as a result of the decision. + result (dict): The result of the decision. + """ + + path: str + result: Any + + @field_validator("path") + def validate_path(cls, value: str) -> str: + """ + Validates the path. + + Args: + value (str): The path to validate. + + Returns: + str: The validated path. + """ + if isinstance(value, str): + return value + return str(value)