# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs
from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata


class WorkflowEdgeModelOutputBackwardCondition_Expression(UncheckedBaseModel):
    type: typing.Literal["expression"] = "expression"
    label: typing.Optional[str] = None
    expression: "AstNodeOutput"

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


from .ast_node_output import AstNodeOutput  # noqa: E402, I001


class WorkflowEdgeModelOutputBackwardCondition_Llm(UncheckedBaseModel):
    type: typing.Literal["llm"] = "llm"
    label: typing.Optional[str] = None
    condition: str

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class WorkflowEdgeModelOutputBackwardCondition_Result(UncheckedBaseModel):
    type: typing.Literal["result"] = "result"
    label: typing.Optional[str] = None
    successful: bool

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


class WorkflowEdgeModelOutputBackwardCondition_Unconditional(UncheckedBaseModel):
    type: typing.Literal["unconditional"] = "unconditional"
    label: typing.Optional[str] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


WorkflowEdgeModelOutputBackwardCondition = typing_extensions.Annotated[
    typing.Union[
        WorkflowEdgeModelOutputBackwardCondition_Expression,
        WorkflowEdgeModelOutputBackwardCondition_Llm,
        WorkflowEdgeModelOutputBackwardCondition_Result,
        WorkflowEdgeModelOutputBackwardCondition_Unconditional,
    ],
    UnionMetadata(discriminant="type"),
]
update_forward_refs(WorkflowEdgeModelOutputBackwardCondition_Expression)
