feat: Add Decision class to langflow schema
This commit is contained in:
parent
79e35dc2a2
commit
6732cf94f6
2 changed files with 32 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
from .dotdict import dotdict
|
from .dotdict import dotdict
|
||||||
from .schema import Record
|
from .schema import Record
|
||||||
|
from .decision import Decision
|
||||||
|
|
||||||
__all__ = ["Record", "dotdict"]
|
__all__ = ["Record", "dotdict", "Decision"]
|
||||||
|
|
|
||||||
30
src/backend/base/langflow/schema/decision.py
Normal file
30
src/backend/base/langflow/schema/decision.py
Normal 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)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue