# 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 WorkflowEdgeModelInputBackwardCondition_Expression(UncheckedBaseModel):
    type: typing.Literal["expression"] = "expression"
    label: typing.Optional[str] = None
    expression: "AstNodeInput"

    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 WorkflowEdgeModelInputBackwardCondition_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 WorkflowEdgeModelInputBackwardCondition_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 WorkflowEdgeModelInputBackwardCondition_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


WorkflowEdgeModelInputBackwardCondition = typing_extensions.Annotated[
    typing.Union[
        WorkflowEdgeModelInputBackwardCondition_Expression,
        WorkflowEdgeModelInputBackwardCondition_Llm,
        WorkflowEdgeModelInputBackwardCondition_Result,
        WorkflowEdgeModelInputBackwardCondition_Unconditional,
    ],
    UnionMetadata(discriminant="type"),
]
from .ast_addition_operator_node_input import AstAdditionOperatorNodeInput  # noqa: E402, I001
from .ast_and_operator_node_input import AstAndOperatorNodeInput  # noqa: E402, I001
from .ast_conditional_operator_node_input import AstConditionalOperatorNodeInput  # noqa: E402, I001
from .ast_division_operator_node_input import AstDivisionOperatorNodeInput  # noqa: E402, I001
from .ast_equals_operator_node_input import AstEqualsOperatorNodeInput  # noqa: E402, I001
from .ast_greater_than_operator_node_input import AstGreaterThanOperatorNodeInput  # noqa: E402, I001
from .ast_greater_than_or_equals_operator_node_input import AstGreaterThanOrEqualsOperatorNodeInput  # noqa: E402, I001
from .ast_less_than_operator_node_input import AstLessThanOperatorNodeInput  # noqa: E402, I001
from .ast_less_than_or_equals_operator_node_input import AstLessThanOrEqualsOperatorNodeInput  # noqa: E402, I001
from .ast_multiplication_operator_node_input import AstMultiplicationOperatorNodeInput  # noqa: E402, I001
from .ast_node_input import AstNodeInput  # noqa: E402, I001
from .ast_not_equals_operator_node_input import AstNotEqualsOperatorNodeInput  # noqa: E402, I001
from .ast_or_operator_node_input import AstOrOperatorNodeInput  # noqa: E402, I001
from .ast_subtraction_operator_node_input import AstSubtractionOperatorNodeInput  # noqa: E402, I001

update_forward_refs(
    WorkflowEdgeModelInputBackwardCondition_Expression,
    AstAdditionOperatorNodeInput=AstAdditionOperatorNodeInput,
    AstAndOperatorNodeInput=AstAndOperatorNodeInput,
    AstConditionalOperatorNodeInput=AstConditionalOperatorNodeInput,
    AstDivisionOperatorNodeInput=AstDivisionOperatorNodeInput,
    AstEqualsOperatorNodeInput=AstEqualsOperatorNodeInput,
    AstGreaterThanOperatorNodeInput=AstGreaterThanOperatorNodeInput,
    AstGreaterThanOrEqualsOperatorNodeInput=AstGreaterThanOrEqualsOperatorNodeInput,
    AstLessThanOperatorNodeInput=AstLessThanOperatorNodeInput,
    AstLessThanOrEqualsOperatorNodeInput=AstLessThanOrEqualsOperatorNodeInput,
    AstMultiplicationOperatorNodeInput=AstMultiplicationOperatorNodeInput,
    AstNodeInput=AstNodeInput,
    AstNotEqualsOperatorNodeInput=AstNotEqualsOperatorNodeInput,
    AstOrOperatorNodeInput=AstOrOperatorNodeInput,
    AstSubtractionOperatorNodeInput=AstSubtractionOperatorNodeInput,
)
