# 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
from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata
from .knowledge_base_rag_tool_status import KnowledgeBaseRagToolStatus
from .transfer_to_agent_tool_result_success_model_branch_info import TransferToAgentToolResultSuccessModelBranchInfo


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_EndCallSuccess(UncheckedBaseModel):
    result_type: typing.Literal["end_call_success"] = "end_call_success"
    status: typing.Optional[typing.Literal["success"]] = None
    reason: typing.Optional[str] = None
    message: 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_KnowledgeBaseRagSuccess(UncheckedBaseModel):
    result_type: typing.Literal["knowledge_base_rag_success"] = "knowledge_base_rag_success"
    status: typing.Optional[KnowledgeBaseRagToolStatus] = None
    chunk_count: typing.Optional[int] = None
    message: 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_LanguageDetectionSuccess(UncheckedBaseModel):
    result_type: typing.Literal["language_detection_success"] = "language_detection_success"
    status: typing.Optional[typing.Literal["success"]] = None
    reason: typing.Optional[str] = None
    language: 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_PlayDtmfError(UncheckedBaseModel):
    result_type: typing.Literal["play_dtmf_error"] = "play_dtmf_error"
    status: typing.Optional[typing.Literal["error"]] = None
    error: str
    details: 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_PlayDtmfSuccess(UncheckedBaseModel):
    result_type: typing.Literal["play_dtmf_success"] = "play_dtmf_success"
    status: typing.Optional[typing.Literal["success"]] = None
    dtmf_tones: str
    reason: 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_SkipTurnSuccess(UncheckedBaseModel):
    result_type: typing.Literal["skip_turn_success"] = "skip_turn_success"
    status: typing.Optional[typing.Literal["success"]] = None
    reason: 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TestingToolResult(UncheckedBaseModel):
    result_type: typing.Literal["testing_tool_result"] = "testing_tool_result"
    status: typing.Optional[typing.Literal["success"]] = None
    reason: 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToAgentError(UncheckedBaseModel):
    result_type: typing.Literal["transfer_to_agent_error"] = "transfer_to_agent_error"
    status: typing.Optional[typing.Literal["error"]] = None
    from_agent: str
    error: 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 ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToAgentSuccess(UncheckedBaseModel):
    result_type: typing.Literal["transfer_to_agent_success"] = "transfer_to_agent_success"
    status: typing.Optional[typing.Literal["success"]] = None
    from_agent: str
    to_agent: str
    to_node: typing.Optional[str] = None
    condition: str
    delay_ms: typing.Optional[int] = None
    transfer_message: typing.Optional[str] = None
    enable_transferred_agent_first_message: typing.Optional[bool] = None
    branch_info: typing.Optional[TransferToAgentToolResultSuccessModelBranchInfo] = None
    preserve_client_tts_overrides: typing.Optional[bool] = 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToNumberError(UncheckedBaseModel):
    result_type: typing.Literal["transfer_to_number_error"] = "transfer_to_number_error"
    status: typing.Optional[typing.Literal["error"]] = None
    error: str
    details: 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToNumberExotelSuccess(
    UncheckedBaseModel
):
    result_type: typing.Literal["transfer_to_number_exotel_success"] = "transfer_to_number_exotel_success"
    status: typing.Optional[typing.Literal["success"]] = None
    transfer_number: str
    reason: typing.Optional[str] = None
    agent_message: typing.Optional[str] = None
    note: 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToNumberSipSuccess(
    UncheckedBaseModel
):
    result_type: typing.Literal["transfer_to_number_sip_success"] = "transfer_to_number_sip_success"
    status: typing.Optional[typing.Literal["success"]] = None
    transfer_number: str
    reason: typing.Optional[str] = None
    note: 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToNumberTwilioSuccess(
    UncheckedBaseModel
):
    result_type: typing.Literal["transfer_to_number_twilio_success"] = "transfer_to_number_twilio_success"
    status: typing.Optional[typing.Literal["success"]] = None
    transfer_number: str
    reason: typing.Optional[str] = None
    client_message: typing.Optional[str] = None
    agent_message: str
    conference_name: str
    post_dial_digits: typing.Optional[str] = None
    note: 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


class ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_VoicemailDetectionSuccess(
    UncheckedBaseModel
):
    result_type: typing.Literal["voicemail_detection_success"] = "voicemail_detection_success"
    status: typing.Optional[typing.Literal["success"]] = None
    voicemail_message: typing.Optional[str] = None
    reason: 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


ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult = typing_extensions.Annotated[
    typing.Union[
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_EndCallSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_KnowledgeBaseRagSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_LanguageDetectionSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_PlayDtmfError,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_PlayDtmfSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_SkipTurnSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TestingToolResult,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToAgentError,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToAgentSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToNumberError,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToNumberExotelSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToNumberSipSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_TransferToNumberTwilioSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelOutputResult_VoicemailDetectionSuccess,
    ],
    UnionMetadata(discriminant="result_type"),
]
