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

from __future__ import annotations
from .completionresponse import CompletionResponse, CompletionResponseTypedDict
from .completionstreamevent import CompletionStreamEvent, CompletionStreamEventTypedDict
from r9s.types import BaseModel
from r9s.utils import eventstreaming
from typing import Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict


class CreateCompletionResponseBodyTypedDict(TypedDict):
    r"""Successful response"""

    data: CompletionStreamEventTypedDict
    r"""Completion stream event (data payload for SSE stream)"""
    id: NotRequired[str]
    event: NotRequired[str]
    retry: NotRequired[int]


class CreateCompletionResponseBody(BaseModel):
    r"""Successful response"""

    data: CompletionStreamEvent
    r"""Completion stream event (data payload for SSE stream)"""

    id: Optional[str] = None

    event: Optional[str] = None

    retry: Optional[int] = None


CreateCompletionResponseTypedDict = TypeAliasType(
    "CreateCompletionResponseTypedDict",
    Union[
        CompletionResponseTypedDict,
        Union[
            eventstreaming.EventStream[CompletionStreamEventTypedDict],
            eventstreaming.EventStreamAsync[CompletionStreamEventTypedDict],
        ],
    ],
)


CreateCompletionResponse = TypeAliasType(
    "CreateCompletionResponse",
    Union[
        CompletionResponse,
        Union[
            eventstreaming.EventStream[CompletionStreamEvent],
            eventstreaming.EventStreamAsync[CompletionStreamEvent],
        ],
    ],
)
