# 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
from .conversation_history_transcript_tool_call_common_model_output import (
    ConversationHistoryTranscriptToolCallCommonModelOutput,
)


class WorkflowToolResponseModelOutputStepsItem_Edge(UncheckedBaseModel):
    type: typing.Literal["edge"] = "edge"
    step_latency_secs: float
    edge_id: str
    target_node_id: 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 WorkflowToolResponseModelOutputStepsItem_MaxIterationsExceeded(UncheckedBaseModel):
    type: typing.Literal["max_iterations_exceeded"] = "max_iterations_exceeded"
    step_latency_secs: float
    max_iterations: int

    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 WorkflowToolResponseModelOutputStepsItem_NestedTools(UncheckedBaseModel):
    type: typing.Literal["nested_tools"] = "nested_tools"
    step_latency_secs: float
    node_id: str
    requests: typing.List[ConversationHistoryTranscriptToolCallCommonModelOutput]
    results: typing.List["WorkflowToolNestedToolsStepModelOutputResultsItem"]
    is_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


WorkflowToolResponseModelOutputStepsItem = typing_extensions.Annotated[
    typing.Union[
        WorkflowToolResponseModelOutputStepsItem_Edge,
        WorkflowToolResponseModelOutputStepsItem_MaxIterationsExceeded,
        WorkflowToolResponseModelOutputStepsItem_NestedTools,
    ],
    UnionMetadata(discriminant="type"),
]
from .conversation_history_transcript_workflow_tools_result_common_model_output import (
    ConversationHistoryTranscriptWorkflowToolsResultCommonModelOutput,
)  # noqa: E402, I001
from .workflow_tool_nested_tools_step_model_output_results_item import WorkflowToolNestedToolsStepModelOutputResultsItem  # noqa: E402, I001
from .workflow_tool_response_model_output import WorkflowToolResponseModelOutput  # noqa: E402, I001

update_forward_refs(
    WorkflowToolResponseModelOutputStepsItem_NestedTools,
    ConversationHistoryTranscriptWorkflowToolsResultCommonModelOutput=ConversationHistoryTranscriptWorkflowToolsResultCommonModelOutput,
    WorkflowToolNestedToolsStepModelOutputResultsItem=WorkflowToolNestedToolsStepModelOutputResultsItem,
    WorkflowToolResponseModelOutput=WorkflowToolResponseModelOutput,
    WorkflowToolResponseModelOutputStepsItem=WorkflowToolResponseModelOutputStepsItem,
)
