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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
from .custom_guardrail_config_model import CustomGuardrailConfigModel
from .custom_guardrail_config_trigger_action import CustomGuardrailConfigTriggerAction
from .guardrail_execution_mode import GuardrailExecutionMode


class CustomGuardrailConfig(UncheckedBaseModel):
    """
    Single custom guardrail configuration
    """

    is_enabled: typing.Optional[bool] = None
    name: str = pydantic.Field()
    """
    User-facing name for this guardrail
    """

    prompt: str = pydantic.Field()
    """
    Instruction describing what to block, e.g. 'don't talk about politics'
    """

    execution_mode: typing.Optional[GuardrailExecutionMode] = None
    model: typing.Optional[CustomGuardrailConfigModel] = pydantic.Field(default=None)
    """
    LLM model to use for custom guardrail evaluation
    """

    history_message_count: typing.Optional[int] = pydantic.Field(default=None)
    """
    How many recent customer messages to include in the guardrail's history, plus the messages that follow them. Only customer messages count toward the limit. 0 (default) shows none; 1 shows the customer's latest message onward. When > 0, the guardrail prompt can refer to this history as <conversation_history>; the reply under evaluation appears as <agent_message> and may repeat at the end of the history.
    """

    trigger_action: typing.Optional[CustomGuardrailConfigTriggerAction] = 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
