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


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


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


ContentPartAddedEventType = Literal["response.content_part.added",]


class ContentPartAddedEventTypedDict(TypedDict):
    r"""Event emitted when a new content part is added to an output item"""

    content_index: int
    item_id: str
    output_index: int
    part: ContentPartAddedEventPartTypedDict
    sequence_number: int
    type: ContentPartAddedEventType


class ContentPartAddedEvent(BaseModel):
    r"""Event emitted when a new content part is added to an output item"""

    content_index: int

    item_id: str

    output_index: int

    part: ContentPartAddedEventPart

    sequence_number: int

    type: ContentPartAddedEventType
