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

from __future__ import annotations
from ...core.pydantic_utilities import UniversalBaseModel
import typing
from ...core.pydantic_utilities import IS_PYDANTIC_V2
import pydantic
import typing_extensions
from ...conversation.types.numeric_conversation_field import NumericConversationField
from ...core.serialization import FieldMetadata
from ...conversation.types.conversation_field import ConversationField


class ConversationMetric_Count(UniversalBaseModel):
    """
    Defines the metric to be calculated for a column or chart.
    Only numeric fields are supported, except for ConversationCount and ConversationDistinctCount, which can be applied to any field.
    """

    type: typing.Literal["count"] = "count"

    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 ConversationMetric_Sum(UniversalBaseModel):
    """
    Defines the metric to be calculated for a column or chart.
    Only numeric fields are supported, except for ConversationCount and ConversationDistinctCount, which can be applied to any field.
    """

    type: typing.Literal["sum"] = "sum"
    target_field: typing_extensions.Annotated[NumericConversationField, FieldMetadata(alias="targetField")]

    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 ConversationMetric_Average(UniversalBaseModel):
    """
    Defines the metric to be calculated for a column or chart.
    Only numeric fields are supported, except for ConversationCount and ConversationDistinctCount, which can be applied to any field.
    """

    type: typing.Literal["average"] = "average"
    target_field: typing_extensions.Annotated[NumericConversationField, FieldMetadata(alias="targetField")]

    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 ConversationMetric_Min(UniversalBaseModel):
    """
    Defines the metric to be calculated for a column or chart.
    Only numeric fields are supported, except for ConversationCount and ConversationDistinctCount, which can be applied to any field.
    """

    type: typing.Literal["min"] = "min"
    target_field: typing_extensions.Annotated[NumericConversationField, FieldMetadata(alias="targetField")]

    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 ConversationMetric_Max(UniversalBaseModel):
    """
    Defines the metric to be calculated for a column or chart.
    Only numeric fields are supported, except for ConversationCount and ConversationDistinctCount, which can be applied to any field.
    """

    type: typing.Literal["max"] = "max"
    target_field: typing_extensions.Annotated[NumericConversationField, FieldMetadata(alias="targetField")]

    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 ConversationMetric_Percentile(UniversalBaseModel):
    """
    Defines the metric to be calculated for a column or chart.
    Only numeric fields are supported, except for ConversationCount and ConversationDistinctCount, which can be applied to any field.
    """

    type: typing.Literal["percentile"] = "percentile"
    percentile: float
    target_field: typing_extensions.Annotated[NumericConversationField, FieldMetadata(alias="targetField")]

    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 ConversationMetric_Median(UniversalBaseModel):
    """
    Defines the metric to be calculated for a column or chart.
    Only numeric fields are supported, except for ConversationCount and ConversationDistinctCount, which can be applied to any field.
    """

    type: typing.Literal["median"] = "median"
    target_field: typing_extensions.Annotated[NumericConversationField, FieldMetadata(alias="targetField")]

    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 ConversationMetric_DistinctCount(UniversalBaseModel):
    """
    Defines the metric to be calculated for a column or chart.
    Only numeric fields are supported, except for ConversationCount and ConversationDistinctCount, which can be applied to any field.
    """

    type: typing.Literal["distinctCount"] = "distinctCount"
    target_field: typing_extensions.Annotated[ConversationField, FieldMetadata(alias="targetField")]

    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


ConversationMetric = typing.Union[
    ConversationMetric_Count,
    ConversationMetric_Sum,
    ConversationMetric_Average,
    ConversationMetric_Min,
    ConversationMetric_Max,
    ConversationMetric_Percentile,
    ConversationMetric_Median,
    ConversationMetric_DistinctCount,
]
