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

from __future__ import annotations
from .completionslogprobs import CompletionsLogprobs, CompletionsLogprobsTypedDict
from friendli.types import BaseModel
from typing import List, Literal, Optional
from typing_extensions import NotRequired, TypedDict


CompletionsChoiceFinishReason = Literal["stop", "length"]
r"""Termination condition of the generation. `stop` means the API returned the full chat completions generated by the model without running into any limits. `length` means the generation exceeded `max_tokens` or the conversation exceeded the max context length."""


class CompletionsChoiceTypedDict(TypedDict):
    index: int
    r"""The index of the choice in the list of generated choices."""
    seed: int
    r"""Random seed used for the generation."""
    text: str
    r"""Generated text output."""
    tokens: List[int]
    r"""Generated output tokens."""
    finish_reason: CompletionsChoiceFinishReason
    r"""Termination condition of the generation. `stop` means the API returned the full chat completions generated by the model without running into any limits. `length` means the generation exceeded `max_tokens` or the conversation exceeded the max context length."""
    logprobs: NotRequired[CompletionsLogprobsTypedDict]
    r"""Log probability information for the choice."""


class CompletionsChoice(BaseModel):
    index: int
    r"""The index of the choice in the list of generated choices."""

    seed: int
    r"""Random seed used for the generation."""

    text: str
    r"""Generated text output."""

    tokens: List[int]
    r"""Generated output tokens."""

    finish_reason: CompletionsChoiceFinishReason
    r"""Termination condition of the generation. `stop` means the API returned the full chat completions generated by the model without running into any limits. `length` means the generation exceeded `max_tokens` or the conversation exceeded the max context length."""

    logprobs: Optional[CompletionsLogprobs] = None
    r"""Log probability information for the choice."""
