"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .bridgephrasemessages import BridgePhraseMessages, BridgePhraseMessagesTypedDict
from pydantic import model_serializer
from syllable_sdk.types import BaseModel, UNSET_SENTINEL
from typing import Dict, List, Optional
from typing_extensions import NotRequired, TypedDict


class BridgePhrasesConfigTypedDict(TypedDict):
    r"""Configuration for conversational bridge phrases.

    Top-level fields are the default (English) phrases.
    The `localized` dict provides per-language overrides keyed by BCP-47 language tag.
    """

    first_slow_messages: NotRequired[List[str]]
    r"""Messages to say when the agent is first delayed."""
    very_slow_messages: NotRequired[List[str]]
    r"""Messages to say when the agent is significantly delayed."""
    tool_responses: NotRequired[List[str]]
    r"""Messages to say when a tool call is in progress."""
    localized: NotRequired[Dict[str, BridgePhraseMessagesTypedDict]]
    r"""Per-language overrides keyed by BCP-47 tag (e.g. \"es-US\")."""


class BridgePhrasesConfig(BaseModel):
    r"""Configuration for conversational bridge phrases.

    Top-level fields are the default (English) phrases.
    The `localized` dict provides per-language overrides keyed by BCP-47 language tag.
    """

    first_slow_messages: Optional[List[str]] = None
    r"""Messages to say when the agent is first delayed."""

    very_slow_messages: Optional[List[str]] = None
    r"""Messages to say when the agent is significantly delayed."""

    tool_responses: Optional[List[str]] = None
    r"""Messages to say when a tool call is in progress."""

    localized: Optional[Dict[str, BridgePhraseMessages]] = None
    r"""Per-language overrides keyed by BCP-47 tag (e.g. \"es-US\")."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["first_slow_messages", "very_slow_messages", "tool_responses", "localized"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m
