# 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_chunk_model import KnowledgeBaseRagChunkModel
from .knowledge_base_rag_tool_status import KnowledgeBaseRagToolStatus
from .knowledge_base_tool_status import KnowledgeBaseToolStatus
from .transfer_to_agent_tool_result_success_model_input_branch_info import (
    TransferToAgentToolResultSuccessModelInputBranchInfo,
)


class ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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
    chunks: typing.Optional[typing.List[KnowledgeBaseRagChunkModel]] = 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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_KnowledgeBaseSuccess(UncheckedBaseModel):
    result_type: typing.Literal["knowledge_base_success"] = "knowledge_base_success"
    status: typing.Optional[KnowledgeBaseToolStatus] = 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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_RunSubagentError(UncheckedBaseModel):
    result_type: typing.Literal["run_subagent_error"] = "run_subagent_error"
    status: typing.Optional[typing.Literal["error"]] = None
    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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_RunSubagentSuccess(UncheckedBaseModel):
    result_type: typing.Literal["run_subagent_success"] = "run_subagent_success"
    status: typing.Optional[typing.Literal["success"]] = None
    query: str
    agent_response: 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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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[TransferToAgentToolResultSuccessModelInputBranchInfo] = 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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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 ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_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


ConversationHistoryTranscriptSystemToolResultCommonModelInputResult = typing_extensions.Annotated[
    typing.Union[
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_EndCallSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_KnowledgeBaseRagSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_KnowledgeBaseSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_LanguageDetectionSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_PlayDtmfError,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_PlayDtmfSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_RunSubagentError,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_RunSubagentSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_SkipTurnSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_TestingToolResult,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_TransferToAgentError,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_TransferToAgentSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_TransferToNumberError,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_TransferToNumberExotelSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_TransferToNumberSipSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_TransferToNumberTwilioSuccess,
        ConversationHistoryTranscriptSystemToolResultCommonModelInputResult_VoicemailDetectionSuccess,
    ],
    UnionMetadata(discriminant="result_type"),
]
