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

from __future__ import annotations
from .openairesponsesrefusalcontent import (
    OpenAIResponsesRefusalContent,
    OpenAIResponsesRefusalContentTypedDict,
)
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
from openrouter.types import BaseModel
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Literal, Union
from typing_extensions import Annotated, TypeAliasType, TypedDict


ContentPartDoneEventPartTypedDict = TypeAliasType(
    "ContentPartDoneEventPartTypedDict",
    Union[
        ReasoningTextContentTypedDict,
        OpenAIResponsesRefusalContentTypedDict,
        ResponseOutputTextTypedDict,
    ],
)


ContentPartDoneEventPart = Annotated[
    Union[
        Annotated[ResponseOutputText, Tag("output_text")],
        Annotated[ReasoningTextContent, Tag("reasoning_text")],
        Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
    ],
    Discriminator(lambda m: get_discriminator(m, "type", "type")),
]


ContentPartDoneEventType = Literal["response.content_part.done",]


class ContentPartDoneEventTypedDict(TypedDict):
    r"""Event emitted when a content part is complete"""

    content_index: int
    item_id: str
    output_index: int
    part: ContentPartDoneEventPartTypedDict
    sequence_number: int
    type: ContentPartDoneEventType


class ContentPartDoneEvent(BaseModel):
    r"""Event emitted when a content part is complete"""

    content_index: int

    item_id: str

    output_index: int

    part: ContentPartDoneEventPart

    sequence_number: int

    type: ContentPartDoneEventType
