# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pyformat: disable

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

from __future__ import annotations
from .. import BaseModel, UNSET_SENTINEL
from .imageconfig import ImageConfig, ImageConfigParam
from .speechconfig import SpeechConfig, SpeechConfigParam
from .thinkinglevel import ThinkingLevel
from .thinkingsummaries import ThinkingSummaries
from .toolchoiceconfig import ToolChoiceConfig, ToolChoiceConfigParam
from .toolchoicetype import ToolChoiceType
from .transcriptionconfig import TranscriptionConfig, TranscriptionConfigParam
from .videoconfig import VideoConfig, VideoConfigParam
import pydantic
from pydantic import model_serializer
from typing import List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


ToolChoiceParam = TypeAliasType(
    "ToolChoiceParam", Union[ToolChoiceConfigParam, ToolChoiceType]
)
r"""The tool choice configuration."""


ToolChoice = TypeAliasType("ToolChoice", Union[ToolChoiceConfig, ToolChoiceType])
r"""The tool choice configuration."""


class GenerationConfigParam(TypedDict):
    r"""Configuration parameters for model interactions."""

    image_config: NotRequired[ImageConfigParam]
    r"""The configuration for image interaction."""
    max_output_tokens: NotRequired[int]
    r"""The maximum number of tokens to include in the response."""
    seed: NotRequired[int]
    r"""Seed used in decoding for reproducibility."""
    speech_config: NotRequired[List[SpeechConfigParam]]
    r"""Configuration for speech interaction."""
    stop_sequences: NotRequired[List[str]]
    r"""A list of character sequences that will stop output interaction."""
    thinking_level: NotRequired[ThinkingLevel]
    thinking_summaries: NotRequired[ThinkingSummaries]
    tool_choice: NotRequired[ToolChoiceParam]
    r"""The tool choice configuration."""
    transcription_config: NotRequired[TranscriptionConfigParam]
    r"""Configuration for speech recognition (transcription)."""
    video_config: NotRequired[VideoConfigParam]
    r"""Configuration options for video generation."""


class GenerationConfig(BaseModel):
    r"""Configuration parameters for model interactions."""

    image_config: Annotated[
        Optional[ImageConfig],
        pydantic.Field(
            deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
        ),
    ] = None
    r"""The configuration for image interaction."""

    max_output_tokens: Optional[int] = None
    r"""The maximum number of tokens to include in the response."""

    seed: Optional[int] = None
    r"""Seed used in decoding for reproducibility."""

    speech_config: Optional[List[SpeechConfig]] = None
    r"""Configuration for speech interaction."""

    stop_sequences: Optional[List[str]] = None
    r"""A list of character sequences that will stop output interaction."""

    thinking_level: Optional[ThinkingLevel] = None

    thinking_summaries: Optional[ThinkingSummaries] = None

    tool_choice: Optional[ToolChoice] = None
    r"""The tool choice configuration."""

    transcription_config: Optional[TranscriptionConfig] = None
    r"""Configuration for speech recognition (transcription)."""

    video_config: Optional[VideoConfig] = None
    r"""Configuration options for video generation."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "image_config",
                "max_output_tokens",
                "seed",
                "speech_config",
                "stop_sequences",
                "thinking_level",
                "thinking_summaries",
                "tool_choice",
                "transcription_config",
                "video_config",
            ]
        )
        serialized = handler(self)
        m = {}

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

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

        return m
