"""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


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


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")),
]


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

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


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

    type: ContentPartDoneEventType

    output_index: float

    item_id: str

    content_index: float

    part: ContentPartDoneEventPart

    sequence_number: float
