feat: Add Decision class to langflow schema

This commit is contained in:
ogabrielluiz 2024-05-28 23:04:37 -03:00
commit 6732cf94f6
2 changed files with 32 additions and 1 deletions

View file

@ -1,4 +1,5 @@
from .dotdict import dotdict
from .schema import Record
from .decision import Decision
__all__ = ["Record", "dotdict"]
__all__ = ["Record", "dotdict", "Decision"]

View file

@ -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)