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

from __future__ import annotations

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .llm_as_judge_code_write import LlmAsJudgeCodeWrite
from .trace_thread_llm_as_judge_code_write import TraceThreadLlmAsJudgeCodeWrite
from .trace_thread_user_defined_metric_python_code_write import TraceThreadUserDefinedMetricPythonCodeWrite
from .user_defined_metric_python_code_write import UserDefinedMetricPythonCodeWrite


class Base(UniversalBaseModel):
    project_id: str
    name: str
    sampling_rate: typing.Optional[float] = None
    enabled: typing.Optional[bool] = None
    action: typing.Literal["evaluator"] = "evaluator"

    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 AutomationRuleEvaluatorWrite_LlmAsJudge(Base):
    type: typing.Literal["llm_as_judge"] = "llm_as_judge"
    code: typing.Optional[LlmAsJudgeCodeWrite] = 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 AutomationRuleEvaluatorWrite_UserDefinedMetricPython(Base):
    type: typing.Literal["user_defined_metric_python"] = "user_defined_metric_python"
    code: typing.Optional[UserDefinedMetricPythonCodeWrite] = 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 AutomationRuleEvaluatorWrite_TraceThreadLlmAsJudge(Base):
    type: typing.Literal["trace_thread_llm_as_judge"] = "trace_thread_llm_as_judge"
    code: typing.Optional[TraceThreadLlmAsJudgeCodeWrite] = 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 AutomationRuleEvaluatorWrite_TraceThreadUserDefinedMetricPython(Base):
    type: typing.Literal["trace_thread_user_defined_metric_python"] = "trace_thread_user_defined_metric_python"
    code: typing.Optional[TraceThreadUserDefinedMetricPythonCodeWrite] = 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


AutomationRuleEvaluatorWrite = typing.Union[
    AutomationRuleEvaluatorWrite_LlmAsJudge,
    AutomationRuleEvaluatorWrite_UserDefinedMetricPython,
    AutomationRuleEvaluatorWrite_TraceThreadLlmAsJudge,
    AutomationRuleEvaluatorWrite_TraceThreadUserDefinedMetricPython,
]
