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

from __future__ import annotations
from .streamedcompletionstokencomplete import (
    StreamedCompletionsTokenComplete,
    StreamedCompletionsTokenCompleteTypedDict,
)
from .streamedcompletionstokensampled import (
    StreamedCompletionsTokenSampled,
    StreamedCompletionsTokenSampledTypedDict,
)
from friendli.types import BaseModel
from friendli.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union
from typing_extensions import Annotated, TypedDict


StreamedCompletionsResultDataTypedDict = Union[
    StreamedCompletionsTokenCompleteTypedDict, StreamedCompletionsTokenSampledTypedDict
]


StreamedCompletionsResultData = Annotated[
    Union[
        Annotated[StreamedCompletionsTokenSampled, Tag("token_sampled")],
        Annotated[StreamedCompletionsTokenComplete, Tag("complete")],
    ],
    Discriminator(lambda m: get_discriminator(m, "event", "event")),
]


class StreamedCompletionsResultTypedDict(TypedDict):
    r"""Successfully generated completions."""

    data: StreamedCompletionsResultDataTypedDict


class StreamedCompletionsResult(BaseModel):
    r"""Successfully generated completions."""

    data: StreamedCompletionsResultData
