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

from __future__ import annotations
from .responseobject import ResponseObject, ResponseObjectTypedDict
from .responseoutputitem import ResponseOutputItem, ResponseOutputItemTypedDict
from r9s.types import BaseModel
from typing import Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict


class ResponseStreamEvent2TypedDict(TypedDict):
    r"""Delta updates object format"""

    text: NotRequired[str]
    r"""Text delta content"""
    role: NotRequired[str]
    r"""Role delta"""
    content: NotRequired[str]
    r"""Content delta"""


class ResponseStreamEvent2(BaseModel):
    r"""Delta updates object format"""

    text: Optional[str] = None
    r"""Text delta content"""

    role: Optional[str] = None
    r"""Role delta"""

    content: Optional[str] = None
    r"""Content delta"""


DeltaTypedDict = TypeAliasType(
    "DeltaTypedDict", Union[ResponseStreamEvent2TypedDict, str]
)
r"""Delta updates (present in response.text.delta events), can be a string or object"""


Delta = TypeAliasType("Delta", Union[ResponseStreamEvent2, str])
r"""Delta updates (present in response.text.delta events), can be a string or object"""


class ResponseStreamEventTypedDict(TypedDict):
    r"""Response stream event (data payload for SSE stream)"""

    type: str
    r"""Event type (e.g., response.created, response.output_item.added, response.text.delta, response.completed)"""
    sequence_number: NotRequired[int]
    r"""Sequence number of the event"""
    response: NotRequired[ResponseObjectTypedDict]
    output_item: NotRequired[ResponseOutputItemTypedDict]
    output_item_index: NotRequired[int]
    r"""Index of the output item"""
    content_index: NotRequired[int]
    r"""Index of the content block"""
    delta: NotRequired[DeltaTypedDict]
    r"""Delta updates (present in response.text.delta events), can be a string or object"""


class ResponseStreamEvent(BaseModel):
    r"""Response stream event (data payload for SSE stream)"""

    type: str
    r"""Event type (e.g., response.created, response.output_item.added, response.text.delta, response.completed)"""

    sequence_number: Optional[int] = None
    r"""Sequence number of the event"""

    response: Optional[ResponseObject] = None

    output_item: Optional[ResponseOutputItem] = None

    output_item_index: Optional[int] = None
    r"""Index of the output item"""

    content_index: Optional[int] = None
    r"""Index of the content block"""

    delta: Optional[Delta] = None
    r"""Delta updates (present in response.text.delta events), can be a string or object"""
