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

from __future__ import annotations
from .chatcompletionstreamchoice import (
    ChatCompletionStreamChoice,
    ChatCompletionStreamChoiceTypedDict,
)
from .usage import Usage, UsageTypedDict
import pydantic
from pydantic.functional_validators import AfterValidator
from r9s.types import BaseModel
from r9s.utils import validate_const
from typing import List, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ChatCompletionStreamEventTypedDict(TypedDict):
    r"""Chat completion chunk event (data payload for SSE stream)"""

    id: str
    created: int
    r"""Unix timestamp"""
    model: str
    choices: List[ChatCompletionStreamChoiceTypedDict]
    r"""Array of completion choices. May be empty in the final chunk when only usage is returned."""
    object: Literal["chat.completion.chunk"]
    system_fingerprint: NotRequired[str]
    usage: NotRequired[UsageTypedDict]


class ChatCompletionStreamEvent(BaseModel):
    r"""Chat completion chunk event (data payload for SSE stream)"""

    id: str

    created: int
    r"""Unix timestamp"""

    model: str

    choices: List[ChatCompletionStreamChoice]
    r"""Array of completion choices. May be empty in the final chunk when only usage is returned."""

    OBJECT: Annotated[
        Annotated[
            Literal["chat.completion.chunk"],
            AfterValidator(validate_const("chat.completion.chunk")),
        ],
        pydantic.Field(alias="object"),
    ] = "chat.completion.chunk"

    system_fingerprint: Optional[str] = None

    usage: Optional[Usage] = None
